Skip to content

Commit a8d1807

Browse files
author
David Collom
committed
Make the selfhosting API Cleaner
1 parent d1dcf1e commit a8d1807

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

pkg/client/selfhosted/api_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ func (v *V1CompatibilityWrapper) UnmarshalJSON(b []byte) error {
4545
return json.Unmarshal([]byte(raw), &v.V1Compatibility)
4646
}
4747

48+
func (v V1CompatibilityWrapper) MarshalJSON() ([]byte, error) {
49+
marshaled, err := json.Marshal(v.V1Compatibility)
50+
if err != nil {
51+
return nil, err
52+
}
53+
return json.Marshal(string(marshaled)) // ← Double encode: inner to string
54+
}
55+
4856
type ErrorResponse struct {
4957
Errors []ErrorType `json:"errors"`
5058
}

pkg/client/selfhosted/selfhosted.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,6 @@ func (c *Client) Tags(ctx context.Context, host, repo, image string) ([]api.Imag
227227
tags[tag] = current
228228
}
229229

230-
if len(manifestListResponse.Manifests) == 0 {
231-
// TODO:
232-
}
233-
234230
for _, manifest := range manifestListResponse.Manifests {
235231

236232
// If we didn't get a SHA from the inital call,

pkg/client/selfhosted/selfhosted_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func TestTags(t *testing.T) {
144144
History: []History{
145145
{
146146
V1Compatibility: V1CompatibilityWrapper{
147-
V1Compatibility{Created: time.Now().Add(-24 * time.Hour)},
147+
V1Compatibility: V1Compatibility{Created: time.Now()},
148148
},
149149
},
150150
},

0 commit comments

Comments
 (0)