Skip to content

Commit 022d2cf

Browse files
committed
update registrar client to expect ZosVersion instead of encoded string
1 parent c7672c4 commit 022d2cf

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

node-registrar/client/zos_version.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ package client
22

33
import (
44
"bytes"
5-
"encoding/base64"
65
"encoding/json"
76
"net/http"
87
"net/url"
9-
"strings"
108
"time"
119

1210
"github.com/pkg/errors"
@@ -80,23 +78,13 @@ func (c *RegistrarClient) setZosVersion(v string, safeToUpgrade bool) (err error
8078
SafeToUpgrade: safeToUpgrade,
8179
}
8280

83-
jsonData, err := json.Marshal(version)
81+
var body bytes.Buffer
82+
err = json.NewEncoder(&body).Encode(version)
8483
if err != nil {
85-
return errors.Wrap(err, "failed to marshal zos version")
84+
return errors.Wrap(err, "failed to encode request body")
8685
}
8786

88-
encodedVersion := struct {
89-
Version string `json:"version"`
90-
}{
91-
Version: base64.StdEncoding.EncodeToString(jsonData),
92-
}
93-
94-
jsonData, err = json.Marshal(encodedVersion)
95-
if err != nil {
96-
return errors.Wrap(err, "failed to marshal zos version in hex format")
97-
}
98-
99-
req, err := http.NewRequest("PUT", url, bytes.NewReader(jsonData))
87+
req, err := http.NewRequest("PUT", url, &body)
10088
if err != nil {
10189
return errors.Wrap(err, "failed to construct http request to the registrar")
10290
}

0 commit comments

Comments
 (0)