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

Commit37ade46

Browse files
committed
fixup! Initial prototype of resources command
1 parent166ed14 commit37ade46

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

‎coder-sdk/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (c Client) CreateEnvironment(ctx context.Context, orgID string, req CreateE
9595

9696
// ListEnvironments lists environments returned by the given filter.
9797
// TODO: add the filter options
98-
func (cClient)ListEnvironments(ctx context.Context) ([]Environment,error) {
98+
func (cClient)ListEnvironments(ctx context.Context) ([]Environment,error) {
9999
varenvs []Environment
100100
iferr:=c.requestBody(ctx,http.MethodGet,"/api/environments",nil,&envs);err!=nil {
101101
returnnil,err

‎coder-sdk/org.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88

99
// Org describes an Organization in Coder
1010
typeOrgstruct {
11-
IDstring`json:"id"`
12-
Namestring`json:"name"`
11+
IDstring`json:"id"`
12+
Namestring`json:"name"`
1313
Members []OrganizationUser`json:"members"`
1414
}
1515

@@ -22,8 +22,8 @@ type OrganizationUser struct {
2222
typeRolestring
2323

2424
const (
25-
RoleOrgMemberRole="organization-member"
26-
RoleOrgAdminRole="organization-admin"
25+
RoleOrgMemberRole="organization-member"
26+
RoleOrgAdminRole="organization-admin"
2727
RoleOrgManagerRole="organization-manager"
2828
)
2929

‎internal/cmd/resourcemanager.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
funcmakeResourceCmd()*cobra.Command {
1313
cmd:=&cobra.Command{
14-
Use:"resources",
14+
Use:"resources",
1515
Short:"manager Coder resources with platform-level context (users, organizations, environments)",
1616
}
1717
cmd.AddCommand(resourceTop)
@@ -54,8 +54,8 @@ var resourceTop = &cobra.Command{
5454

5555
tabwriter:=tabwriter.NewWriter(os.Stdout,0,0,4,' ',0)
5656
for_,u:=rangeusers {
57-
_,_=fmt.Fprintf(tabwriter,"%s\t(%s)\t%s",u.Name,u.Email,aggregateEnvResources(userEnvs[u.ID]))
58-
iflen(userEnvs[u.ID])>0 {
57+
_,_=fmt.Fprintf(tabwriter,"%s\t(%s)\t%s",u.Name,u.Email,aggregateEnvResources(userEnvs[u.ID]))
58+
iflen(userEnvs[u.ID])>0 {
5959
_,_=fmt.Fprintf(tabwriter,"\f")
6060
}
6161
for_,env:=rangeuserEnvs[u.ID] {
@@ -71,19 +71,19 @@ var resourceTop = &cobra.Command{
7171
}
7272

7373
funcresourcesFromEnv(env coder.Environment)resources {
74-
returnresources{
75-
cpuAllocation:env.CPUCores,
76-
cpuUtilization:env.LatestStat.CPUUsage,
77-
memAllocation:env.MemoryGB,
78-
memUtilization:env.LatestStat.MemoryUsage,
79-
}
74+
returnresources{
75+
cpuAllocation:env.CPUCores,
76+
cpuUtilization:env.LatestStat.CPUUsage,
77+
memAllocation:env.MemoryGB,
78+
memUtilization:env.LatestStat.MemoryUsage,
79+
}
8080
}
8181

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

86-
funcaggregateEnvResources(envs []coder.Environment)(resources) {
86+
funcaggregateEnvResources(envs []coder.Environment)resources {
8787
varaggregateresources
8888
for_,e:=rangeenvs {
8989
aggregate.cpuAllocation+=e.CPUCores

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp