- Notifications
You must be signed in to change notification settings - Fork18
add method to set default tag on image#187
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -35,6 +35,11 @@ type CreateImageTagReq struct { | ||
Default bool `json:"default"` | ||
} | ||
// SetDefaultTagReq is used to set the default tag for an image. | ||
type SetDefaultTagReq struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Another approach is to have the I went with this approach since it seemed to mirror the existing struct | ||
DefaultTag string `json:"default_tag"` | ||
} | ||
// CreateImageTag creates a new image tag resource. | ||
func (c Client) CreateImageTag(ctx context.Context, imageID string, req CreateImageTagReq) (*ImageTag, error) { | ||
var tag ImageTag | ||
@@ -66,3 +71,8 @@ func (c Client) ImageTagByID(ctx context.Context, imageID, tagID string) (*Image | ||
} | ||
return &tag, nil | ||
} | ||
// SetDefaultImageTag sets the default tag for an image. The tag must exist before calling this method. | ||
func (c Client) SetDefaultImageTag(ctx context.Context, imageID string, req SetDefaultTagReq) error { | ||
return c.requestBody(ctx, http.MethodPatch, "/api/images/"+imageID, req, nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This method returns the image, but I don't think that's necessary if you already have the imageID and this method returns without an error - the only changed value would be the default tag field. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Totally agree. Returning an error alone seems appropriate here. | ||
} |