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

Commita1a318f

Browse files
committed
fixup! Export entclient to coder-sdk
1 parent3261fe3 commita1a318f

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

‎coder-sdk/env.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ type Environment struct {
3434
AutoOffThreshold xjson.Duration`json:"auto_off_threshold" tab:"-"`
3535
}
3636

37-
//EnvironmentsInOrganization gets the list of environments owned by theauthenticated user
38-
func (cClient)EnvironmentsInOrganization(ctx context.Context,user*User,org*Org) ([]Environment,error) {
37+
//EnvironmentsByOrganization gets the list of environments owned by thegiven user.
38+
func (cClient)EnvironmentsByOrganization(ctx context.Context,userID,orgIDstring) ([]Environment,error) {
3939
varenvs []Environment
4040
err:=c.requestBody(
4141
ctx,
42-
http.MethodGet,"/api/orgs/"+org.ID+"/members/"+user.ID+"/environments",
42+
http.MethodGet,"/api/orgs/"+orgID+"/members/"+userID+"/environments",
4343
nil,
4444
&envs,
4545
)

‎coder-sdk/secrets.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,33 @@ type Secret struct {
1717
}
1818

1919
// Secrets gets all secrets for the given user
20-
func (c*Client)Secrets(ctx context.Context,user*User) ([]Secret,error) {
20+
func (c*Client)Secrets(ctx context.Context,userIDstring) ([]Secret,error) {
2121
varsecrets []Secret
22-
err:=c.requestBody(ctx,http.MethodGet,"/api/users/"+user.ID+"/secrets",nil,&secrets)
22+
err:=c.requestBody(ctx,http.MethodGet,"/api/users/"+userID+"/secrets",nil,&secrets)
2323
returnsecrets,err
2424
}
2525

2626
// SecretWithValueByName gets the Coder secret with its value by its name.
27-
func (c*Client)SecretWithValueByName(ctx context.Context,namestring,user*User) (*Secret,error) {
28-
s,err:=c.SecretByName(ctx,name,user)
27+
func (c*Client)SecretWithValueByName(ctx context.Context,name,userIDstring) (*Secret,error) {
28+
s,err:=c.SecretByName(ctx,name,userID)
2929
iferr!=nil {
3030
returnnil,err
3131
}
3232
varsecretSecret
33-
err=c.requestBody(ctx,http.MethodGet,"/api/users/"+user.ID+"/secrets/"+s.ID,nil,&secret)
33+
err=c.requestBody(ctx,http.MethodGet,"/api/users/"+userID+"/secrets/"+s.ID,nil,&secret)
3434
return&secret,err
3535
}
3636

3737
// SecretWithValueByID gets the Coder secret with its value by the secret_id.
38-
func (c*Client)SecretWithValueByID(ctx context.Context,idstring,user*User) (*Secret,error) {
38+
func (c*Client)SecretWithValueByID(ctx context.Context,id,userIDstring) (*Secret,error) {
3939
varsecretSecret
40-
err:=c.requestBody(ctx,http.MethodGet,"/api/users/"+user.ID+"/secrets/"+id,nil,&secret)
40+
err:=c.requestBody(ctx,http.MethodGet,"/api/users/"+userID+"/secrets/"+id,nil,&secret)
4141
return&secret,err
4242
}
4343

4444
// SecretByName gets a secret object by name
45-
func (c*Client)SecretByName(ctx context.Context,namestring,user*User) (*Secret,error) {
46-
secrets,err:=c.Secrets(ctx,user)
45+
func (c*Client)SecretByName(ctx context.Context,name,userIDstring) (*Secret,error) {
46+
secrets,err:=c.Secrets(ctx,userID)
4747
iferr!=nil {
4848
returnnil,err
4949
}
@@ -69,11 +69,11 @@ func (c *Client) InsertSecret(ctx context.Context, user *User, req InsertSecretR
6969
}
7070

7171
// DeleteSecretByName deletes the authenticated users secret with the given name
72-
func (c*Client)DeleteSecretByName(ctx context.Context,namestring,user*User)error {
73-
secret,err:=c.SecretByName(ctx,name,user)
72+
func (c*Client)DeleteSecretByName(ctx context.Context,name,userIDstring)error {
73+
secret,err:=c.SecretByName(ctx,name,userID)
7474
iferr!=nil {
7575
returnerr
7676
}
77-
_,err=c.request(ctx,http.MethodDelete,"/api/users/"+user.ID+"/secrets/"+secret.ID,nil)
77+
_,err=c.request(ctx,http.MethodDelete,"/api/users/"+userID+"/secrets/"+secret.ID,nil)
7878
returnerr
7979
}

‎internal/cmd/ceapi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func getEnvs(ctx context.Context, client *coder.Client, email string) ([]coder.E
4444
varallEnvs []coder.Environment
4545

4646
for_,org:=rangeorgs {
47-
envs,err:=client.EnvironmentsInOrganization(ctx,user,&org)
47+
envs,err:=client.EnvironmentsByOrganization(ctx,user.ID,org.ID)
4848
iferr!=nil {
4949
returnnil,xerrors.Errorf("get envs for %v: %+v",org.Name,err)
5050
}

‎internal/cmd/secrets.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func listSecrets(userEmail *string) func(cmd *cobra.Command, _ []string) error {
141141
returnxerrors.Errorf("get user %q by email: %w",*userEmail,err)
142142
}
143143

144-
secrets,err:=client.Secrets(cmd.Context(),user)
144+
secrets,err:=client.Secrets(cmd.Context(),user.ID)
145145
iferr!=nil {
146146
returnxerrors.Errorf("get secrets: %w",err)
147147
}
@@ -174,7 +174,7 @@ func makeViewSecret(userEmail *string) func(cmd *cobra.Command, args []string) e
174174
returnxerrors.Errorf("get user %q by email: %w",*userEmail,err)
175175
}
176176

177-
secret,err:=client.SecretWithValueByName(cmd.Context(),name,user)
177+
secret,err:=client.SecretWithValueByName(cmd.Context(),name,user.ID)
178178
iferr!=nil {
179179
returnxerrors.Errorf("get secret by name: %w",err)
180180
}
@@ -199,7 +199,7 @@ func makeRemoveSecrets(userEmail *string) func(c *cobra.Command, args []string)
199199

200200
errorSeen:=false
201201
for_,n:=rangeargs {
202-
err:=client.DeleteSecretByName(cmd.Context(),n,user)
202+
err:=client.DeleteSecretByName(cmd.Context(),n,user.ID)
203203
iferr!=nil {
204204
flog.Error("failed to delete secret %q: %v",n,err)
205205
errorSeen=true

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp