Skip to content

Commit

Permalink
fix parsing version for update worker
Browse files Browse the repository at this point in the history
Signed-off-by: Ashraf Fouda <[email protected]>
  • Loading branch information
ashraffouda committed Feb 19, 2025
1 parent bcc8e7e commit 59b95ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func getRolloutConfig(ctx context.Context, gw *stubs.RegistrarGatewayStub) (Regi
}

// if we are on devnet just update we don't need to update the version throught out the registrar
v := "0.0.0"
v := "v0.0.0"
if env.RunningMode != environment.RunningDev {
v, err = gw.GetZosVersion(ctx)
if err != nil {
Expand Down
12 changes: 7 additions & 5 deletions tools/zos-update-worker/internal/update_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,16 @@ func (r RegistrarClient) GetZosVersion() (RegistrarVersion, error) {
return RegistrarVersion{}, fmt.Errorf("failed to get version %s with status code %s", url, resp.Status)
}
defer resp.Body.Close()
fmt.Println(string(body))
fmt.Println(body[0])
jsonVersion, err := base64.StdEncoding.DecodeString(strings.Trim(string(body), "\""))
if err != nil {
return RegistrarVersion{}, err
return RegistrarVersion{}, fmt.Errorf("failed to decode version %w", err)
}
correctedJSON := strings.ReplaceAll(string(jsonVersion), "'", "\"")
var version RegistrarVersion
err = json.Unmarshal(jsonVersion, &version)
err = json.Unmarshal([]byte(correctedJSON), &version)
// err = json.NewDecoder(resp.Body).Decode(&version)
if err != nil {
return RegistrarVersion{}, err
return RegistrarVersion{}, fmt.Errorf("failed to unmarshal version %w", err)
}

return version, nil
Expand Down Expand Up @@ -178,6 +177,9 @@ func (w *Worker) updateZosVersion(network Network, regClient RegistrarClient) er
zosLink := fmt.Sprintf("%v/.tag-%v", path, regVersion.Version)

// update links zos
fmt.Println(zosCurrent)
fmt.Println(zosLatest)
fmt.Println(zosLink)
return w.updateLink(zosCurrent, zosLatest, zosLink)
}

Expand Down

0 comments on commit 59b95ec

Please sign in to comment.