feat(cli/support): confirm before creating bundle (#12684)

Forces user to confirm before creating a support bundle.
Also adds contextual information to the bundle under cli_logs.txt.
This commit is contained in:
Cian Johnston
2024-03-21 17:06:28 +00:00
committed by GitHub
parent 8ea5fb7115
commit f2a9e515df
3 changed files with 107 additions and 18 deletions
+7 -4
View File
@@ -76,7 +76,7 @@ func TestSupportBundle(t *testing.T) {
d := t.TempDir()
path := filepath.Join(d, "bundle.zip")
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name, "--output", path)
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name, "--output-file", path, "--yes")
//nolint: gocritic // requires owner privilege
clitest.SetupConfig(t, client, root)
err = inv.Run()
@@ -88,7 +88,7 @@ func TestSupportBundle(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)
inv, root := clitest.New(t, "support", "bundle")
inv, root := clitest.New(t, "support", "bundle", "--yes")
//nolint: gocritic // requires owner privilege
clitest.SetupConfig(t, client, root)
err := inv.Run()
@@ -103,7 +103,7 @@ func TestSupportBundle(t *testing.T) {
OrganizationID: admin.OrganizationID,
OwnerID: admin.UserID,
}).Do() // without agent!
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name)
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name, "--yes")
//nolint: gocritic // requires owner privilege
clitest.SetupConfig(t, client, root)
err := inv.Run()
@@ -119,7 +119,7 @@ func TestSupportBundle(t *testing.T) {
OrganizationID: user.OrganizationID,
OwnerID: member.ID,
}).WithAgent().Do()
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name)
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name, "--yes")
clitest.SetupConfig(t, memberClient, root)
err := inv.Run()
require.ErrorContains(t, err, "failed authorization check")
@@ -219,6 +219,9 @@ func assertBundleContents(t *testing.T, path string) {
case "logs.txt":
bs := readBytesFromZip(t, f)
require.NotEmpty(t, bs, "logs should not be empty")
case "cli_logs.txt":
bs := readBytesFromZip(t, f)
require.NotEmpty(t, bs, "CLI logs should not be empty")
default:
require.Failf(t, "unexpected file in bundle", f.Name)
}