Skip to content

Commit 916a878

Browse files
committed
Update installer to use new update-sent endpoint
1 parent 4257c7f commit 916a878

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

installer/config/const.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,24 @@ import (
55
"time"
66
)
77

8-
const INSTALLER_VERSION = ""
9-
const REPLACE = ""
10-
const PUBLIC_KEY = ``
8+
const INSTALLER_VERSION = "v11.0.0-alpha.1"
9+
const REPLACE = "0aXq879sPfvy2Zrc"
10+
const PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
11+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxoZ5m/bsj4NOlSblXPg3
12+
eGbx2nCg5jMoVsCevxX64+MkOpwHBNiA0VPCZfOrdv2atWbOnJ7KfmZJWWZFSlTf
13+
tJ6VA0jaODnSlQeoTn/XIMKkfyzxKgLN+miG89M4ysidZgHPYlwz8+R1gIPouxYa
14+
BUQ8mUgRrkW3JCpYoGvf6k0Od9k8NXdR52rFf0Ryl6oGwedOWh/tiYE0he0pWkB7
15+
zPAveFqvxJnte4aN1Xjv2Qp1OmQVvc37RMZsh8oNpfYTMxrGFWZpBmF61NLXOYjn
16+
YtvKtxUQPR/TOf9p55H9cFeRf2LzSAM4L3NQ3Xdss6eWndjywL5Giqd2gtrD/1Tt
17+
+wIDAQAB
18+
-----END PUBLIC KEY-----
19+
`
1120

1221
const (
1322
RegisterInstanceEndpoint = "/api/v1/instances/register"
1423
GetInstanceDetailsEndpoint = "/api/v1/instances"
1524
GetUpdatesInfoEndpoint = "/api/v1/updates"
25+
SetUpdateSentEndpoint = "/api/v1/updates/sent"
1626
GetLicenseEndpoint = "/api/v1/licenses"
1727
HealthEndpoint = "/api/v1/health"
1828
LogCollectorEndpoint = "/api/v1/logcollectors/upload"

installer/updater/client.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func (c *UpdaterClient) CheckUpdate() error {
9999
newUpdate["version"] = update.Version.Version
100100
newUpdate["edition"] = update.Instance.Edition
101101
newUpdate["changelog"] = update.Version.Changelog
102+
newUpdate["id"] = update.ID
102103
updates = append(updates, newUpdate)
103104
}
104105
} else {
@@ -110,6 +111,7 @@ func (c *UpdaterClient) CheckUpdate() error {
110111
newUpdate["version"] = v
111112
newUpdate["edition"] = "enterprise"
112113
newUpdate["changelog"] = "No changelog available for offline version"
114+
newUpdate["id"] = "offline"
113115
updates = append(updates, newUpdate)
114116
}
115117

@@ -124,6 +126,12 @@ func (c *UpdaterClient) CheckUpdate() error {
124126
if err != nil {
125127
return fmt.Errorf("error updating to new version: %v", err)
126128
}
129+
if update["id"] != "offline" {
130+
err = c.MarkUpdateSent(update["id"])
131+
if err != nil {
132+
return fmt.Errorf("error marking update as sent: %v", err)
133+
}
134+
}
127135
}
128136
}
129137

@@ -155,6 +163,21 @@ func (c *UpdaterClient) UpdateToNewVersion(version, edition, changelog string) e
155163
return nil
156164
}
157165

166+
func (c *UpdaterClient) MarkUpdateSent(updateId string) error {
167+
url := fmt.Sprintf("%s%s?id=%s", c.Config.Server, config.SetUpdateSentEndpoint, updateId)
168+
_, status, err := utils.DoReq[any](
169+
url,
170+
nil,
171+
http.MethodPost,
172+
map[string]string{"id": c.Config.InstanceID, "key": c.Config.InstanceKey},
173+
nil,
174+
)
175+
if err != nil || status != http.StatusOK {
176+
return fmt.Errorf("error marking update as sent: status: %d, error: %v", status, err)
177+
}
178+
return nil
179+
}
180+
158181
func (c *UpdaterClient) UploadLogs(ctx context.Context, path string) error {
159182
url := fmt.Sprintf("%s%s", c.Config.Server, config.LogCollectorEndpoint)
160183

0 commit comments

Comments
 (0)