From 62364983b53b602949d1898cf0540c148af2503b Mon Sep 17 00:00:00 2001 From: Javier Campanini Date: Sat, 14 Nov 2020 01:08:24 -0500 Subject: [PATCH 1/2] add sdk method to patch an image --- coder-sdk/image.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/coder-sdk/image.go b/coder-sdk/image.go index 78fad426..85f4636f 100644 --- a/coder-sdk/image.go +++ b/coder-sdk/image.go @@ -44,6 +44,16 @@ type ImportImageReq struct { URL string `json:"url"` } +// UpdateImageReq defines the requests parameters for a partial update of an image resource. +type UpdateImageReq struct { + DefaultCPUCores *float32 `json:"default_cpu_cores"` + DefaultMemoryGB *int `json:"default_memory_gb"` + DefaultDiskGB *int `json:"default_disk_gb"` + Description *string `json:"description"` + URL *string `json:"url"` + Deprecated *bool `json:"deprecated"` +} + // ImportImage creates a new image and optionally a new registry. func (c Client) ImportImage(ctx context.Context, orgID string, req ImportImageReq) (*Image, error) { var img Image @@ -61,3 +71,8 @@ func (c Client) OrganizationImages(ctx context.Context, orgID string) ([]Image, } return imgs, nil } + +// UpdateImage applies a partial update to an image resource. +func (c Client) UpdateImage(ctx context.Context, imageID string, req UpdateImageReq) error { + return c.requestBody(ctx, http.MethodPatch, "/api/images/"+imageID, req, nil) +} From b7fbf9c576bae5e8c1e86defadb053f6a6c7fa15 Mon Sep 17 00:00:00 2001 From: Javier Campanini Date: Mon, 16 Nov 2020 10:40:45 -0500 Subject: [PATCH 2/2] add default_tag Co-authored-by: Charles Moog --- coder-sdk/image.go | 1 + 1 file changed, 1 insertion(+) diff --git a/coder-sdk/image.go b/coder-sdk/image.go index 85f4636f..2ecaaba9 100644 --- a/coder-sdk/image.go +++ b/coder-sdk/image.go @@ -52,6 +52,7 @@ type UpdateImageReq struct { Description *string `json:"description"` URL *string `json:"url"` Deprecated *bool `json:"deprecated"` + DefaultTag *string `json:"default_tag"` } // ImportImage creates a new image and optionally a new registry.