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

Remove --user flag from "envs create"#203

Merged
cmoog merged 2 commits intomasterfromuser-flag
Dec 10, 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
3 changes: 1 addition & 2 deletionsdocs/coder_envs.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,8 +9,7 @@ Perform operations on the Coder environments owned by the active user.
### Options

```
-h, --help help for envs
--user string Specify the user whose resources to target (default "me")
-h, --help help for envs
```

### Options inherited from parent commands
Expand Down
3 changes: 1 addition & 2 deletionsdocs/coder_envs_create.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,8 +36,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
### Options inherited from parent commands

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

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletionsdocs/coder_envs_edit.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,13 +32,13 @@ coder envs edit back-end-env --disk 20
--not-container-vm do not deploy the environment as a Container-based VM
-o, --org string name of the organization the environment should be created under.
-t, --tag string image tag of the image you want to base the environment off of. (default "latest")
--user string Specify the user whose resources to target (default "me")
```

### Options inherited from parent commands

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

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletionsdocs/coder_envs_ls.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,13 +15,13 @@ coder envs ls [flags]
```
-h, --help help for ls
-o, --output string human | json (default "human")
--user string Specify the user whose resources to target (default "me")
```

### Options inherited from parent commands

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

### SEE ALSO
Expand Down
10 changes: 5 additions & 5 deletionsdocs/coder_envs_rebuild.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,16 +16,16 @@ coder envs rebuild backend-env --force
### Options

```
--follow follow build log after initiating rebuild
--force force rebuild without showing a confirmation prompt
-h, --help help for rebuild
--follow follow build log after initiating rebuild
--force force rebuild without showing a confirmation prompt
-h, --help help for rebuild
--user string Specify the user whose resources to target (default "me")
```

### Options inherited from parent commands

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

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletionsdocs/coder_envs_rm.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,15 +9,15 @@ coder envs rm [...environment_names] [flags]
### Options

```
-f, --force force remove the specified environments without prompting first
-h, --help help for rm
-f, --force force remove the specified environments without prompting first
-h, --help help for rm
--user string Specify the user whose resources to target (default "me")
```

### Options inherited from parent commands

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

### SEE ALSO
Expand Down
6 changes: 3 additions & 3 deletionsdocs/coder_envs_stop.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,14 +28,14 @@ coder envs --user charlie@coder.com ls -o json \
### Options

```
-h, --help help for stop
-h, --help help for stop
--user string Specify the user whose resources to target (default "me")
```

### Options inherited from parent commands

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

### SEE ALSO
Expand Down
6 changes: 3 additions & 3 deletionsdocs/coder_envs_watch-build.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,14 +15,14 @@ coder envs watch-build front-end-env
### Options

```
-h, --help help for watch-build
-h, --help help for watch-build
--user string Specify the user whose resources to target (default "me")
```

### Options inherited from parent commands

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

### SEE ALSO
Expand Down
64 changes: 38 additions & 26 deletionsinternal/cmd/envs.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,22 +18,20 @@ import (
const defaultImgTag = "latest"

func envsCmd() *cobra.Command {
var user string
cmd := &cobra.Command{
Use: "envs",
Short: "Interact with Coder environments",
Long: "Perform operations on the Coder environments owned by the active user.",
}
cmd.PersistentFlags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target")

cmd.AddCommand(
lsEnvsCommand(&user),
stopEnvsCmd(&user),
rmEnvsCmd(&user),
watchBuildLogCommand(&user),
rebuildEnvCommand(&user),
createEnvCmd(&user),
editEnvCmd(&user),
lsEnvsCommand(),
stopEnvsCmd(),
rmEnvsCmd(),
watchBuildLogCommand(),
rebuildEnvCommand(),
createEnvCmd(),
editEnvCmd(),
)
return cmd
}
Expand All@@ -43,8 +41,11 @@ const (
jsonOutput = "json"
)

func lsEnvsCommand(user *string) *cobra.Command {
var outputFmt string
func lsEnvsCommand() *cobra.Command {
var (
outputFmt string
user string
)

cmd := &cobra.Command{
Use: "ls",
Expand All@@ -56,7 +57,7 @@ func lsEnvsCommand(user *string) *cobra.Command {
if err != nil {
return err
}
envs, err := getEnvs(ctx, client,*user)
envs, err := getEnvs(ctx, client, user)
if err != nil {
return err
}
Expand DownExpand Up@@ -85,13 +86,15 @@ func lsEnvsCommand(user *string) *cobra.Command {
},
}

cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target")
cmd.Flags().StringVarP(&outputFmt, "output", "o", humanOutput, "human | json")

return cmd
}

func stopEnvsCmd(user *string) *cobra.Command {
return &cobra.Command{
func stopEnvsCmd() *cobra.Command {
var user string
cmd := &cobra.Command{
Use: "stop [...environment_names]",
Short: "stop Coder environments by name",
Long: "Stop Coder environments by name",
Expand All@@ -117,7 +120,7 @@ coder envs --user charlie@coder.com ls -o json \
for _, envName := range args {
envName := envName
egroup.Go(func() error {
env, err := findEnv(ctx, client, envName,*user)
env, err := findEnv(ctx, client, envName, user)
if err != nil {
return err
}
Expand All@@ -136,9 +139,11 @@ coder envs --user charlie@coder.com ls -o json \
return egroup.Wait()
},
}
cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target")
return cmd
}

func createEnvCmd(user *string) *cobra.Command {
func createEnvCmd() *cobra.Command {
var (
org string
cpu float32
Expand DownExpand Up@@ -170,7 +175,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
return err
}

multiOrgMember, err := isMultiOrgMember(ctx, client,*user)
multiOrgMember, err := isMultiOrgMember(ctx, client,coder.Me)
if err != nil {
return err
}
Expand All@@ -180,7 +185,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
}

importedImg, err := findImg(ctx, client, findImgConf{
email:*user,
email:coder.Me,
imgName: img,
orgName: org,
})
Expand DownExpand Up@@ -245,7 +250,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
return cmd
}

func editEnvCmd(user *string) *cobra.Command {
func editEnvCmd() *cobra.Command {
var (
org string
img string
Expand All@@ -257,6 +262,7 @@ func editEnvCmd(user *string) *cobra.Command {
follow bool
useCVM bool
notCVM bool
user string
)

cmd := &cobra.Command{
Expand All@@ -276,12 +282,12 @@ coder envs edit back-end-env --disk 20`,

