mirror of https://github.com/coder/coder.git
feat(cli): unhide support bundle cmd (#12745)
* chore(cli): add another test to ensure no secret leakage * feat(cli): unhide support bundle cmd
This commit is contained in:
parent
2332d8197a
commit
01f9a9ab77
|
@ -30,7 +30,6 @@ func (r *RootCmd) support() *serpent.Command {
|
|||
Handler: func(inv *serpent.Invocation) error {
|
||||
return inv.Command.HelpHandler(inv)
|
||||
},
|
||||
Hidden: true, // TODO: un-hide once the must-haves from #12160 are completed.
|
||||
Children: []*serpent.Command{
|
||||
r.supportBundle(),
|
||||
},
|
||||
|
@ -40,7 +39,7 @@ func (r *RootCmd) support() *serpent.Command {
|
|||
|
||||
var supportBundleBlurb = cliui.Bold("This will collect the following information:\n") +
|
||||
` - Coder deployment version
|
||||
- Coder deployment Configuration (sanitized), including enabled experiments
|
||||
- Coder deployment Configuration (sanitized), including enabled experiments
|
||||
- Coder deployment health snapshot
|
||||
- Coder deployment Network troubleshooting information
|
||||
- Workspace configuration, parameters, and build logs
|
||||
|
|
|
@ -39,15 +39,19 @@ func TestSupportBundle(t *testing.T) {
|
|||
t.Run("Workspace", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
client, db := coderdtest.NewWithDatabase(t, nil)
|
||||
var dc codersdk.DeploymentConfig
|
||||
secretValue := uuid.NewString()
|
||||
seedSecretDeploymentOptions(t, &dc, secretValue)
|
||||
client, db := coderdtest.NewWithDatabase(t, &coderdtest.Options{
|
||||
DeploymentValues: dc.Values,
|
||||
})
|
||||
owner := coderdtest.CreateFirstUser(t, client)
|
||||
randSecretValue := uuid.NewString()
|
||||
r := dbfake.WorkspaceBuild(t, db, database.Workspace{
|
||||
OrganizationID: owner.OrganizationID,
|
||||
OwnerID: owner.UserID,
|
||||
}).WithAgent(func(agents []*proto.Agent) []*proto.Agent {
|
||||
// This should not show up in the bundle output
|
||||
agents[0].Env["SECRET_VALUE"] = randSecretValue
|
||||
agents[0].Env["SECRET_VALUE"] = secretValue
|
||||
return agents
|
||||
}).Do()
|
||||
ws, err := client.Workspace(ctx, r.Workspace.ID)
|
||||
|
@ -89,7 +93,7 @@ func TestSupportBundle(t *testing.T) {
|
|||
clitest.SetupConfig(t, client, root)
|
||||
err = inv.Run()
|
||||
require.NoError(t, err)
|
||||
assertBundleContents(t, path, randSecretValue)
|
||||
assertBundleContents(t, path, secretValue)
|
||||
})
|
||||
|
||||
t.Run("NoWorkspace", func(t *testing.T) {
|
||||
|
@ -263,3 +267,15 @@ func assertDoesNotContain(t *testing.T, f *zip.File, vals ...string) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func seedSecretDeploymentOptions(t *testing.T, dc *codersdk.DeploymentConfig, secretValue string) {
|
||||
t.Helper()
|
||||
if dc == nil {
|
||||
dc = &codersdk.DeploymentConfig{}
|
||||
}
|
||||
for _, opt := range dc.Options {
|
||||
if codersdk.IsSecretDeploymentOption(opt) {
|
||||
opt.Value.Set(secretValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ SUBCOMMANDS:
|
|||
stat Show resource usage for the current workspace.
|
||||
state Manually manage Terraform state to fix broken workspaces
|
||||
stop Stop a workspace
|
||||
support Commands for troubleshooting issues with a Coder
|
||||
deployment.
|
||||
templates Manage templates
|
||||
tokens Manage personal access tokens
|
||||
unfavorite Remove a workspace from your favorites
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
coder v0.0.0-devel
|
||||
|
||||
USAGE:
|
||||
coder support
|
||||
|
||||
Commands for troubleshooting issues with a Coder deployment.
|
||||
|
||||
SUBCOMMANDS:
|
||||
bundle Generate a support bundle to troubleshoot issues connecting to a
|
||||
workspace.
|
||||
|
||||
———
|
||||
Run `coder --help` for a list of global options.
|
|
@ -0,0 +1,25 @@
|
|||
coder v0.0.0-devel
|
||||
|
||||
USAGE:
|
||||
coder support bundle [flags] <workspace> [<agent>]
|
||||
|
||||
Generate a support bundle to troubleshoot issues connecting to a workspace.
|
||||
|
||||
This command generates a file containing detailed troubleshooting information
|
||||
about the Coder deployment and workspace connections. You must specify a
|
||||
single workspace (and optionally an agent name).
|
||||
|
||||
OPTIONS:
|
||||
-O, --output-file string, $CODER_SUPPORT_BUNDLE_OUTPUT_FILE
|
||||
File path for writing the generated support bundle. Defaults to
|
||||
coder-support-$(date +%s).zip.
|
||||
|
||||
--url-override string, $CODER_SUPPORT_BUNDLE_URL_OVERRIDE
|
||||
Override the URL to your Coder deployment. This may be useful, for
|
||||
example, if you need to troubleshoot a specific Coder replica.
|
||||
|
||||
-y, --yes bool
|
||||
Bypass prompts.
|
||||
|
||||
———
|
||||
Run `coder --help` for a list of global options.
|
|
@ -57,6 +57,7 @@ Coder — A tool for provisioning self-hosted development environments with Terr
|
|||
| [<code>stop</code>](./cli/stop.md) | Stop a workspace |
|
||||
| [<code>unfavorite</code>](./cli/unfavorite.md) | Remove a workspace from your favorites |
|
||||
| [<code>update</code>](./cli/update.md) | Will update and start a given workspace if it is out of date |
|
||||
| [<code>support</code>](./cli/support.md) | Commands for troubleshooting issues with a Coder deployment. |
|
||||
| [<code>server</code>](./cli/server.md) | Start a Coder server |
|
||||
| [<code>features</code>](./cli/features.md) | List Enterprise features |
|
||||
| [<code>licenses</code>](./cli/licenses.md) | Add, delete, and list licenses |
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<!-- DO NOT EDIT | GENERATED CONTENT -->
|
||||
|
||||
# support
|
||||
|
||||
Commands for troubleshooting issues with a Coder deployment.
|
||||
|
||||
## Usage
|
||||
|
||||
```console
|
||||
coder support
|
||||
```
|
||||
|
||||
## Subcommands
|
||||
|
||||
| Name | Purpose |
|
||||
| ------------------------------------------ | --------------------------------------------------------------------------- |
|
||||
| [<code>bundle</code>](./support_bundle.md) | Generate a support bundle to troubleshoot issues connecting to a workspace. |
|
|
@ -0,0 +1,45 @@
|
|||
<!-- DO NOT EDIT | GENERATED CONTENT -->
|
||||
|
||||
# support bundle
|
||||
|
||||
Generate a support bundle to troubleshoot issues connecting to a workspace.
|
||||
|
||||
## Usage
|
||||
|
||||
```console
|
||||
coder support bundle [flags] <workspace> [<agent>]
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
```console
|
||||
This command generates a file containing detailed troubleshooting information about the Coder deployment and workspace connections. You must specify a single workspace (and optionally an agent name).
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### -y, --yes
|
||||
|
||||
| | |
|
||||
| ---- | ----------------- |
|
||||
| Type | <code>bool</code> |
|
||||
|
||||
Bypass prompts.
|
||||
|
||||
### -O, --output-file
|
||||
|
||||
| | |
|
||||
| ----------- | ---------------------------------------------- |
|
||||
| Type | <code>string</code> |
|
||||
| Environment | <code>$CODER_SUPPORT_BUNDLE_OUTPUT_FILE</code> |
|
||||
|
||||
File path for writing the generated support bundle. Defaults to coder-support-$(date +%s).zip.
|
||||
|
||||
### --url-override
|
||||
|
||||
| | |
|
||||
| ----------- | ----------------------------------------------- |
|
||||
| Type | <code>string</code> |
|
||||
| Environment | <code>$CODER_SUPPORT_BUNDLE_URL_OVERRIDE</code> |
|
||||
|
||||
Override the URL to your Coder deployment. This may be useful, for example, if you need to troubleshoot a specific Coder replica.
|
|
@ -900,6 +900,16 @@
|
|||
"description": "Stop a workspace",
|
||||
"path": "cli/stop.md"
|
||||
},
|
||||
{
|
||||
"title": "support",
|
||||
"description": "Commands for troubleshooting issues with a Coder deployment.",
|
||||
"path": "cli/support.md"
|
||||
},
|
||||
{
|
||||
"title": "support bundle",
|
||||
"description": "Generate a support bundle to troubleshoot issues connecting to a workspace.",
|
||||
"path": "cli/support_bundle.md"
|
||||
},
|
||||
{
|
||||
"title": "templates",
|
||||
"description": "Manage templates",
|
||||
|
|
Loading…
Reference in New Issue