Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

add method to set default tag on image #187

Closed

Conversation

jmcampanini
Copy link
Contributor

Allow the SDK to set the default tag for an image. We have a scenario where we'd like to update the default tag of an image to a pre-existing tag (so we can't use the create call with default=true).

@@ -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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another approach is to have the SetDefaultImageTag take a tag string instead, and then we build the JSON struct either on the fly or build it using an inline struct.

I went with this approach since it seemed to mirror the existing struct CreateImageTagReq.


// 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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree. Returning an error alone seems appropriate here.

@cmoog
Copy link
Contributor

cmoog commented Nov 14, 2020

Can this functionality be folded under #188 ? We could modify the UpdateImageReq to include

DefaultTag string `json:"default_tag"`

@jmcampanini
Copy link
Contributor Author

my understanding from the UpdateImageReq is that fields are all optional. if that's the case, i like the idea of closing this in favor of the update method!

@jmcampanini jmcampanini deleted the jc/add-setdefaultimagetag branch November 16, 2020 15:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants