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

Commitcbcbe0c

Browse files
committed
fixup! Initial prototype of resources command
1 parent37ade46 commitcbcbe0c

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

‎coder-sdk/org.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,40 @@ import (
66
"time"
77
)
88

9-
//Org describes an Organization in Coder
10-
typeOrgstruct {
9+
//Organization describes an Organization in Coder
10+
typeOrganizationstruct {
1111
IDstring`json:"id"`
1212
Namestring`json:"name"`
1313
Members []OrganizationUser`json:"members"`
1414
}
1515

16+
// OrganizationUser user wraps the basic User type and adds data specific to the user's membership of an organization
1617
typeOrganizationUserstruct {
1718
User
18-
OrganizationRoles []Role`json:"organization_roles"`
19+
OrganizationRoles []OrganizationRole`json:"organization_roles"`
1920
RolesUpdatedAt time.Time`json:"roles_updated_at"`
2021
}
2122

22-
typeRolestring
23+
// OrganizationRole defines an organization OrganizationRole
24+
typeOrganizationRolestring
2325

26+
// The OrganizationRole enum values
2427
const (
25-
RoleOrgMemberRole="organization-member"
26-
RoleOrgAdminRole="organization-admin"
27-
RoleOrgManagerRole="organization-manager"
28+
RoleOrgMemberOrganizationRole="organization-member"
29+
RoleOrgAdminOrganizationRole="organization-admin"
30+
RoleOrgManagerOrganizationRole="organization-manager"
2831
)
2932

30-
//Orgs gets all Organizations
31-
func (cClient)Orgs(ctx context.Context) ([]Org,error) {
32-
varorgs []Org
33+
//Organizations gets all Organizations
34+
func (cClient)Organizations(ctx context.Context) ([]Organization,error) {
35+
varorgs []Organization
3336
iferr:=c.requestBody(ctx,http.MethodGet,"/api/orgs",nil,&orgs);err!=nil {
3437
returnnil,err
3538
}
3639
returnorgs,nil
3740
}
3841

42+
// OrgMembers get all members of the given organization
3943
func (cClient)OrgMembers(ctx context.Context,orgIDstring) ([]OrganizationUser,error) {
4044
varmembers []OrganizationUser
4145
iferr:=c.requestBody(ctx,http.MethodGet,"/api/orgs/"+orgID+"/members",nil,&members);err!=nil {

‎internal/cmd/ceapi.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
// Helpers for working with the Coder Enterprise API.
1313

1414
// lookupUserOrgs gets a list of orgs the user is apart of.
15-
funclookupUserOrgs(user*coder.User,orgs []coder.Org) []coder.Org {
15+
funclookupUserOrgs(user*coder.User,orgs []coder.Organization) []coder.Organization {
1616
// NOTE: We don't know in advance how many orgs the user is in so we can't pre-alloc.
17-
varuserOrgs []coder.Org
17+
varuserOrgs []coder.Organization
1818

1919
for_,org:=rangeorgs {
2020
for_,member:=rangeorg.Members {
@@ -36,7 +36,7 @@ func getEnvs(ctx context.Context, client *coder.Client, email string) ([]coder.E
3636
returnnil,xerrors.Errorf("get user: %w",err)
3737
}
3838

39-
orgs,err:=client.Orgs(ctx)
39+
orgs,err:=client.Organizations(ctx)
4040
iferr!=nil {
4141
returnnil,xerrors.Errorf("get orgs: %w",err)
4242
}

‎internal/cmd/resourcemanager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ var resourceTop = &cobra.Command{
4343
returnerr
4444
}
4545

46-
orgs:=make(map[string]coder.Org)
47-
orglist,err:=client.Orgs(ctx)
46+
orgs:=make(map[string]coder.Organization)
47+
orglist,err:=client.Organizations(ctx)
4848
iferr!=nil {
4949
returnerr
5050
}
@@ -79,7 +79,7 @@ func resourcesFromEnv(env coder.Environment) resources {
7979
}
8080
}
8181

82-
funcfmtEnvResources(env coder.Environment,orgsmap[string]coder.Org)string {
82+
funcfmtEnvResources(env coder.Environment,orgsmap[string]coder.Organization)string {
8383
returnfmt.Sprintf("%s\t%s\t[org: %s]",env.Name,resourcesFromEnv(env),orgs[env.OrganizationID].Name)
8484
}
8585

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp