Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Unhide rebuild and watch-build commands #161

Merged
merged 5 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions docs/coder_envs.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ Perform operations on the Coder environments owned by the active user.

* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
* [coder envs ls](coder_envs_ls.md) - list all environments owned by the active user
* [coder envs rebuild](coder_envs_rebuild.md) - rebuild a Coder environment
* [coder envs stop](coder_envs_stop.md) - stop Coder environments by name
* [coder envs watch-build](coder_envs_watch-build.md) - trail the build log of a Coder environment

34 changes: 34 additions & 0 deletions docs/coder_envs_rebuild.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## coder envs rebuild

rebuild a Coder environment

```
coder envs rebuild [environment_name] [flags]
```

### Examples

```
coder envs rebuild front-end-env --follow
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
```

### Options inherited from parent commands

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

### SEE ALSO

* [coder envs](coder_envs.md) - Interact with Coder environments

31 changes: 31 additions & 0 deletions docs/coder_envs_watch-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## coder envs watch-build

trail the build log of a Coder environment

```
coder envs watch-build [environment_name] [flags]
```

### Examples

```
coder envs watch-build front-end-env
```

### Options

```
-h, --help help for watch-build
```

### Options inherited from parent commands

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

### SEE ALSO

* [coder envs](coder_envs.md) - Interact with Coder environments

4 changes: 2 additions & 2 deletions internal/cmd/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func envsCommand() *cobra.Command {
lsEnvsCommand(&user),
stopEnvsCommand(&user),
rmEnvsCommand(&user),
watchBuildLogCommand(),
rebuildEnvCommand(),
watchBuildLogCommand(&user),
rebuildEnvCommand(&user),
createEnvCommand(&user),
editEnvCommand(&user),
)
Expand Down
19 changes: 10 additions & 9 deletions internal/cmd/rebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"golang.org/x/xerrors"
)

func rebuildEnvCommand() *cobra.Command {
func rebuildEnvCommand(user *string) *cobra.Command {
var follow bool
var force bool
cmd := &cobra.Command{
Expand All @@ -26,14 +26,13 @@ func rebuildEnvCommand() *cobra.Command {
Args: cobra.ExactArgs(1),
Example: `coder envs rebuild front-end-env --follow
coder envs rebuild backend-env --force`,
Hidden: true, // TODO(@cmoog) un-hide
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient()
if err != nil {
return err
}
env, err := findEnv(ctx, client, args[0], coder.Me)
env, err := findEnv(ctx, client, args[0], *user)
if err != nil {
return err
}
Expand All @@ -44,7 +43,10 @@ coder envs rebuild backend-env --force`,
IsConfirm: true,
}).Run()
if err != nil {
return err
return clog.Fatal(
"failed to confirm prompt", clog.BlankLine,
clog.Tipf(`use "--force" to rebuild without a confirmation prompt`),
)
}
}

Expand All @@ -65,7 +67,7 @@ coder envs rebuild backend-env --force`,
},
}

cmd.Flags().BoolVar(&follow, "follow", false, "follow buildlog after initiating rebuild")
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 Down Expand Up @@ -134,20 +136,19 @@ func trailBuildLogs(ctx context.Context, client *coder.Client, envID string) err
return nil
}

func watchBuildLogCommand() *cobra.Command {
func watchBuildLogCommand(user *string) *cobra.Command {
cmd := &cobra.Command{
Use: "watch-build [environment_name]",
Example: "coder watch-build front-end-env",
Example: "coder envs watch-build front-end-env",
Short: "trail the build log of a Coder environment",
Args: cobra.ExactArgs(1),
Hidden: true, // TODO(@cmoog) un-hide
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient()
if err != nil {
return err
}
env, err := findEnv(ctx, client, args[0], coder.Me)
env, err := findEnv(ctx, client, args[0], *user)
if err != nil {
return err
}
Expand Down