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

Initial prototype of resources command#137

Merged
cmoog merged 6 commits intomasterfromresource-manager
Oct 18, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletionsci/steps/gendocs.sh
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,15 +7,16 @@ echo "Generating docs..."
cd "$(dirname "$0")"
cd ../../

rm -rf ./docs
mkdir ./docs
go run ./cmd/coder gen-docs ./docs

# remove cobra footer from each file
for filename in ./docs/*.md; do
trimmed=$(head -n -1 "$filename")
echo "$trimmed" >$filename
echo "$trimmed" >$filename
done


if [[ ${CI-} && $(git ls-files --other --modified --exclude-standard) ]]; then
echo "Documentation needs generation:"
git -c color.ui=always status | grep --color=no '\e\[31m'
Expand Down
12 changes: 11 additions & 1 deletioncoder-sdk/env.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ type Environment struct {
UserID string `json:"user_id" tab:"-"`
LastBuiltAt time.Time `json:"last_built_at" tab:"-"`
CPUCores float32 `json:"cpu_cores" tab:"CPUCores"`
MemoryGBint `json:"memory_gb" tab:"MemoryGB"`
MemoryGBfloat32 `json:"memory_gb" tab:"MemoryGB"`
DiskGB int `json:"disk_gb" tab:"DiskGB"`
GPUs int `json:"gpus" tab:"GPUs"`
Updating bool `json:"updating" tab:"Updating"`
Expand DownExpand Up@@ -93,6 +93,16 @@ func (c Client) CreateEnvironment(ctx context.Context, orgID string, req CreateE
return &env, nil
}

// Environments lists environments returned by the given filter.
// TODO: add the filter options, explore performance issues
func (c Client) Environments(ctx context.Context) ([]Environment, error) {
var envs []Environment
if err := c.requestBody(ctx, http.MethodGet, "/api/environments", nil, &envs); err != nil {
return nil, err
}
return envs, nil
}

// EnvironmentsByOrganization gets the list of environments owned by the given user.
func (c Client) EnvironmentsByOrganization(ctx context.Context, userID, orgID string) ([]Environment, error) {
var envs []Environment
Expand Down
43 changes: 35 additions & 8 deletionscoder-sdk/org.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,20 +3,47 @@ package coder
import (
"context"
"net/http"
"time"
)

//Org describes an Organization in Coder
typeOrg struct {
ID string `json:"id"`
Name string `json:"name"`
Members []User `json:"members"`
//Organization describes an Organization in Coder
typeOrganization struct {
ID string`json:"id"`
Name string`json:"name"`
Members []OrganizationUser `json:"members"`
}

// Orgs gets all Organizations
func (c Client) Orgs(ctx context.Context) ([]Org, error) {
var orgs []Org
// OrganizationUser user wraps the basic User type and adds data specific to the user's membership of an organization
type OrganizationUser struct {
User
OrganizationRoles []OrganizationRole `json:"organization_roles"`
RolesUpdatedAt time.Time `json:"roles_updated_at"`
}

// OrganizationRole defines an organization OrganizationRole
type OrganizationRole string

// The OrganizationRole enum values
const (
RoleOrgMember OrganizationRole = "organization-member"
RoleOrgAdmin OrganizationRole = "organization-admin"
RoleOrgManager OrganizationRole = "organization-manager"
)

// Organizations gets all Organizations
func (c Client) Organizations(ctx context.Context) ([]Organization, error) {
var orgs []Organization
if err := c.requestBody(ctx, http.MethodGet, "/api/orgs", nil, &orgs); err != nil {
return nil, err
}
return orgs, nil
}

// OrgMembers get all members of the given organization
func (c Client) OrgMembers(ctx context.Context, orgID string) ([]OrganizationUser, error) {
var members []OrganizationUser
if err := c.requestBody(ctx, http.MethodGet, "/api/orgs/"+orgID+"/members", nil, &members); err != nil {
return nil, err
}
return members, nil
}
3 changes: 2 additions & 1 deletiondocs/coder.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,8 @@ coder provides a CLI for working with an existing Coder Enterprise installation
### Options

```
-h, --help help for coder
-h, --help help for coder
-v, --verbose show verbose output
```

### SEE ALSO
Expand Down
6 changes: 6 additions & 0 deletionsdocs/coder_completion.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -58,6 +58,12 @@ MacOS:
-h, --help help for completion
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
6 changes: 6 additions & 0 deletionsdocs/coder_config-ssh.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,12 @@ coder config-ssh [flags]
--remove remove the auto-generated Coder Enterprise ssh config
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
6 changes: 6 additions & 0 deletionsdocs/coder_envs.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,12 @@ Perform operations on the Coder environments owned by the active user.
--user string Specify the user whose resources to target (default "me")
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
Expand Down
1 change: 1 addition & 0 deletionsdocs/coder_envs_ls.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,7 @@ coder envs ls [flags]

```
--user string Specify the user whose resources to target (default "me")
-v, --verbose show verbose output
```

### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletionsdocs/coder_envs_stop.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ coder envs stop [environment_name] [flags]

```
--user string Specify the user whose resources to target (default "me")
-v, --verbose show verbose output
```

### SEE ALSO
Expand Down
6 changes: 6 additions & 0 deletionsdocs/coder_login.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,12 @@ coder login [Coder Enterprise URL eg. https://my.coder.domain/] [flags]
-h, --help help for login
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
6 changes: 6 additions & 0 deletionsdocs/coder_logout.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,12 @@ coder logout [flags]
-h, --help help for logout
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
6 changes: 6 additions & 0 deletionsdocs/coder_secrets.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,12 @@ Interact with secrets objects owned by the active user.
--user string Specify the user whose resources to target (default "me")
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
Expand Down
1 change: 1 addition & 0 deletionsdocs/coder_secrets_create.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,6 +32,7 @@ coder secrets create aws-credentials --from-file ./credentials.json

```
--user string Specify the user whose resources to target (default "me")
-v, --verbose show verbose output
```

### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletionsdocs/coder_secrets_ls.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ coder secrets ls [flags]

```
--user string Specify the user whose resources to target (default "me")
-v, --verbose show verbose output
```

### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletionsdocs/coder_secrets_rm.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,7 @@ coder secrets rm mysql-password mysql-user

```
--user string Specify the user whose resources to target (default "me")
-v, --verbose show verbose output
```

### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletionsdocs/coder_secrets_view.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,7 @@ coder secrets view mysql-password

```
--user string Specify the user whose resources to target (default "me")
-v, --verbose show verbose output
```

### SEE ALSO
Expand Down
6 changes: 6 additions & 0 deletionsdocs/coder_sh.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,12 @@ coder sh backend-env
-h, --help help for sh
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
6 changes: 6 additions & 0 deletionsdocs/coder_sync.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,12 @@ coder sync [local directory] [<env name>:<remote directory>] [flags]
--init do initial transfer and exit
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
6 changes: 6 additions & 0 deletionsdocs/coder_urls.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,12 @@ Interact with environment DevURLs
-h, --help help for urls
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
Expand Down
6 changes: 6 additions & 0 deletionsdocs/coder_urls_create.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,12 @@ coder urls create [env_name] [port] [--access <level>] [--name <name>] [flags]
--name string DevURL name
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder urls](coder_urls.md) - Interact with environment DevURLs
6 changes: 6 additions & 0 deletionsdocs/coder_urls_ls.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,12 @@ coder urls ls [environment_name] [flags]
-o, --output string human|json (default "human")
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder urls](coder_urls.md) - Interact with environment DevURLs
6 changes: 6 additions & 0 deletionsdocs/coder_urls_rm.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,12 @@ coder urls rm [environment_name] [port] [flags]
-h, --help help for rm
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder urls](coder_urls.md) - Interact with environment DevURLs
6 changes: 6 additions & 0 deletionsdocs/coder_users.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,12 @@ Interact with Coder user accounts
-h, --help help for users
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
Expand Down
6 changes: 6 additions & 0 deletionsdocs/coder_users_ls.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,12 @@ coder users ls -o json | jq .[] | jq -r .email
-o, --output string human | json (default "human")
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder users](coder_users.md) - Interact with Coder user accounts
6 changes: 3 additions & 3 deletionsinternal/cmd/ceapi.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,9 +12,9 @@ import (
// Helpers for working with the Coder Enterprise API.

// lookupUserOrgs gets a list of orgs the user is apart of.
func lookupUserOrgs(user *coder.User, orgs []coder.Org) []coder.Org {
func lookupUserOrgs(user *coder.User, orgs []coder.Organization) []coder.Organization {
// NOTE: We don't know in advance how many orgs the user is in so we can't pre-alloc.
var userOrgs []coder.Org
var userOrgs []coder.Organization

for _, org := range orgs {
for _, member := range org.Members {
Expand All@@ -36,7 +36,7 @@ func getEnvs(ctx context.Context, client *coder.Client, email string) ([]coder.E
return nil, xerrors.Errorf("get user: %w", err)
}

orgs, err := client.Orgs(ctx)
orgs, err := client.Organizations(ctx)
if err != nil {
return nil, xerrors.Errorf("get orgs: %w", err)
}
Expand Down
5 changes: 5 additions & 0 deletionsinternal/cmd/cmd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,9 @@ import (
"github.com/spf13/cobra/doc"
)

// verbose is a global flag for specifying that a command should give verbose output
var verbose bool = false

// Make constructs the "coder" root command
func Make() *cobra.Command {
app := &cobra.Command{
Expand All@@ -24,9 +27,11 @@ func Make() *cobra.Command {
makeEnvsCommand(),
makeSyncCmd(),
makeURLCmd(),
makeResourceCmd(),
completionCmd,
genDocs(app),
)
app.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "show verbose output")
return app
}

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp