Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01f9a9a

Browse files
authored
feat(cli): unhide support bundle cmd (#12745)
* chore(cli): add another test to ensure no secret leakage * feat(cli): unhide support bundle cmd
1 parent 2332d81 commit 01f9a9a

9 files changed

+134
-6
lines changed

cli/support.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func (r *RootCmd) support() *serpent.Command {
3030
Handler: func(inv *serpent.Invocation) error {
3131
return inv.Command.HelpHandler(inv)
3232
},
33-
Hidden: true, // TODO: un-hide once the must-haves from #12160 are completed.
3433
Children: []*serpent.Command{
3534
r.supportBundle(),
3635
},
@@ -40,7 +39,7 @@ func (r *RootCmd) support() *serpent.Command {
4039

4140
var supportBundleBlurb = cliui.Bold("This will collect the following information:\n") +
4241
` - Coder deployment version
43-
- Coder deployment Configuration (sanitized), including enabled experiments
42+
- Coder deployment Configuration (sanitized), including enabled experiments
4443
- Coder deployment health snapshot
4544
- Coder deployment Network troubleshooting information
4645
- Workspace configuration, parameters, and build logs

cli/support_test.go

+20-4
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ func TestSupportBundle(t *testing.T) {
3939
t.Run("Workspace", func(t *testing.T) {
4040
t.Parallel()
4141
ctx := testutil.Context(t, testutil.WaitShort)
42-
client, db := coderdtest.NewWithDatabase(t, nil)
42+
var dc codersdk.DeploymentConfig
43+
secretValue := uuid.NewString()
44+
seedSecretDeploymentOptions(t, &dc, secretValue)
45+
client, db := coderdtest.NewWithDatabase(t, &coderdtest.Options{
46+
DeploymentValues: dc.Values,
47+
})
4348
owner := coderdtest.CreateFirstUser(t, client)
44-
randSecretValue := uuid.NewString()
4549
r := dbfake.WorkspaceBuild(t, db, database.Workspace{
4650
OrganizationID: owner.OrganizationID,
4751
OwnerID: owner.UserID,
4852
}).WithAgent(func(agents []*proto.Agent) []*proto.Agent {
4953
// This should not show up in the bundle output
50-
agents[0].Env["SECRET_VALUE"] = randSecretValue
54+
agents[0].Env["SECRET_VALUE"] = secretValue
5155
return agents
5256
}).Do()
5357
ws, err := client.Workspace(ctx, r.Workspace.ID)
@@ -89,7 +93,7 @@ func TestSupportBundle(t *testing.T) {
8993
clitest.SetupConfig(t, client, root)
9094
err = inv.Run()
9195
require.NoError(t, err)
92-
assertBundleContents(t, path, randSecretValue)
96+
assertBundleContents(t, path, secretValue)
9397
})
9498

9599
t.Run("NoWorkspace", func(t *testing.T) {
@@ -263,3 +267,15 @@ func assertDoesNotContain(t *testing.T, f *zip.File, vals ...string) {
263267
}
264268
}
265269
}
270+
271+
func seedSecretDeploymentOptions(t *testing.T, dc *codersdk.DeploymentConfig, secretValue string) {
272+
t.Helper()
273+
if dc == nil {
274+
dc = &codersdk.DeploymentConfig{}
275+
}
276+
for _, opt := range dc.Options {
277+
if codersdk.IsSecretDeploymentOption(opt) {
278+
opt.Value.Set(secretValue)
279+
}
280+
}
281+
}

cli/testdata/coder_--help.golden

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ SUBCOMMANDS:
4646
stat Show resource usage for the current workspace.
4747
state Manually manage Terraform state to fix broken workspaces
4848
stop Stop a workspace
49+
support Commands for troubleshooting issues with a Coder
50+
deployment.
4951
templates Manage templates
5052
tokens Manage personal access tokens
5153
unfavorite Remove a workspace from your favorites
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
coder v0.0.0-devel
2+
3+
USAGE:
4+
coder support
5+
6+
Commands for troubleshooting issues with a Coder deployment.
7+
8+
SUBCOMMANDS:
9+
bundle Generate a support bundle to troubleshoot issues connecting to a
10+
workspace.
11+
12+
———
13+
Run `coder --help` for a list of global options.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
coder v0.0.0-devel
2+
3+
USAGE:
4+
coder support bundle [flags] <workspace> [<agent>]
5+
6+
Generate a support bundle to troubleshoot issues connecting to a workspace.
7+
8+
This command generates a file containing detailed troubleshooting information
9+
about the Coder deployment and workspace connections. You must specify a
10+
single workspace (and optionally an agent name).
11+
12+
OPTIONS:
13+
-O, --output-file string, $CODER_SUPPORT_BUNDLE_OUTPUT_FILE
14+
File path for writing the generated support bundle. Defaults to
15+
coder-support-$(date +%s).zip.
16+
17+
--url-override string, $CODER_SUPPORT_BUNDLE_URL_OVERRIDE
18+
Override the URL to your Coder deployment. This may be useful, for
19+
example, if you need to troubleshoot a specific Coder replica.
20+
21+
-y, --yes bool
22+
Bypass prompts.
23+
24+
———
25+
Run `coder --help` for a list of global options.

docs/cli.md

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Coder — A tool for provisioning self-hosted development environments with Terr
5757
| [<code>stop</code>](./cli/stop.md) | Stop a workspace |
5858
| [<code>unfavorite</code>](./cli/unfavorite.md) | Remove a workspace from your favorites |
5959
| [<code>update</code>](./cli/update.md) | Will update and start a given workspace if it is out of date |
60+
| [<code>support</code>](./cli/support.md) | Commands for troubleshooting issues with a Coder deployment. |
6061
| [<code>server</code>](./cli/server.md) | Start a Coder server |
6162
| [<code>features</code>](./cli/features.md) | List Enterprise features |
6263
| [<code>licenses</code>](./cli/licenses.md) | Add, delete, and list licenses |

docs/cli/support.md

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/cli/support_bundle.md

+45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/manifest.json

+10
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,16 @@
900900
"description": "Stop a workspace",
901901
"path": "cli/stop.md"
902902
},
903+
{
904+
"title": "support",
905+
"description": "Commands for troubleshooting issues with a Coder deployment.",
906+
"path": "cli/support.md"
907+
},
908+
{
909+
"title": "support bundle",
910+
"description": "Generate a support bundle to troubleshoot issues connecting to a workspace.",
911+
"path": "cli/support_bundle.md"
912+
},
903913
{
904914
"title": "templates",
905915
"description": "Manage templates",

0 commit comments

Comments
 (0)