envName := args[0]

env, err := findEnv(ctx, client, envName,*user)
env, err := findEnv(ctx, client, envName, user)
if err != nil {
return err
}

multiOrgMember, err := isMultiOrgMember(ctx, client,*user)
multiOrgMember, err := isMultiOrgMember(ctx, client, user)
if err != nil {
return err
}
Expand DownExpand Up@@ -337,11 +343,16 @@ coder envs edit back-end-env --disk 20`,
cmd.Flags().BoolVar(&follow, "follow", false, "follow buildlog after initiating rebuild")
cmd.Flags().BoolVar(&useCVM, "container-vm", false, "deploy the environment as a Container-based VM")
cmd.Flags().BoolVar(&notCVM, "not-container-vm", false, "do not deploy the environment as a Container-based VM")
cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target")
return cmd
}

func rmEnvsCmd(user *string) *cobra.Command {
var force bool
func rmEnvsCmd() *cobra.Command {
var (
force bool
user string
)

cmd := &cobra.Command{
Use: "rm [...environment_names]",
Short: "remove Coder environments by name",
Expand DownExpand Up@@ -369,7 +380,7 @@ func rmEnvsCmd(user *string) *cobra.Command {
for _, envName := range args {
envName := envName
egroup.Go(func() error {
env, err := findEnv(ctx, client, envName,*user)
env, err := findEnv(ctx, client, envName, user)
if err != nil {
return err
}
Expand All@@ -387,6 +398,7 @@ func rmEnvsCmd(user *string) *cobra.Command {
},
}
cmd.Flags().BoolVarP(&force, "force", "f", false, "force remove the specified environments without prompting first")
cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target")
return cmd
}

Expand All@@ -396,7 +408,7 @@ type updateConf struct {
diskGB int
gpus int
environment *coder.Environment
user*string
user string
image string
imageTag string
orgName string
Expand DownExpand Up@@ -427,7 +439,7 @@ func buildUpdateReq(ctx context.Context, client *coder.Client, conf updateConf)
// If this is not empty it means the user is requesting to change the environment image.
if conf.image != "" {
importedImg, err := findImg(ctx, client, findImgConf{
email:*conf.user,
email: conf.user,
imgName: conf.image,
orgName: conf.orgName,
})
Expand Down
12 changes: 8 additions & 4 deletionsinternal/cmd/rebuild.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,9 +17,10 @@ import (
"golang.org/x/xerrors"
)

func rebuildEnvCommand(user *string) *cobra.Command {
func rebuildEnvCommand() *cobra.Command {
var follow bool
var force bool
var user string
cmd := &cobra.Command{
Use: "rebuild [environment_name]",
Short: "rebuild a Coder environment",
Expand All@@ -32,7 +33,7 @@ coder envs rebuild backend-env --force`,
if err != nil {
return err
}
env, err := findEnv(ctx, client, args[0],*user)
env, err := findEnv(ctx, client, args[0], user)
if err != nil {
return err
}
Expand DownExpand Up@@ -67,6 +68,7 @@ coder envs rebuild backend-env --force`,
},
}

cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target")
cmd.Flags().BoolVar(&follow, "follow", false, "follow build log after initiating rebuild")
cmd.Flags().BoolVar(&force, "force", false, "force rebuild without showing a confirmation prompt")
return cmd
Expand DownExpand Up@@ -136,7 +138,8 @@ func trailBuildLogs(ctx context.Context, client *coder.Client, envID string) err
return nil
}

func watchBuildLogCommand(user *string) *cobra.Command {
func watchBuildLogCommand() *cobra.Command {
var user string
cmd := &cobra.Command{
Use: "watch-build [environment_name]",
Example: "coder envs watch-build front-end-env",
Expand All@@ -148,7 +151,7 @@ func watchBuildLogCommand(user *string) *cobra.Command {
if err != nil {
return err
}
env, err := findEnv(ctx, client, args[0],*user)
env, err := findEnv(ctx, client, args[0], user)
if err != nil {
return err
}
Expand All@@ -159,5 +162,6 @@ func watchBuildLogCommand(user *string) *cobra.Command {
return nil
},
}
cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target")
return cmd
}

[8]ページ先頭

©2009-2025 Movatter.jp