Skip to content

Commit

Permalink
fix version encoding error
Browse files Browse the repository at this point in the history
  • Loading branch information
Eslam-Nawara committed Feb 16, 2025
1 parent b9fd88b commit bcc8e7e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
23 changes: 20 additions & 3 deletions pkg/registrar_gateway/registrar_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -437,10 +438,26 @@ func (r *registrarGateway) getZosVersion(url string) (string, error) {

defer resp.Body.Close()

var version string
err = json.NewDecoder(resp.Body).Decode(&version)
var versionString string
err = json.NewDecoder(resp.Body).Decode(&versionString)
if err != nil {
return "", err
}

versionBytes, err := base64.StdEncoding.DecodeString(versionString)
if err != nil {
return "", err
}

correctedJSON := strings.ReplaceAll(string(versionBytes), "'", "\"")

var version types.ZosVersion
err = json.NewDecoder(strings.NewReader(correctedJSON)).Decode(&version)
if err != nil {
return "", err
}

return version, err
return version.Version, err
}

func (r *registrarGateway) createNode(url string, node types.UpdateNodeRequest) (nodeID uint64, err error) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ type UptimeReport struct {
}

type ZosVersion struct {
Version string `json:"version"`
Version string `json:"version"`
SafeToUpgrade bool `json:"safe_to_upgrade"`
}

type Interface struct {
Expand Down

0 comments on commit bcc8e7e

Please sign in to comment.