mygithub.libinneed.workers.dev/stackitcloud/stackit-cli
Advanced tools
@@ -39,3 +39,3 @@ name: CI | ||
| - name: Archive code coverage results | ||
| uses: actions/upload-artifact@v4 | ||
| uses: actions/upload-artifact@v5 | ||
| with: | ||
@@ -42,0 +42,0 @@ name: ${{ env.CODE_COVERAGE_ARTIFACT_NAME }} |
@@ -93,3 +93,3 @@ # STACKIT CLI release workflow. | ||
| - name: Upload artifacts to workflow | ||
| uses: actions/upload-artifact@v4 | ||
| uses: actions/upload-artifact@v5 | ||
| with: | ||
@@ -114,3 +114,3 @@ name: goreleaser-dist-temp | ||
| - name: Download artifacts from workflow | ||
| uses: actions/download-artifact@v5 | ||
| uses: actions/download-artifact@v6 | ||
| with: | ||
@@ -152,3 +152,3 @@ name: goreleaser-dist-temp | ||
| - name: Download artifacts from workflow | ||
| uses: actions/download-artifact@v5 | ||
| uses: actions/download-artifact@v6 | ||
| with: | ||
@@ -155,0 +155,0 @@ name: goreleaser-dist-temp |
@@ -16,5 +16,5 @@ name: Renovate | ||
| - name: Self-hosted Renovate | ||
| uses: renovatebot/github-action@v43.0.18 | ||
| uses: renovatebot/github-action@v43.0.19 | ||
| with: | ||
| configurationFile: .github/renovate.json | ||
| token: ${{ secrets.RENOVATE_TOKEN }} |
@@ -20,6 +20,6 @@ ## stackit git instance create | ||
| Create a instance with name 'my-new-instance' and flavor | ||
| $ stackit git instance create --name my-new-instance --flavor git-100' | ||
| $ stackit git instance create --name my-new-instance --flavor git-100 | ||
| Create a instance with name 'my-new-instance' and acl | ||
| $ stackit git instance create --name my-new-instance --acl 1.1.1.1/1' | ||
| $ stackit git instance create --name my-new-instance --acl 1.1.1.1/1 | ||
| ``` | ||
@@ -26,0 +26,0 @@ |
+3
-3
@@ -12,3 +12,3 @@ module github.com/stackitcloud/stackit-cli | ||
| github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf | ||
| github.com/jedib0t/go-pretty/v6 v6.6.8 | ||
| github.com/jedib0t/go-pretty/v6 v6.6.9 | ||
| github.com/lmittmann/tint v1.1.2 | ||
@@ -28,3 +28,3 @@ github.com/mattn/go-colorable v0.1.14 | ||
| github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.2.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.17.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.18.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.3.1 | ||
@@ -243,3 +243,2 @@ github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.13.1 | ||
| github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
| github.com/stackitcloud/stackit-sdk-go/services/kms v1.0.0 | ||
| github.com/sagikazarmark/locafero v0.11.0 // indirect | ||
@@ -249,2 +248,3 @@ github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect | ||
| github.com/spf13/cast v1.10.0 // indirect | ||
| github.com/stackitcloud/stackit-sdk-go/services/kms v1.0.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.6.0 | ||
@@ -251,0 +251,0 @@ github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.1 |
@@ -164,2 +164,3 @@ package list | ||
| outputFormat string | ||
| projectLabel string | ||
| flavors []git.Flavor | ||
@@ -196,3 +197,3 @@ } | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.flavors); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.projectLabel, tt.args.flavors); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -199,0 +200,0 @@ } |
@@ -63,15 +63,16 @@ package list | ||
| } | ||
| flavors := *resp.Flavors | ||
| if len(flavors) == 0 { | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| params.Printer.Info("No flavors found for project %q\n", projectLabel) | ||
| return nil | ||
| } else if model.Limit != nil && len(flavors) > int(*model.Limit) { | ||
| flavors := resp.GetFlavors() | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| // Truncate output | ||
| if model.Limit != nil && len(flavors) > int(*model.Limit) { | ||
| flavors = (flavors)[:*model.Limit] | ||
| } | ||
| return outputResult(params.Printer, model.OutputFormat, flavors) | ||
| return outputResult(params.Printer, model.OutputFormat, projectLabel, flavors) | ||
| }, | ||
@@ -114,4 +115,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, flavors []git.Flavor) error { | ||
| func outputResult(p *print.Printer, outputFormat, projectLabel string, flavors []git.Flavor) error { | ||
| return p.OutputResult(outputFormat, flavors, func() error { | ||
| if len(flavors) == 0 { | ||
| p.Outputf("No flavors found for project %q\n", projectLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -118,0 +124,0 @@ table.SetHeader("ID", "DESCRIPTION", "DISPLAY_NAME", "AVAILABLE", "SKU") |
@@ -49,7 +49,7 @@ package create | ||
| `Create a instance with name 'my-new-instance' and flavor`, | ||
| `$ stackit git instance create --name my-new-instance --flavor git-100'`, | ||
| `$ stackit git instance create --name my-new-instance --flavor git-100`, | ||
| ), | ||
| examples.NewExample( | ||
| `Create a instance with name 'my-new-instance' and acl`, | ||
| `$ stackit git instance create --name my-new-instance --acl 1.1.1.1/1'`, | ||
| `$ stackit git instance create --name my-new-instance --acl 1.1.1.1/1`, | ||
| ), | ||
@@ -56,0 +56,0 @@ ), |
@@ -164,2 +164,3 @@ package list | ||
| outputFormat string | ||
| projectLabel string | ||
| instances []git.Instance | ||
@@ -196,3 +197,3 @@ } | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.instances); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.projectLabel, tt.args.instances); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -199,0 +200,0 @@ } |
@@ -64,15 +64,16 @@ package list | ||
| } | ||
| instances := *resp.Instances | ||
| if len(instances) == 0 { | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| params.Printer.Info("No instances found for project %q\n", projectLabel) | ||
| return nil | ||
| } else if model.Limit != nil && len(instances) > int(*model.Limit) { | ||
| instances := resp.GetInstances() | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| // Truncate output | ||
| if model.Limit != nil && len(instances) > int(*model.Limit) { | ||
| instances = (instances)[:*model.Limit] | ||
| } | ||
| return outputResult(params.Printer, model.OutputFormat, instances) | ||
| return outputResult(params.Printer, model.OutputFormat, projectLabel, instances) | ||
| }, | ||
@@ -115,4 +116,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, instances []git.Instance) error { | ||
| func outputResult(p *print.Printer, outputFormat, projectLabel string, instances []git.Instance) error { | ||
| return p.OutputResult(outputFormat, instances, func() error { | ||
| if len(instances) == 0 { | ||
| p.Outputf("No instances found for project %q\n", projectLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -119,0 +125,0 @@ table.SetHeader("ID", "NAME", "URL", "VERSION", "STATE", "CREATED") |
@@ -19,4 +19,2 @@ package list | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -31,5 +29,5 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| limitFlag: "10", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| limitFlag: "10", | ||
| } | ||
@@ -87,3 +85,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -95,3 +93,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -103,3 +101,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -182,4 +180,5 @@ isValid: false, | ||
| type args struct { | ||
| outputFormat string | ||
| credentials []logme.CredentialsListItem | ||
| outputFormat string | ||
| instanceLabel string | ||
| credentials []logme.CredentialsListItem | ||
| } | ||
@@ -215,3 +214,3 @@ tests := []struct { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.credentials); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.instanceLabel, tt.args.credentials); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -218,0 +217,0 @@ } |
@@ -70,11 +70,8 @@ package list | ||
| } | ||
| credentials := *resp.CredentialsList | ||
| if len(credentials) == 0 { | ||
| instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) | ||
| instanceLabel = model.InstanceId | ||
| } | ||
| params.Printer.Info("No credentials found for instance %q\n", instanceLabel) | ||
| return nil | ||
| credentials := resp.GetCredentialsList() | ||
| instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) | ||
| instanceLabel = model.InstanceId | ||
| } | ||
@@ -86,3 +83,3 @@ | ||
| } | ||
| return outputResult(params.Printer, model.OutputFormat, credentials) | ||
| return outputResult(params.Printer, model.OutputFormat, instanceLabel, credentials) | ||
| }, | ||
@@ -131,4 +128,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, credentials []logme.CredentialsListItem) error { | ||
| func outputResult(p *print.Printer, outputFormat, instanceLabel string, credentials []logme.CredentialsListItem) error { | ||
| return p.OutputResult(outputFormat, credentials, func() error { | ||
| if len(credentials) == 0 { | ||
| p.Outputf("No credentials found for instance %q\n", instanceLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -135,0 +137,0 @@ table.SetHeader("ID") |
@@ -19,4 +19,2 @@ package list | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -30,4 +28,4 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| } | ||
@@ -84,3 +82,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -92,3 +90,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -100,3 +98,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -159,2 +157,3 @@ isValid: false, | ||
| outputFormat string | ||
| projectLabel string | ||
| instances []logme.Instance | ||
@@ -191,3 +190,3 @@ } | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.instances); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.projectLabel, tt.args.instances); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -194,0 +193,0 @@ } |
@@ -67,11 +67,8 @@ package list | ||
| } | ||
| instances := *resp.Instances | ||
| if len(instances) == 0 { | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| params.Printer.Info("No instances found for project %q\n", projectLabel) | ||
| return nil | ||
| instances := resp.GetInstances() | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
@@ -84,3 +81,3 @@ | ||
| return outputResult(params.Printer, model.OutputFormat, instances) | ||
| return outputResult(params.Printer, model.OutputFormat, projectLabel, instances) | ||
| }, | ||
@@ -125,4 +122,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, instances []logme.Instance) error { | ||
| func outputResult(p *print.Printer, outputFormat, projectLabel string, instances []logme.Instance) error { | ||
| return p.OutputResult(outputFormat, instances, func() error { | ||
| if len(instances) == 0 { | ||
| p.Outputf("No instances found for project %q\n", projectLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -129,0 +131,0 @@ table.SetHeader("ID", "NAME", "LAST OPERATION TYPE", "LAST OPERATION STATE") |
@@ -19,4 +19,2 @@ package plans | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -30,4 +28,4 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| } | ||
@@ -84,3 +82,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -92,3 +90,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -100,3 +98,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -159,2 +157,3 @@ isValid: false, | ||
| outputFormat string | ||
| projectLabel string | ||
| plans []logme.Offering | ||
@@ -191,3 +190,3 @@ } | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.plans); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.projectLabel, tt.args.plans); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -194,0 +193,0 @@ } |
@@ -67,11 +67,8 @@ package plans | ||
| } | ||
| plans := *resp.Offerings | ||
| if len(plans) == 0 { | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| params.Printer.Info("No plans found for project %q\n", projectLabel) | ||
| return nil | ||
| plans := resp.GetOfferings() | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
@@ -84,3 +81,3 @@ | ||
| return outputResult(params.Printer, model.OutputFormat, plans) | ||
| return outputResult(params.Printer, model.OutputFormat, projectLabel, plans) | ||
| }, | ||
@@ -125,4 +122,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, plans []logme.Offering) error { | ||
| func outputResult(p *print.Printer, outputFormat, projectLabel string, plans []logme.Offering) error { | ||
| return p.OutputResult(outputFormat, plans, func() error { | ||
| if len(plans) == 0 { | ||
| p.Outputf("No plans found for project %q\n", projectLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -129,0 +131,0 @@ table.SetHeader("OFFERING NAME", "VERSION", "ID", "NAME", "DESCRIPTION") |
@@ -19,4 +19,2 @@ package list | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -31,5 +29,5 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| limitFlag: "10", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| limitFlag: "10", | ||
| } | ||
@@ -87,3 +85,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -95,3 +93,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -103,3 +101,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -182,4 +180,5 @@ isValid: false, | ||
| type args struct { | ||
| outputFormat string | ||
| credentials []mariadb.CredentialsListItem | ||
| outputFormat string | ||
| instanceLabel string | ||
| credentials []mariadb.CredentialsListItem | ||
| } | ||
@@ -216,3 +215,3 @@ tests := []struct { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.credentials); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.instanceLabel, tt.args.credentials); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -219,0 +218,0 @@ } |
@@ -69,11 +69,8 @@ package list | ||
| } | ||
| credentials := *resp.CredentialsList | ||
| if len(credentials) == 0 { | ||
| instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) | ||
| instanceLabel = model.InstanceId | ||
| } | ||
| params.Printer.Info("No credentials found for instance %q\n", instanceLabel) | ||
| return nil | ||
| credentials := resp.GetCredentialsList() | ||
| instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) | ||
| instanceLabel = model.InstanceId | ||
| } | ||
@@ -85,3 +82,3 @@ | ||
| } | ||
| return outputResult(params.Printer, model.OutputFormat, credentials) | ||
| return outputResult(params.Printer, model.OutputFormat, instanceLabel, credentials) | ||
| }, | ||
@@ -130,4 +127,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, credentials []mariadb.CredentialsListItem) error { | ||
| func outputResult(p *print.Printer, outputFormat, instanceLabel string, credentials []mariadb.CredentialsListItem) error { | ||
| return p.OutputResult(outputFormat, credentials, func() error { | ||
| if len(credentials) == 0 { | ||
| p.Outputf("No credentials found for instance %q\n", instanceLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -134,0 +136,0 @@ table.SetHeader("ID") |
@@ -19,4 +19,2 @@ package list | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -30,4 +28,4 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| } | ||
@@ -84,3 +82,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -92,3 +90,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -100,3 +98,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -159,2 +157,3 @@ isValid: false, | ||
| outputFormat string | ||
| projectLabel string | ||
| instances []mariadb.Instance | ||
@@ -192,3 +191,3 @@ } | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.instances); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.projectLabel, tt.args.instances); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -195,0 +194,0 @@ } |
@@ -67,11 +67,8 @@ package list | ||
| } | ||
| instances := *resp.Instances | ||
| if len(instances) == 0 { | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| params.Printer.Info("No instances found for project %q\n", projectLabel) | ||
| return nil | ||
| instances := resp.GetInstances() | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
@@ -84,3 +81,3 @@ | ||
| return outputResult(params.Printer, model.OutputFormat, instances) | ||
| return outputResult(params.Printer, model.OutputFormat, projectLabel, instances) | ||
| }, | ||
@@ -125,4 +122,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, instances []mariadb.Instance) error { | ||
| func outputResult(p *print.Printer, outputFormat, projectLabel string, instances []mariadb.Instance) error { | ||
| return p.OutputResult(outputFormat, instances, func() error { | ||
| if len(instances) == 0 { | ||
| p.Outputf("No instances found for project %q\n", projectLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -129,0 +131,0 @@ table.SetHeader("ID", "NAME", "LAST OPERATION TYPE", "LAST OPERATION STATE") |
@@ -19,4 +19,2 @@ package plans | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -30,4 +28,4 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| } | ||
@@ -84,3 +82,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -92,3 +90,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -100,3 +98,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -159,2 +157,3 @@ isValid: false, | ||
| outputFormat string | ||
| projectLabel string | ||
| plans []mariadb.Offering | ||
@@ -192,3 +191,3 @@ } | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.plans); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.projectLabel, tt.args.plans); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -195,0 +194,0 @@ } |
@@ -67,11 +67,8 @@ package plans | ||
| } | ||
| plans := *resp.Offerings | ||
| if len(plans) == 0 { | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| params.Printer.Info("No plans found for project %q\n", projectLabel) | ||
| return nil | ||
| plans := resp.GetOfferings() | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
@@ -84,3 +81,3 @@ | ||
| return outputResult(params.Printer, model.OutputFormat, plans) | ||
| return outputResult(params.Printer, model.OutputFormat, projectLabel, plans) | ||
| }, | ||
@@ -125,4 +122,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, plans []mariadb.Offering) error { | ||
| func outputResult(p *print.Printer, outputFormat, projectLabel string, plans []mariadb.Offering) error { | ||
| return p.OutputResult(outputFormat, plans, func() error { | ||
| if len(plans) == 0 { | ||
| p.Outputf("No plans found for project %q\n", projectLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -129,0 +131,0 @@ table.SetHeader("OFFERING NAME", "VERSION", "ID", "NAME", "DESCRIPTION") |
@@ -18,5 +18,2 @@ package create | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -27,5 +24,8 @@ | ||
| var testProjectId = uuid.NewString() | ||
| var testRegion = "eu01" | ||
| var testBucketName = "my-bucket" | ||
| const ( | ||
| testRegion = "eu01" | ||
| testBucketName = "my-bucket" | ||
| ) | ||
| func fixtureArgValues(mods ...func(argValues []string)) []string { | ||
@@ -43,4 +43,4 @@ argValues := []string{ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| regionFlag: testRegion, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| globalflags.RegionFlag: testRegion, | ||
| } | ||
@@ -113,3 +113,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -122,3 +122,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -131,3 +131,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -134,0 +134,0 @@ isValid: false, |
@@ -16,5 +16,2 @@ package delete | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -25,5 +22,8 @@ | ||
| var testProjectId = uuid.NewString() | ||
| var testRegion = "eu01" | ||
| var testBucketName = "my-bucket" | ||
| const ( | ||
| testRegion = "eu01" | ||
| testBucketName = "my-bucket" | ||
| ) | ||
| func fixtureArgValues(mods ...func(argValues []string)) []string { | ||
@@ -41,4 +41,4 @@ argValues := []string{ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| regionFlag: testRegion, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| globalflags.RegionFlag: testRegion, | ||
| } | ||
@@ -111,3 +111,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -120,3 +120,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -129,3 +129,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -132,0 +132,0 @@ isValid: false, |
@@ -18,5 +18,2 @@ package describe | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -27,5 +24,8 @@ | ||
| var testProjectId = uuid.NewString() | ||
| var testRegion = "eu01" | ||
| var testBucketName = "my-bucket" | ||
| const ( | ||
| testRegion = "eu01" | ||
| testBucketName = "my-bucket" | ||
| ) | ||
| func fixtureArgValues(mods ...func(argValues []string)) []string { | ||
@@ -43,4 +43,4 @@ argValues := []string{ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| regionFlag: testRegion, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| globalflags.RegionFlag: testRegion, | ||
| } | ||
@@ -113,3 +113,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -122,3 +122,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -131,3 +131,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -134,0 +134,0 @@ isValid: false, |
@@ -19,5 +19,2 @@ package list | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -32,5 +29,5 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| regionFlag: testRegion, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| globalflags.RegionFlag: testRegion, | ||
| } | ||
@@ -88,3 +85,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -96,3 +93,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -104,3 +101,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -163,2 +160,3 @@ isValid: false, | ||
| outputFormat string | ||
| projectLabel string | ||
| buckets []objectstorage.Bucket | ||
@@ -188,3 +186,3 @@ } | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.buckets); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.projectLabel, tt.args.buckets); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -191,0 +189,0 @@ } |
@@ -67,12 +67,9 @@ package list | ||
| } | ||
| if resp.Buckets == nil || len(*resp.Buckets) == 0 { | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| params.Printer.Info("No buckets found for project %s\n", projectLabel) | ||
| return nil | ||
| buckets := resp.GetBuckets() | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| buckets := *resp.Buckets | ||
@@ -84,3 +81,3 @@ // Truncate output | ||
| return outputResult(params.Printer, model.OutputFormat, buckets) | ||
| return outputResult(params.Printer, model.OutputFormat, projectLabel, buckets) | ||
| }, | ||
@@ -125,3 +122,3 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, buckets []objectstorage.Bucket) error { | ||
| func outputResult(p *print.Printer, outputFormat, projectLabel string, buckets []objectstorage.Bucket) error { | ||
| if buckets == nil { | ||
@@ -132,2 +129,7 @@ return fmt.Errorf("buckets is empty") | ||
| return p.OutputResult(outputFormat, buckets, func() error { | ||
| if len(buckets) == 0 { | ||
| p.Outputf("No buckets found for project %s\n", projectLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -134,0 +136,0 @@ table.SetHeader("NAME", "REGION", "URL (PATH STYLE)", "URL (VIRTUAL HOSTED STYLE)") |
@@ -19,5 +19,2 @@ package create | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -28,10 +25,13 @@ | ||
| var testProjectId = uuid.NewString() | ||
| var testCredentialsGroupName = "test-name" | ||
| var testRegion = "eu01" | ||
| const ( | ||
| testCredentialsGroupName = "test-name" | ||
| testRegion = "eu01" | ||
| ) | ||
| func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| credentialsGroupNameFlag: testCredentialsGroupName, | ||
| regionFlag: testRegion, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| credentialsGroupNameFlag: testCredentialsGroupName, | ||
| globalflags.RegionFlag: testRegion, | ||
| } | ||
@@ -100,3 +100,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -108,3 +108,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -116,3 +116,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -119,0 +119,0 @@ isValid: false, |
@@ -16,5 +16,2 @@ package delete | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -26,4 +23,5 @@ | ||
| var testCredentialsGroupId = uuid.NewString() | ||
| var testRegion = "eu01" | ||
| const testRegion = "eu01" | ||
| func fixtureArgValues(mods ...func(argValues []string)) []string { | ||
@@ -41,4 +39,4 @@ argValues := []string{ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| regionFlag: testRegion, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| globalflags.RegionFlag: testRegion, | ||
| } | ||
@@ -111,3 +109,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -120,3 +118,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -129,3 +127,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -132,0 +130,0 @@ isValid: false, |
@@ -19,5 +19,2 @@ package list | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -28,9 +25,10 @@ | ||
| var testProjectId = uuid.NewString() | ||
| var testRegion = "eu01" | ||
| const testRegion = "eu01" | ||
| func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| regionFlag: "eu01", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| globalflags.RegionFlag: "eu01", | ||
| } | ||
@@ -88,3 +86,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -96,3 +94,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -104,3 +102,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -107,0 +105,0 @@ isValid: false, |
@@ -66,7 +66,3 @@ package list | ||
| } | ||
| credentialsGroups := *resp.CredentialsGroups | ||
| if len(credentialsGroups) == 0 { | ||
| params.Printer.Info("No credentials groups found for your project") | ||
| return nil | ||
| } | ||
| credentialsGroups := resp.GetCredentialsGroups() | ||
@@ -118,2 +114,7 @@ // Truncate output | ||
| return p.OutputResult(outputFormat, credentialsGroups, func() error { | ||
| if len(credentialsGroups) == 0 { | ||
| p.Outputf("No credentials groups found for your project") | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -120,0 +121,0 @@ table.SetHeader("ID", "NAME", "URN") |
@@ -20,5 +20,2 @@ package create | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -30,11 +27,14 @@ | ||
| var testCredentialsGroupId = uuid.NewString() | ||
| var testExpirationDate = "2024-01-01T00:00:00Z" | ||
| var testRegion = "eu01" | ||
| const ( | ||
| testExpirationDate = "2024-01-01T00:00:00Z" | ||
| testRegion = "eu01" | ||
| ) | ||
| func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| credentialsGroupIdFlag: testCredentialsGroupId, | ||
| expireDateFlag: testExpirationDate, | ||
| regionFlag: testRegion, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| credentialsGroupIdFlag: testCredentialsGroupId, | ||
| expireDateFlag: testExpirationDate, | ||
| globalflags.RegionFlag: testRegion, | ||
| } | ||
@@ -114,3 +114,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -122,3 +122,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -130,3 +130,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -133,0 +133,0 @@ isValid: false, |
@@ -16,5 +16,2 @@ package delete | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -26,5 +23,8 @@ | ||
| var testCredentialsGroupId = uuid.NewString() | ||
| var testCredentialsId = "keyID" | ||
| var testRegion = "eu01" | ||
| const ( | ||
| testCredentialsId = "keyID" | ||
| testRegion = "eu01" | ||
| ) | ||
| func fixtureArgValues(mods ...func(argValues []string)) []string { | ||
@@ -42,5 +42,5 @@ argValues := []string{ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| credentialsGroupIdFlag: testCredentialsGroupId, | ||
| regionFlag: testRegion, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| credentialsGroupIdFlag: testCredentialsGroupId, | ||
| globalflags.RegionFlag: testRegion, | ||
| } | ||
@@ -115,3 +115,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -124,3 +124,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -133,3 +133,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -136,0 +136,0 @@ isValid: false, |
@@ -19,5 +19,2 @@ package list | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -33,6 +30,6 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| credentialsGroupIdFlag: testCredentialsGroupId, | ||
| limitFlag: "10", | ||
| regionFlag: testRegion, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| credentialsGroupIdFlag: testCredentialsGroupId, | ||
| limitFlag: "10", | ||
| globalflags.RegionFlag: testRegion, | ||
| } | ||
@@ -92,3 +89,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -100,3 +97,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -108,3 +105,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -187,4 +184,5 @@ isValid: false, | ||
| type args struct { | ||
| outputFormat string | ||
| credentials []objectstorage.AccessKey | ||
| outputFormat string | ||
| credentialsGroupLabel string | ||
| credentials []objectstorage.AccessKey | ||
| } | ||
@@ -220,3 +218,3 @@ tests := []struct { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.credentials); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.credentialsGroupLabel, tt.args.credentials); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -223,0 +221,0 @@ } |
@@ -69,12 +69,8 @@ package list | ||
| } | ||
| credentials := *resp.AccessKeys | ||
| if len(credentials) == 0 { | ||
| credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId, model.Region) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get credentials group name: %v", err) | ||
| credentialsGroupLabel = model.CredentialsGroupId | ||
| } | ||
| credentials := resp.GetAccessKeys() | ||
| params.Printer.Info("No credentials found for credentials group %q\n", credentialsGroupLabel) | ||
| return nil | ||
| credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId, model.Region) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get credentials group name: %v", err) | ||
| credentialsGroupLabel = model.CredentialsGroupId | ||
| } | ||
@@ -86,3 +82,3 @@ | ||
| } | ||
| return outputResult(params.Printer, model.OutputFormat, credentials) | ||
| return outputResult(params.Printer, model.OutputFormat, credentialsGroupLabel, credentials) | ||
| }, | ||
@@ -132,4 +128,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, credentials []objectstorage.AccessKey) error { | ||
| func outputResult(p *print.Printer, outputFormat, credentialsGroupLabel string, credentials []objectstorage.AccessKey) error { | ||
| return p.OutputResult(outputFormat, credentials, func() error { | ||
| if len(credentials) == 0 { | ||
| p.Outputf("No credentials found for credentials group %q\n", credentialsGroupLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -136,0 +137,0 @@ table.SetHeader("CREDENTIALS ID", "ACCESS KEY ID", "EXPIRES AT") |
@@ -16,5 +16,2 @@ package disable | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -25,8 +22,9 @@ | ||
| var testProjectId = uuid.NewString() | ||
| var testRegion = "eu01" | ||
| const testRegion = "eu01" | ||
| func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| regionFlag: testRegion, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| globalflags.RegionFlag: testRegion, | ||
| } | ||
@@ -83,3 +81,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -91,3 +89,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -99,3 +97,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -102,0 +100,0 @@ isValid: false, |
@@ -16,5 +16,2 @@ package enable | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| var regionFlag = globalflags.RegionFlag | ||
| type testCtxKey struct{} | ||
@@ -25,8 +22,9 @@ | ||
| var testProjectId = uuid.NewString() | ||
| var testRegion = "eu01" | ||
| const testRegion = "eu01" | ||
| func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| regionFlag: testRegion, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| globalflags.RegionFlag: testRegion, | ||
| } | ||
@@ -83,3 +81,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -91,3 +89,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -99,3 +97,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -102,0 +100,0 @@ isValid: false, |
@@ -17,4 +17,2 @@ package create | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -29,4 +27,4 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| } | ||
@@ -93,3 +91,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -101,3 +99,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -109,3 +107,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -112,0 +110,0 @@ isValid: false, |
@@ -16,4 +16,2 @@ package delete | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -39,4 +37,4 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| } | ||
@@ -109,3 +107,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -118,3 +116,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -127,3 +125,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -130,0 +128,0 @@ isValid: false, |
@@ -17,4 +17,2 @@ package describe | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -40,4 +38,4 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| } | ||
@@ -110,3 +108,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -119,3 +117,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -128,3 +126,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -131,0 +129,0 @@ isValid: false, |
@@ -18,4 +18,2 @@ package list | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -30,5 +28,5 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| limitFlag: "10", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| instanceIdFlag: testInstanceId, | ||
| limitFlag: "10", | ||
| } | ||
@@ -86,3 +84,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -94,3 +92,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -102,3 +100,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -181,4 +179,5 @@ isValid: false, | ||
| type args struct { | ||
| outputFormat string | ||
| credentials []rabbitmq.CredentialsListItem | ||
| outputFormat string | ||
| instanceLabel string | ||
| credentials []rabbitmq.CredentialsListItem | ||
| } | ||
@@ -210,3 +209,3 @@ tests := []struct { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.credentials); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.instanceLabel, tt.args.credentials); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -213,0 +212,0 @@ } |
@@ -69,11 +69,8 @@ package list | ||
| } | ||
| credentials := *resp.CredentialsList | ||
| if len(credentials) == 0 { | ||
| instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) | ||
| instanceLabel = model.InstanceId | ||
| } | ||
| params.Printer.Info("No credentials found for instance %q\n", instanceLabel) | ||
| return nil | ||
| credentials := resp.GetCredentialsList() | ||
| instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) | ||
| instanceLabel = model.InstanceId | ||
| } | ||
@@ -85,3 +82,4 @@ | ||
| } | ||
| return outputResult(params.Printer, model.OutputFormat, credentials) | ||
| return outputResult(params.Printer, model.OutputFormat, instanceLabel, credentials) | ||
| }, | ||
@@ -130,4 +128,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, credentials []rabbitmq.CredentialsListItem) error { | ||
| func outputResult(p *print.Printer, outputFormat, instanceLabel string, credentials []rabbitmq.CredentialsListItem) error { | ||
| return p.OutputResult(outputFormat, credentials, func() error { | ||
| if len(credentials) == 0 { | ||
| p.Outputf("No credentials found for instance %q\n", instanceLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -134,0 +137,0 @@ table.SetHeader("ID") |
@@ -20,4 +20,2 @@ package create | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -50,13 +48,13 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| instanceNameFlag: "example-name", | ||
| enableMonitoringFlag: "true", | ||
| graphiteFlag: "example-graphite", | ||
| metricsFrequencyFlag: "100", | ||
| metricsPrefixFlag: "example-prefix", | ||
| monitoringInstanceIdFlag: testMonitoringInstanceId, | ||
| pluginFlag: "example-plugin", | ||
| sgwAclFlag: "198.51.100.14/24", | ||
| syslogFlag: "example-syslog", | ||
| planIdFlag: testPlanId, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| instanceNameFlag: "example-name", | ||
| enableMonitoringFlag: "true", | ||
| graphiteFlag: "example-graphite", | ||
| metricsFrequencyFlag: "100", | ||
| metricsPrefixFlag: "example-prefix", | ||
| monitoringInstanceIdFlag: testMonitoringInstanceId, | ||
| pluginFlag: "example-plugin", | ||
| sgwAclFlag: "198.51.100.14/24", | ||
| syslogFlag: "example-syslog", | ||
| planIdFlag: testPlanId, | ||
| } | ||
@@ -153,5 +151,5 @@ for _, mod := range mods { | ||
| flagValues: map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| instanceNameFlag: "example-name", | ||
| planIdFlag: testPlanId, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| instanceNameFlag: "example-name", | ||
| planIdFlag: testPlanId, | ||
| }, | ||
@@ -171,9 +169,9 @@ isValid: true, | ||
| flagValues: map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| planIdFlag: testPlanId, | ||
| instanceNameFlag: "", | ||
| enableMonitoringFlag: "false", | ||
| graphiteFlag: "", | ||
| metricsFrequencyFlag: "0", | ||
| metricsPrefixFlag: "", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| planIdFlag: testPlanId, | ||
| instanceNameFlag: "", | ||
| enableMonitoringFlag: "false", | ||
| graphiteFlag: "", | ||
| metricsFrequencyFlag: "0", | ||
| metricsPrefixFlag: "", | ||
| }, | ||
@@ -197,3 +195,3 @@ isValid: true, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -205,3 +203,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -213,3 +211,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -216,0 +214,0 @@ isValid: false, |
@@ -16,4 +16,2 @@ package delete | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -38,3 +36,3 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| } | ||
@@ -106,3 +104,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -115,3 +113,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -124,3 +122,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -127,0 +125,0 @@ isValid: false, |
@@ -17,4 +17,2 @@ package describe | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -39,3 +37,3 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| } | ||
@@ -107,3 +105,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -116,3 +114,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -125,3 +123,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -128,0 +126,0 @@ isValid: false, |
@@ -18,4 +18,2 @@ package list | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -29,4 +27,4 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| } | ||
@@ -83,3 +81,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -91,3 +89,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -99,3 +97,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -158,2 +156,3 @@ isValid: false, | ||
| outputFormat string | ||
| projectLabel string | ||
| instances []rabbitmq.Instance | ||
@@ -186,3 +185,3 @@ } | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.instances); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.projectLabel, tt.args.instances); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -189,0 +188,0 @@ } |
@@ -67,11 +67,8 @@ package list | ||
| } | ||
| instances := *resp.Instances | ||
| if len(instances) == 0 { | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| params.Printer.Info("No instances found for project %q\n", projectLabel) | ||
| return nil | ||
| instances := resp.GetInstances() | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
@@ -84,3 +81,3 @@ | ||
| return outputResult(params.Printer, model.OutputFormat, instances) | ||
| return outputResult(params.Printer, model.OutputFormat, projectLabel, instances) | ||
| }, | ||
@@ -125,4 +122,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, instances []rabbitmq.Instance) error { | ||
| func outputResult(p *print.Printer, outputFormat, projectLabel string, instances []rabbitmq.Instance) error { | ||
| return p.OutputResult(outputFormat, instances, func() error { | ||
| if len(instances) == 0 { | ||
| p.Outputf("No instances found for project %q\n", projectLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -129,0 +131,0 @@ table.SetHeader("ID", "NAME", "LAST OPERATION TYPE", "LAST OPERATION STATE") |
@@ -19,4 +19,2 @@ package update | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -62,12 +60,12 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| enableMonitoringFlag: "true", | ||
| graphiteFlag: "example-graphite", | ||
| metricsFrequencyFlag: "100", | ||
| metricsPrefixFlag: "example-prefix", | ||
| monitoringInstanceIdFlag: testMonitoringInstanceId, | ||
| pluginFlag: "example-plugin", | ||
| sgwAclFlag: "198.51.100.14/24", | ||
| syslogFlag: "example-syslog", | ||
| planIdFlag: testPlanId, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| enableMonitoringFlag: "true", | ||
| graphiteFlag: "example-graphite", | ||
| metricsFrequencyFlag: "100", | ||
| metricsPrefixFlag: "example-prefix", | ||
| monitoringInstanceIdFlag: testMonitoringInstanceId, | ||
| pluginFlag: "example-plugin", | ||
| sgwAclFlag: "198.51.100.14/24", | ||
| syslogFlag: "example-syslog", | ||
| planIdFlag: testPlanId, | ||
| } | ||
@@ -164,3 +162,3 @@ for _, mod := range mods { | ||
| flagValues: map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| }, | ||
@@ -180,8 +178,8 @@ isValid: false, | ||
| flagValues: map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| planIdFlag: testPlanId, | ||
| enableMonitoringFlag: "false", | ||
| graphiteFlag: "", | ||
| metricsFrequencyFlag: "0", | ||
| metricsPrefixFlag: "", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| planIdFlag: testPlanId, | ||
| enableMonitoringFlag: "false", | ||
| graphiteFlag: "", | ||
| metricsFrequencyFlag: "0", | ||
| metricsPrefixFlag: "", | ||
| }, | ||
@@ -206,3 +204,3 @@ isValid: true, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -215,3 +213,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -224,3 +222,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -227,0 +225,0 @@ isValid: false, |
@@ -18,4 +18,2 @@ package plans | ||
| var projectIdFlag = globalflags.ProjectIdFlag | ||
| type testCtxKey struct{} | ||
@@ -29,4 +27,4 @@ | ||
| flagValues := map[string]string{ | ||
| projectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| globalflags.ProjectIdFlag: testProjectId, | ||
| limitFlag: "10", | ||
| } | ||
@@ -83,3 +81,3 @@ for _, mod := range mods { | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, projectIdFlag) | ||
| delete(flagValues, globalflags.ProjectIdFlag) | ||
| }), | ||
@@ -91,3 +89,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "" | ||
| flagValues[globalflags.ProjectIdFlag] = "" | ||
| }), | ||
@@ -99,3 +97,3 @@ isValid: false, | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| flagValues[projectIdFlag] = "invalid-uuid" | ||
| flagValues[globalflags.ProjectIdFlag] = "invalid-uuid" | ||
| }), | ||
@@ -158,2 +156,3 @@ isValid: false, | ||
| outputFormat string | ||
| projectLabel string | ||
| plans []rabbitmq.Offering | ||
@@ -186,3 +185,3 @@ } | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.plans); (err != nil) != tt.wantErr { | ||
| if err := outputResult(p, tt.args.outputFormat, tt.args.projectLabel, tt.args.plans); (err != nil) != tt.wantErr { | ||
| t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) | ||
@@ -189,0 +188,0 @@ } |
@@ -68,11 +68,8 @@ package plans | ||
| } | ||
| plans := *resp.Offerings | ||
| if len(plans) == 0 { | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
| params.Printer.Info("No plans found for project %q\n", projectLabel) | ||
| return nil | ||
| plans := resp.GetOfferings() | ||
| projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) | ||
| projectLabel = model.ProjectId | ||
| } | ||
@@ -85,3 +82,3 @@ | ||
| return outputResult(params.Printer, model.OutputFormat, plans) | ||
| return outputResult(params.Printer, model.OutputFormat, projectLabel, plans) | ||
| }, | ||
@@ -126,4 +123,9 @@ } | ||
| func outputResult(p *print.Printer, outputFormat string, plans []rabbitmq.Offering) error { | ||
| func outputResult(p *print.Printer, outputFormat, projectLabel string, plans []rabbitmq.Offering) error { | ||
| return p.OutputResult(outputFormat, plans, func() error { | ||
| if len(plans) == 0 { | ||
| p.Outputf("No plans found for project %q\n", projectLabel) | ||
| return nil | ||
| } | ||
| table := tables.NewTable() | ||
@@ -130,0 +132,0 @@ table.SetHeader("OFFERING NAME", "VERSION", "ID", "NAME", "DESCRIPTION") |
Sorry, the diff of this file is too big to display