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

Commitd765c36

Browse files
authored
Add "coder envs stop [environment_name]" command (#136)
1 parentb7cd44f commitd765c36

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

‎coder-sdk/env.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ func (c Client) DeleteEnvironment(ctx context.Context, envID string) error {
107107
returnc.requestBody(ctx,http.MethodDelete,"/api/environments/"+envID,nil,nil)
108108
}
109109

110+
// StopEnvironment stops the stops.
111+
func (cClient)StopEnvironment(ctx context.Context,envIDstring)error {
112+
returnc.requestBody(ctx,http.MethodPut,"/api/environments/"+envID+"/stop",nil,nil)
113+
}
114+
110115
// DialWsep dials an environments command execution interface
111116
// See https://github.com/cdr/wsep for details.
112117
func (cClient)DialWsep(ctx context.Context,env*Environment) (*websocket.Conn,error) {

‎docs/coder_envs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ Perform operations on the Coder environments owned by the active user.
1717

1818
*[coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
1919
*[coder envs ls](coder_envs_ls.md) - list all environments owned by the active user
20+
*[coder envs stop](coder_envs_stop.md) - stop a Coder environment by name

‎docs/coder_envs_stop.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
##coder envs stop
2+
3+
stop a Coder environment by name
4+
5+
###Synopsis
6+
7+
Stop a Coder environment by name
8+
9+
```
10+
coder envs stop [environment_name] [flags]
11+
```
12+
13+
###Options
14+
15+
```
16+
-h, --help help for stop
17+
```
18+
19+
###Options inherited from parent commands
20+
21+
```
22+
--user string Specify the user whose resources to target (default "me")
23+
```
24+
25+
###SEE ALSO
26+
27+
*[coder envs](coder_envs.md) - Interact with Coder environments

‎internal/cmd/envs.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,34 @@ func makeEnvsCommand() *cobra.Command {
6161
}
6262
lsCmd.Flags().StringVarP(&outputFmt,"output","o","human","human | json")
6363
cmd.AddCommand(lsCmd)
64+
cmd.AddCommand(stopEnvCommand(&user))
6465

6566
returncmd
6667
}
68+
69+
funcstopEnvCommand(user*string)*cobra.Command {
70+
return&cobra.Command{
71+
Use:"stop [environment_name]",
72+
Short:"stop a Coder environment by name",
73+
Long:"Stop a Coder environment by name",
74+
Args:cobra.ExactArgs(1),
75+
RunE:func(cmd*cobra.Command,args []string)error {
76+
client,err:=newClient()
77+
iferr!=nil {
78+
returnxerrors.Errorf("new client: %w",err)
79+
}
80+
81+
envName:=args[0]
82+
env,err:=findEnv(cmd.Context(),client,envName,*user)
83+
iferr!=nil {
84+
returnxerrors.Errorf("find environment by name: %w",err)
85+
}
86+
87+
iferr=client.StopEnvironment(cmd.Context(),env.ID);err!=nil {
88+
returnxerrors.Errorf("stop environment: %w",err)
89+
}
90+
flog.Success("Successfully stopped environment %q",envName)
91+
returnnil
92+
},
93+
}
94+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp