Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

add method to set default tag on image#187

Closed
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletionscoder-sdk/tags.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
ContributorAuthor

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 theSetDefaultImageTag take atag 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 structCreateImageTagReq.

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
Expand DownExpand Up@@ -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)
Copy link
ContributorAuthor

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.

}

[8]ページ先頭

©2009-2025 Movatter.jp