diff --git a/ci/integration/envs_test.go b/ci/integration/envs_test.go index 634496f7..8401e872 100644 --- a/ci/integration/envs_test.go +++ b/ci/integration/envs_test.go @@ -81,8 +81,9 @@ search: } if !found { // ignore this error for now as it causes a race with other parallel tests - _, _ = client.ImportImage(ctx, org.ID, coder.ImportImageReq{ + _, _ = client.ImportImage(ctx, coder.ImportImageReq{ RegistryID: &dockerhubID, + OrgID: org.ID, Repository: img, Tag: "latest", DefaultCPUCores: 2.5, diff --git a/coder-sdk/image.go b/coder-sdk/image.go index f9478a8b..0290b25e 100644 --- a/coder-sdk/image.go +++ b/coder-sdk/image.go @@ -3,6 +3,7 @@ package coder import ( "context" "net/http" + "net/url" "time" ) @@ -36,6 +37,7 @@ type ImportImageReq struct { RegistryID *string `json:"registry_id"` // Used to import images to existing registries. NewRegistry *NewRegistryRequest `json:"new_registry"` // Used when adding a new registry. Repository string `json:"repository"` // Refers to the image. Ex: "codercom/ubuntu". + OrgID string `json:"org_id"` Tag string `json:"tag"` DefaultCPUCores float32 `json:"default_cpu_cores"` DefaultMemoryGB int `json:"default_memory_gb"` @@ -56,9 +58,9 @@ type UpdateImageReq struct { } // ImportImage creates a new image and optionally a new registry. -func (c Client) ImportImage(ctx context.Context, orgID string, req ImportImageReq) (*Image, error) { +func (c Client) ImportImage(ctx context.Context, req ImportImageReq) (*Image, error) { var img Image - if err := c.requestBody(ctx, http.MethodPost, "/api/private/orgs/"+orgID+"/images", req, &img); err != nil { + if err := c.requestBody(ctx, http.MethodPost, "/api/v0/images", req, &img); err != nil { return nil, err } return &img, nil @@ -66,8 +68,14 @@ func (c Client) ImportImage(ctx context.Context, orgID string, req ImportImageRe // OrganizationImages returns all of the images imported for orgID. func (c Client) OrganizationImages(ctx context.Context, orgID string) ([]Image, error) { - var imgs []Image - if err := c.requestBody(ctx, http.MethodGet, "/api/private/orgs/"+orgID+"/images", nil, &imgs); err != nil { + var ( + imgs []Image + query = url.Values{} + ) + + query.Set("org", orgID) + + if err := c.requestBody(ctx, http.MethodGet, "/api/v0/images", nil, &imgs, withQueryParams(query)); err != nil { return nil, err } return imgs, nil @@ -75,10 +83,10 @@ func (c Client) OrganizationImages(ctx context.Context, orgID string) ([]Image, // 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/private/images/"+imageID, req, nil) + return c.requestBody(ctx, http.MethodPatch, "/api/v0/images/"+imageID, req, nil) } // UpdateImageTags refreshes the latest digests for all tags of the image. func (c Client) UpdateImageTags(ctx context.Context, imageID string) error { - return c.requestBody(ctx, http.MethodPost, "/api/private/images/"+imageID+"/tags/update", nil, nil) + return c.requestBody(ctx, http.MethodPost, "/api/v0/images/"+imageID+"/tags/update", nil, nil) } diff --git a/coder-sdk/registries.go b/coder-sdk/registries.go index 4f4ff3ca..820a97c8 100644 --- a/coder-sdk/registries.go +++ b/coder-sdk/registries.go @@ -3,6 +3,7 @@ package coder import ( "context" "net/http" + "net/url" "time" ) @@ -18,17 +19,23 @@ type Registry struct { // Registries fetches all registries in an organization. func (c Client) Registries(ctx context.Context, orgID string) ([]Registry, error) { - var r []Registry - if err := c.requestBody(ctx, http.MethodGet, "/api/private/orgs/"+orgID+"/registries", nil, &r); err != nil { + var ( + r []Registry + query = url.Values{} + ) + + query.Set("org", orgID) + + if err := c.requestBody(ctx, http.MethodGet, "/api/v0/registries", nil, &r, withQueryParams(query)); err != nil { return nil, err } return r, nil } // RegistryByID fetches a registry resource by its ID. -func (c Client) RegistryByID(ctx context.Context, orgID, registryID string) (*Registry, error) { +func (c Client) RegistryByID(ctx context.Context, registryID string) (*Registry, error) { var r Registry - if err := c.requestBody(ctx, http.MethodGet, "/api/private/orgs/"+orgID+"/registries/"+registryID, nil, &r); err != nil { + if err := c.requestBody(ctx, http.MethodGet, "/api/v0/registries/"+registryID, nil, &r); err != nil { return nil, err } return &r, nil @@ -43,11 +50,11 @@ type UpdateRegistryReq struct { } // UpdateRegistry applies a partial update to a registry resource. -func (c Client) UpdateRegistry(ctx context.Context, orgID, registryID string, req UpdateRegistryReq) error { - return c.requestBody(ctx, http.MethodPatch, "/api/private/orgs/"+orgID+"/registries/"+registryID, req, nil) +func (c Client) UpdateRegistry(ctx context.Context, registryID string, req UpdateRegistryReq) error { + return c.requestBody(ctx, http.MethodPatch, "/api/v0/registries/"+registryID, req, nil) } // DeleteRegistry deletes a registry resource by its ID. -func (c Client) DeleteRegistry(ctx context.Context, orgID, registryID string) error { - return c.requestBody(ctx, http.MethodDelete, "/api/private/orgs/"+orgID+"/registries/"+registryID, nil, nil) +func (c Client) DeleteRegistry(ctx context.Context, registryID string) error { + return c.requestBody(ctx, http.MethodDelete, "/api/v0/registries/"+registryID, nil, nil) }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: