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

Commitfca4520

Browse files
committed
Add create registry to sdk
1 parent9b94c77 commitfca4520

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

‎coder-sdk/registries.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ func (c Client) Registries(ctx context.Context, orgID string) ([]Registry, error
2626
}
2727

2828
// RegistryByID fetches a registry resource by its ID.
29-
func (cClient)RegistryByID(ctx context.Context,orgID,registryIDstring) (*Registry,error) {
29+
func (cClient)RegistryByID(ctx context.Context,registryIDstring) (*Registry,error) {
3030
varrRegistry
31-
iferr:=c.requestBody(ctx,http.MethodGet,"/api/private/orgs/"+orgID+"/registries/"+registryID,nil,&r);err!=nil {
31+
iferr:=c.requestBody(ctx,http.MethodGet,"/api/private/registries/"+registryID,nil,&r);err!=nil {
3232
returnnil,err
3333
}
3434
return&r,nil
@@ -43,11 +43,28 @@ type UpdateRegistryReq struct {
4343
}
4444

4545
// UpdateRegistry applies a partial update to a registry resource.
46-
func (cClient)UpdateRegistry(ctx context.Context,orgID,registryIDstring,reqUpdateRegistryReq)error {
47-
returnc.requestBody(ctx,http.MethodPatch,"/api/private/orgs/"+orgID+"/registries/"+registryID,req,nil)
46+
func (cClient)UpdateRegistry(ctx context.Context,registryIDstring,reqUpdateRegistryReq)error {
47+
returnc.requestBody(ctx,http.MethodPatch,"/api/private/registries/"+registryID,req,nil)
4848
}
4949

5050
// DeleteRegistry deletes a registry resource by its ID.
51-
func (cClient)DeleteRegistry(ctx context.Context,orgID,registryIDstring)error {
52-
returnc.requestBody(ctx,http.MethodDelete,"/api/private/orgs/"+orgID+"/registries/"+registryID,nil,nil)
51+
func (cClient)DeleteRegistry(ctx context.Context,registryIDstring)error {
52+
returnc.requestBody(ctx,http.MethodDelete,"/api/private/registries/"+registryID,nil,nil)
53+
}
54+
55+
// CreateRegistryReq defines the request parameters for creating a new registry resource.
56+
typeCreateRegistryReqstruct {
57+
FriendlyNamestring`json:"friendly_name"`
58+
Registrystring`json:"registry"`
59+
Usernamestring`json:"username"`
60+
Passwordstring`json:"password"`
61+
}
62+
63+
// CreateRegistry creates a new registry resource in an organization.
64+
func (cClient)CreateRegistry(ctx context.Context,orgIDstring,reqCreateRegistryReq) (*Registry,error) {
65+
varrRegistry
66+
iferr:=c.requestBody(ctx,http.MethodPost,"/api/private/orgs/"+orgID+"/registries",req,&r);err!=nil {
67+
returnnil,err
68+
}
69+
return&r,nil
5370
}

‎internal/cmd/tokens.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func regenTokenCmd() *cobra.Command {
106106
}
107107
token,err:=client.RegenerateAPIToken(ctx,coder.Me,args[0])
108108
iferr!=nil {
109-
returnnil
109+
returnerr
110110
}
111111
fmt.Println(token)
112112
returnnil

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp