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

Commite5d55d0

Browse files
authored
Merge pull request#137 from cdr/resource-manager
Initial prototype of resources top command
2 parents592bea6 +1a1b6e3 commite5d55d0

27 files changed

+406
-15
lines changed

‎ci/steps/gendocs.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ echo "Generating docs..."
77
cd"$(dirname"$0")"
88
cd ../../
99

10+
rm -rf ./docs
11+
mkdir ./docs
1012
go run ./cmd/coder gen-docs ./docs
1113

1214
# remove cobra footer from each file
1315
forfilenamein ./docs/*.md;do
1416
trimmed=$(head -n -1"$filename")
15-
echo"$trimmed">$filename
17+
echo"$trimmed">$filename
1618
done
1719

18-
1920
if [[${CI-}&&$(git ls-files --other --modified --exclude-standard) ]];then
2021
echo"Documentation needs generation:"
2122
git -c color.ui=always status| grep --color=no'\e\[31m'

‎coder-sdk/env.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Environment struct {
2121
UserIDstring`json:"user_id" tab:"-"`
2222
LastBuiltAt time.Time`json:"last_built_at" tab:"-"`
2323
CPUCoresfloat32`json:"cpu_cores" tab:"CPUCores"`
24-
MemoryGBint`json:"memory_gb" tab:"MemoryGB"`
24+
MemoryGBfloat32`json:"memory_gb" tab:"MemoryGB"`
2525
DiskGBint`json:"disk_gb" tab:"DiskGB"`
2626
GPUsint`json:"gpus" tab:"GPUs"`
2727
Updatingbool`json:"updating" tab:"Updating"`
@@ -93,6 +93,16 @@ func (c Client) CreateEnvironment(ctx context.Context, orgID string, req CreateE
9393
return&env,nil
9494
}
9595

96+
// Environments lists environments returned by the given filter.
97+
// TODO: add the filter options, explore performance issues
98+
func (cClient)Environments(ctx context.Context) ([]Environment,error) {
99+
varenvs []Environment
100+
iferr:=c.requestBody(ctx,http.MethodGet,"/api/environments",nil,&envs);err!=nil {
101+
returnnil,err
102+
}
103+
returnenvs,nil
104+
}
105+
96106
// EnvironmentsByOrganization gets the list of environments owned by the given user.
97107
func (cClient)EnvironmentsByOrganization(ctx context.Context,userID,orgIDstring) ([]Environment,error) {
98108
varenvs []Environment

‎coder-sdk/org.go

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,47 @@ package coder
33
import (
44
"context"
55
"net/http"
6+
"time"
67
)
78

8-
//Org describes an Organization in Coder
9-
typeOrgstruct {
10-
IDstring`json:"id"`
11-
Namestring`json:"name"`
12-
Members []User`json:"members"`
9+
//Organization describes an Organization in Coder
10+
typeOrganizationstruct {
11+
IDstring`json:"id"`
12+
Namestring`json:"name"`
13+
Members []OrganizationUser`json:"members"`
1314
}
1415

15-
// Orgs gets all Organizations
16-
func (cClient)Orgs(ctx context.Context) ([]Org,error) {
17-
varorgs []Org
16+
// OrganizationUser user wraps the basic User type and adds data specific to the user's membership of an organization
17+
typeOrganizationUserstruct {
18+
User
19+
OrganizationRoles []OrganizationRole`json:"organization_roles"`
20+
RolesUpdatedAt time.Time`json:"roles_updated_at"`
21+
}
22+
23+
// OrganizationRole defines an organization OrganizationRole
24+
typeOrganizationRolestring
25+
26+
// The OrganizationRole enum values
27+
const (
28+
RoleOrgMemberOrganizationRole="organization-member"
29+
RoleOrgAdminOrganizationRole="organization-admin"
30+
RoleOrgManagerOrganizationRole="organization-manager"
31+
)
32+
33+
// Organizations gets all Organizations
34+
func (cClient)Organizations(ctx context.Context) ([]Organization,error) {
35+
varorgs []Organization
1836
iferr:=c.requestBody(ctx,http.MethodGet,"/api/orgs",nil,&orgs);err!=nil {
1937
returnnil,err
2038
}
2139
returnorgs,nil
2240
}
41+
42+
// OrgMembers get all members of the given organization
43+
func (cClient)OrgMembers(ctx context.Context,orgIDstring) ([]OrganizationUser,error) {
44+
varmembers []OrganizationUser
45+
iferr:=c.requestBody(ctx,http.MethodGet,"/api/orgs/"+orgID+"/members",nil,&members);err!=nil {
46+
returnnil,err
47+
}
48+
returnmembers,nil
49+
}

‎docs/coder.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ coder provides a CLI for working with an existing Coder Enterprise installation
99
###Options
1010

1111
```
12-
-h, --help help for coder
12+
-h, --help help for coder
13+
-v, --verbose show verbose output
1314
```
1415

1516
###SEE ALSO

‎docs/coder_completion.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ MacOS:
5858
-h, --help help for completion
5959
```
6060

61+
###Options inherited from parent commands
62+
63+
```
64+
-v, --verbose show verbose output
65+
```
66+
6167
###SEE ALSO
6268

6369
*[coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation

‎docs/coder_config-ssh.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ coder config-ssh [flags]
1818
--remove remove the auto-generated Coder Enterprise ssh config
1919
```
2020

21+
###Options inherited from parent commands
22+
23+
```
24+
-v, --verbose show verbose output
25+
```
26+
2127
###SEE ALSO
2228

2329
*[coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation

‎docs/coder_envs.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Perform operations on the Coder environments owned by the active user.
1313
--user string Specify the user whose resources to target (default "me")
1414
```
1515

16+
###Options inherited from parent commands
17+
18+
```
19+
-v, --verbose show verbose output
20+
```
21+
1622
###SEE ALSO
1723

1824
*[coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation

‎docs/coder_envs_ls.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ coder envs ls [flags]
2121

2222
```
2323
--user string Specify the user whose resources to target (default "me")
24+
-v, --verbose show verbose output
2425
```
2526

2627
###SEE ALSO

‎docs/coder_envs_stop.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ coder envs stop [environment_name] [flags]
2020

2121
```
2222
--user string Specify the user whose resources to target (default "me")
23+
-v, --verbose show verbose output
2324
```
2425

2526
###SEE ALSO

‎docs/coder_login.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ coder login [Coder Enterprise URL eg. https://my.coder.domain/] [flags]
1616
-h, --help help for login
1717
```
1818

19+
###Options inherited from parent commands
20+
21+
```
22+
-v, --verbose show verbose output
23+
```
24+
1925
###SEE ALSO
2026

2127
*[coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation

‎docs/coder_logout.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ coder logout [flags]
1616
-h, --help help for logout
1717
```
1818

19+
###Options inherited from parent commands
20+
21+
```
22+
-v, --verbose show verbose output
23+
```
24+
1925
###SEE ALSO
2026

2127
*[coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation

‎docs/coder_secrets.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Interact with secrets objects owned by the active user.
1313
--user string Specify the user whose resources to target (default "me")
1414
```
1515

16+
###Options inherited from parent commands
17+
18+
```
19+
-v, --verbose show verbose output
20+
```
21+
1622
###SEE ALSO
1723

1824
*[coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation

‎docs/coder_secrets_create.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ coder secrets create aws-credentials --from-file ./credentials.json
3232

3333
```
3434
--user string Specify the user whose resources to target (default "me")
35+
-v, --verbose show verbose output
3536
```
3637

3738
###SEE ALSO

‎docs/coder_secrets_ls.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ coder secrets ls [flags]
2020

2121
```
2222
--user string Specify the user whose resources to target (default "me")
23+
-v, --verbose show verbose output
2324
```
2425

2526
###SEE ALSO

‎docs/coder_secrets_rm.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ coder secrets rm mysql-password mysql-user
2626

2727
```
2828
--user string Specify the user whose resources to target (default "me")
29+
-v, --verbose show verbose output
2930
```
3031

3132
###SEE ALSO

‎docs/coder_secrets_view.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ coder secrets view mysql-password
2626

2727
```
2828
--user string Specify the user whose resources to target (default "me")
29+
-v, --verbose show verbose output
2930
```
3031

3132
###SEE ALSO

‎docs/coder_sh.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ coder sh backend-env
2222
-h, --help help for sh
2323
```
2424

25+
###Options inherited from parent commands
26+
27+
```
28+
-v, --verbose show verbose output
29+
```
30+
2531
###SEE ALSO
2632

2733
*[coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation

‎docs/coder_sync.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ coder sync [local directory] [<env name>:<remote directory>] [flags]
1717
--init do initial transfer and exit
1818
```
1919

20+
###Options inherited from parent commands
21+
22+
```
23+
-v, --verbose show verbose output
24+
```
25+
2026
###SEE ALSO
2127

2228
*[coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation

‎docs/coder_urls.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ Interact with environment DevURLs
1212
-h, --help help for urls
1313
```
1414

15+
###Options inherited from parent commands
16+
17+
```
18+
-v, --verbose show verbose output
19+
```
20+
1521
###SEE ALSO
1622

1723
*[coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation

‎docs/coder_urls_create.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ coder urls create [env_name] [port] [--access <level>] [--name <name>] [flags]
1818
--name string DevURL name
1919
```
2020

21+
###Options inherited from parent commands
22+
23+
```
24+
-v, --verbose show verbose output
25+
```
26+
2127
###SEE ALSO
2228

2329
*[coder urls](coder_urls.md) - Interact with environment DevURLs

‎docs/coder_urls_ls.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ coder urls ls [environment_name] [flags]
1717
-o, --output string human|json (default "human")
1818
```
1919

20+
###Options inherited from parent commands
21+
22+
```
23+
-v, --verbose show verbose output
24+
```
25+
2026
###SEE ALSO
2127

2228
*[coder urls](coder_urls.md) - Interact with environment DevURLs

‎docs/coder_urls_rm.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ coder urls rm [environment_name] [port] [flags]
1616
-h, --help help for rm
1717
```
1818

19+
###Options inherited from parent commands
20+
21+
```
22+
-v, --verbose show verbose output
23+
```
24+
1925
###SEE ALSO
2026

2127
*[coder urls](coder_urls.md) - Interact with environment DevURLs

‎docs/coder_users.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ Interact with Coder user accounts
1212
-h, --help help for users
1313
```
1414

15+
###Options inherited from parent commands
16+
17+
```
18+
-v, --verbose show verbose output
19+
```
20+
1521
###SEE ALSO
1622

1723
*[coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation

‎docs/coder_users_ls.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ coder users ls -o json | jq .[] | jq -r .email
2424
-o, --output string human | json (default "human")
2525
```
2626

27+
###Options inherited from parent commands
28+
29+
```
30+
-v, --verbose show verbose output
31+
```
32+
2733
###SEE ALSO
2834

2935
*[coder users](coder_users.md) - Interact with Coder user accounts

‎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/cmd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import (
77
"github.com/spf13/cobra/doc"
88
)
99

10+
// verbose is a global flag for specifying that a command should give verbose output
11+
varverbosebool=false
12+
1013
// Make constructs the "coder" root command
1114
funcMake()*cobra.Command {
1215
app:=&cobra.Command{
@@ -24,9 +27,11 @@ func Make() *cobra.Command {
2427
makeEnvsCommand(),
2528
makeSyncCmd(),
2629
makeURLCmd(),
30+
makeResourceCmd(),
2731
completionCmd,
2832
genDocs(app),
2933
)
34+
app.PersistentFlags().BoolVarP(&verbose,"verbose","v",false,"show verbose output")
3035
returnapp
3136
}
3237

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp