🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

mygithub.libinneed.workers.dev/stackitcloud/stackit-cli

Package Overview
Dependencies
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mygithub.libinneed.workers.dev/stackitcloud/stackit-cli - go Package Compare versions

Comparing version
v0.23.1
to
v0.24.0
.github/CODEOWNERS

Sorry, the diff of this file is not supported yet

+42
## stackit beta affinity-group create
Creates an affinity groups
### Synopsis
Creates an affinity groups.
```
stackit beta affinity-group create [flags]
```
### Examples
```
Create an affinity group with name "AFFINITY_GROUP_NAME" and policy "soft-affinity"
$ stackit beta affinity-group create --name AFFINITY_GROUP_NAME --policy soft-affinity
```
### Options
```
-h, --help Help for "stackit beta affinity-group create"
--name string The name of the affinity group.
--policy string The policy for the affinity group. Valid values for the policy are: "hard-affinity", "hard-anti-affinity", "soft-affinity", "soft-anti-affinity"
```
### Options inherited from parent commands
```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```
### SEE ALSO
* [stackit beta affinity-group](./stackit_beta_affinity-group.md) - Manage server affinity groups
## stackit beta affinity-group delete
Deletes an affinity group
### Synopsis
Deletes an affinity group.
```
stackit beta affinity-group delete AFFINITY_GROUP [flags]
```
### Examples
```
Delete an affinity group with ID "xxx"
$ stackit beta affinity-group delete xxx
```
### Options
```
-h, --help Help for "stackit beta affinity-group delete"
```
### Options inherited from parent commands
```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```
### SEE ALSO
* [stackit beta affinity-group](./stackit_beta_affinity-group.md) - Manage server affinity groups
## stackit beta affinity-group describe
Show details of an affinity group
### Synopsis
Show details of an affinity group.
```
stackit beta affinity-group describe AFFINITY_GROUP_ID [flags]
```
### Examples
```
Get details about an affinity group with the ID "xxx"
$ stackit beta affinity-group describe xxx
```
### Options
```
-h, --help Help for "stackit beta affinity-group describe"
```
### Options inherited from parent commands
```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```
### SEE ALSO
* [stackit beta affinity-group](./stackit_beta_affinity-group.md) - Manage server affinity groups
## stackit beta affinity-group list
Lists affinity groups
### Synopsis
Lists affinity groups.
```
stackit beta affinity-group list [flags]
```
### Examples
```
Lists all affinity groups
$ stackit beta affinity-group list
Lists up to 10 affinity groups
$ stackit beta affinity-group list --limit=10
```
### Options
```
-h, --help Help for "stackit beta affinity-group list"
--limit int Limit the output to the first n elements
```
### Options inherited from parent commands
```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```
### SEE ALSO
* [stackit beta affinity-group](./stackit_beta_affinity-group.md) - Manage server affinity groups
## stackit beta affinity-group
Manage server affinity groups
### Synopsis
Manage the lifecycle of server affinity groups.
```
stackit beta affinity-group [flags]
```
### Options
```
-h, --help Help for "stackit beta affinity-group"
```
### Options inherited from parent commands
```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```
### SEE ALSO
* [stackit beta](./stackit_beta.md) - Contains beta STACKIT CLI commands
* [stackit beta affinity-group create](./stackit_beta_affinity-group_create.md) - Creates an affinity groups
* [stackit beta affinity-group delete](./stackit_beta_affinity-group_delete.md) - Deletes an affinity group
* [stackit beta affinity-group describe](./stackit_beta_affinity-group_describe.md) - Show details of an affinity group
* [stackit beta affinity-group list](./stackit_beta_affinity-group_list.md) - Lists affinity groups
package affinity_groups
import (
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/cmd/beta/affinity-groups/create"
"github.com/stackitcloud/stackit-cli/internal/cmd/beta/affinity-groups/delete"
"github.com/stackitcloud/stackit-cli/internal/cmd/beta/affinity-groups/describe"
"github.com/stackitcloud/stackit-cli/internal/cmd/beta/affinity-groups/list"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
)
func NewCmd(p *print.Printer) *cobra.Command {
cmd := &cobra.Command{
Use: "affinity-group",
Short: "Manage server affinity groups",
Long: "Manage the lifecycle of server affinity groups.",
Args: args.NoArgs,
Run: utils.CmdHelp,
}
addSubcommands(cmd, p)
return cmd
}
func addSubcommands(cmd *cobra.Command, p *print.Printer) {
cmd.AddCommand(
create.NewCmd(p),
delete.NewCmd(p),
describe.NewCmd(p),
list.NewCmd(p),
)
}
package create
import (
"context"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
)
const projectIdFlag = globalflags.ProjectIdFlag
type testCtxKey struct{}
var (
testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
testClient = &iaas.APIClient{}
testProjectId = uuid.NewString()
)
const (
testName = "test-name"
testPolicy = "test-policy"
)
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
nameFlag: testName,
policyFlag: testPolicy,
}
for _, mod := range mods {
mod(flagValues)
}
return flagValues
}
func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
Verbosity: globalflags.VerbosityDefault,
ProjectId: testProjectId,
},
Name: testName,
Policy: testPolicy,
}
for _, mod := range mods {
mod(model)
}
return model
}
func fixtureRequest(mods ...func(request *iaas.ApiCreateAffinityGroupRequest)) iaas.ApiCreateAffinityGroupRequest {
request := testClient.CreateAffinityGroup(testCtx, testProjectId)
request = request.CreateAffinityGroupPayload(fixturePayload())
for _, mod := range mods {
mod(&request)
}
return request
}
func fixturePayload(mods ...func(payload *iaas.CreateAffinityGroupPayload)) iaas.CreateAffinityGroupPayload {
payload := iaas.CreateAffinityGroupPayload{
Name: utils.Ptr(testName),
Policy: utils.Ptr(testPolicy),
}
for _, mod := range mods {
mod(&payload)
}
return payload
}
func TestParseInput(t *testing.T) {
tests := []struct {
description string
flagValues map[string]string
isValid bool
expectedModel *inputModel
}{
{
description: "base",
flagValues: fixtureFlagValues(),
isValid: true,
expectedModel: fixtureInputModel(),
},
{
description: "without name flag",
flagValues: fixtureFlagValues(
func(flagValues map[string]string) {
delete(flagValues, "name")
},
),
isValid: false,
},
{
description: "without policy flag",
flagValues: fixtureFlagValues(
func(flagValues map[string]string) {
delete(flagValues, "policy")
},
),
isValid: false,
},
{
description: "without name and policy flag",
flagValues: fixtureFlagValues(
func(flagValues map[string]string) {
delete(flagValues, "policy")
delete(flagValues, "name")
},
),
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
p := print.NewPrinter()
cmd := NewCmd(p)
if err := globalflags.Configure(cmd.Flags()); err != nil {
t.Fatalf("configure global flags: %v", err)
}
for flag, value := range tt.flagValues {
if err := cmd.Flags().Set(flag, value); err != nil {
if !tt.isValid {
return
}
t.Fatalf("setting flag --%s=%s: %v", flag, value, err)
}
}
if err := cmd.ValidateRequiredFlags(); err != nil {
if !tt.isValid {
return
}
t.Fatalf("error validating flags: %v", err)
}
model, err := parseInput(p, cmd)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error parsing flags: %v", err)
}
if !tt.isValid {
t.Fatalf("did not fail on invalid input")
}
diff := cmp.Diff(model, tt.expectedModel)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
}
})
}
}
func TestBuildRequest(t *testing.T) {
tests := []struct {
description string
model inputModel
expectedRequest iaas.ApiCreateAffinityGroupRequest
}{
{
description: "base",
model: *fixtureInputModel(),
expectedRequest: fixtureRequest(),
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
request := buildRequest(testCtx, tt.model, testClient)
diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmpopts.EquateComparable(testCtx))
if diff != "" {
t.Fatalf("Request does not match: %s", diff)
}
})
}
}
func TestOutputResult(t *testing.T) {
tests := []struct {
description string
model inputModel
response iaas.AffinityGroup
isValid bool
}{
{
description: "empty",
model: inputModel{},
response: iaas.AffinityGroup{},
isValid: true,
},
{
description: "base",
model: *fixtureInputModel(),
response: iaas.AffinityGroup{
Id: utils.Ptr(testProjectId),
Members: utils.Ptr([]string{uuid.NewString(), uuid.NewString()}),
Name: utils.Ptr("test-project"),
Policy: utils.Ptr("hard-affinity"),
},
isValid: true,
},
}
p := print.NewPrinter()
p.Cmd = NewCmd(p)
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
err := outputResult(p, tt.model, tt.response)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error output result: %v", err)
return
}
if !tt.isValid {
t.Fatalf("did not fail on invalid input")
return
}
})
}
}
package create
import (
"context"
"encoding/json"
"fmt"
"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
"github.com/stackitcloud/stackit-cli/internal/pkg/flags"
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
)
const (
nameFlag = "name"
policyFlag = "policy"
)
type inputModel struct {
*globalflags.GlobalFlagModel
Name string
Policy string
}
func NewCmd(p *print.Printer) *cobra.Command {
cmd := &cobra.Command{
Use: "create",
Short: "Creates an affinity groups",
Long: `Creates an affinity groups.`,
Args: args.NoArgs,
Example: examples.Build(
examples.NewExample(
`Create an affinity group with name "AFFINITY_GROUP_NAME" and policy "soft-affinity"`,
"$ stackit beta affinity-group create --name AFFINITY_GROUP_NAME --policy soft-affinity",
),
),
RunE: func(cmd *cobra.Command, _ []string) error {
ctx := context.Background()
model, err := parseInput(p, cmd)
if err != nil {
return err
}
// Configure API client
apiClient, err := client.ConfigureClient(p)
if err != nil {
return err
}
if !model.AssumeYes {
prompt := fmt.Sprintf("Are you sure you want to create the affinity group %q?", model.Name)
err = p.PromptForConfirmation(prompt)
if err != nil {
return err
}
}
// Call API
request := buildRequest(ctx, *model, apiClient)
result, err := request.Execute()
if err != nil {
return fmt.Errorf("create affinity group: %w", err)
}
if resp := result; resp != nil {
return outputResult(p, *model, *resp)
}
return fmt.Errorf("create affinity group: nil result")
},
}
configureFlags(cmd)
return cmd
}
func configureFlags(cmd *cobra.Command) {
cmd.Flags().String(nameFlag, "", "The name of the affinity group.")
cmd.Flags().String(policyFlag, "", `The policy for the affinity group. Valid values for the policy are: "hard-affinity", "hard-anti-affinity", "soft-affinity", "soft-anti-affinity"`)
if err := flags.MarkFlagsRequired(cmd, nameFlag, policyFlag); err != nil {
cobra.CheckErr(err)
}
}
func buildRequest(ctx context.Context, model inputModel, apiClient *iaas.APIClient) iaas.ApiCreateAffinityGroupRequest {
req := apiClient.CreateAffinityGroup(ctx, model.ProjectId)
req = req.CreateAffinityGroupPayload(
iaas.CreateAffinityGroupPayload{
Name: utils.Ptr(model.Name),
Policy: utils.Ptr(model.Policy),
},
)
return req
}
func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
globalFlags := globalflags.Parse(p, cmd)
if globalFlags.ProjectId == "" {
return nil, &errors.ProjectIdError{}
}
model := inputModel{
GlobalFlagModel: globalFlags,
Name: flags.FlagToStringValue(p, cmd, nameFlag),
Policy: flags.FlagToStringValue(p, cmd, policyFlag),
}
if p.IsVerbosityDebug() {
modelStr, err := print.BuildDebugStrFromInputModel(model)
if err != nil {
p.Debug(print.ErrorLevel, "convert model to string for debugging: %v", err)
} else {
p.Debug(print.DebugLevel, "parsed input values: %s", modelStr)
}
}
return &model, nil
}
func outputResult(p *print.Printer, model inputModel, resp iaas.AffinityGroup) error {
outputFormat := ""
if model.GlobalFlagModel != nil {
outputFormat = model.GlobalFlagModel.OutputFormat
}
switch outputFormat {
case print.JSONOutputFormat:
details, err := json.MarshalIndent(resp, "", " ")
if err != nil {
return fmt.Errorf("marshal affinity group: %w", err)
}
p.Outputln(string(details))
case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {
return fmt.Errorf("marshal affinity group: %w", err)
}
p.Outputln(string(details))
default:
p.Outputf("Created affinity group %q with id %s\n", model.Name, utils.PtrString(resp.Id))
}
return nil
}
package delete
import (
"context"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
)
const projectIdFlag = globalflags.ProjectIdFlag
type testCtxKey struct{}
var (
testCtx = context.WithValue(context.Background(), &testCtxKey{}, "test")
testClient = &iaas.APIClient{}
testProjectId = uuid.NewString()
testAffinityGroupId = uuid.NewString()
)
func fixtureArgValues(mods ...func(argValues []string)) []string {
argValues := []string{
testAffinityGroupId,
}
for _, mod := range mods {
mod(argValues)
}
return argValues
}
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
}
for _, mod := range mods {
mod(flagValues)
}
return flagValues
}
func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
Verbosity: globalflags.VerbosityDefault,
ProjectId: testProjectId,
},
AffinityGroupId: testAffinityGroupId,
}
for _, mod := range mods {
mod(model)
}
return model
}
func fixtureRequest(mods ...func(request *iaas.ApiDeleteAffinityGroupRequest)) iaas.ApiDeleteAffinityGroupRequest {
request := testClient.DeleteAffinityGroup(testCtx, testProjectId, testAffinityGroupId)
for _, mod := range mods {
mod(&request)
}
return request
}
func TestParseInput(t *testing.T) {
tests := []struct {
description string
argValues []string
flagValues map[string]string
isValid bool
expectedModel *inputModel
}{
{
description: "base",
argValues: fixtureArgValues(),
flagValues: fixtureFlagValues(),
isValid: true,
expectedModel: fixtureInputModel(),
},
{
description: "without args",
argValues: []string{},
flagValues: fixtureFlagValues(),
isValid: false,
},
{
description: "without flags",
argValues: fixtureArgValues(),
flagValues: map[string]string{},
isValid: false,
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
p := print.NewPrinter()
cmd := NewCmd(p)
err := globalflags.Configure(cmd.Flags())
if err != nil {
t.Fatalf("configure global flags: %v", err)
}
for flag, value := range tt.flagValues {
err = cmd.Flags().Set(flag, value)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("setting flag --%s=%s: %v", flag, value, err)
}
}
err = cmd.ValidateArgs(tt.argValues)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error validating args: %v", err)
}
err = cmd.ValidateRequiredFlags()
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error validating flags: %v", err)
}
model, err := parseInput(p, cmd, tt.argValues)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error parsing input: %v", err)
}
if !tt.isValid {
t.Fatalf("did not fail on invalid input")
}
diff := cmp.Diff(model, tt.expectedModel)
if diff != "" {
t.Fatalf("data does not match: %s", diff)
}
})
}
}
func TestBuildRequest(t *testing.T) {
tests := []struct {
description string
model inputModel
expectedRequest iaas.ApiDeleteAffinityGroupRequest
}{
{
description: "base",
model: *fixtureInputModel(),
expectedRequest: fixtureRequest(),
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
request := buildRequest(testCtx, tt.model, testClient)
diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmpopts.EquateComparable(testCtx),
)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
}
})
}
}
package delete
import (
"context"
"fmt"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/projectname"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
)
type inputModel struct {
*globalflags.GlobalFlagModel
AffinityGroupId string
}
const (
affinityGroupIdArg = "AFFINITY_GROUP"
)
func NewCmd(p *print.Printer) *cobra.Command {
cmd := &cobra.Command{
Use: fmt.Sprintf("delete %s", affinityGroupIdArg),
Short: "Deletes an affinity group",
Long: `Deletes an affinity group.`,
Args: args.SingleArg(affinityGroupIdArg, utils.ValidateUUID),
Example: examples.Build(
examples.NewExample(
`Delete an affinity group with ID "xxx"`,
"$ stackit beta affinity-group delete xxx",
),
),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
model, err := parseInput(p, cmd, args)
if err != nil {
return err
}
// Configure API client
apiClient, err := client.ConfigureClient(p)
if err != nil {
return err
}
projectLabel, err := projectname.GetProjectName(ctx, p, cmd)
if err != nil {
p.Debug(print.ErrorLevel, "get project name: %v", err)
projectLabel = model.ProjectId
}
affinityGroupLabel, err := iaasUtils.GetAffinityGroupName(ctx, apiClient, model.ProjectId, model.AffinityGroupId)
if err != nil {
p.Debug(print.ErrorLevel, "get affinity group name: %v", err)
affinityGroupLabel = model.AffinityGroupId
}
if !model.AssumeYes {
prompt := fmt.Sprintf("Are you sure you want to delete affinity group %q?", affinityGroupLabel)
err = p.PromptForConfirmation(prompt)
if err != nil {
return err
}
}
// Call API
request := buildRequest(ctx, *model, apiClient)
err = request.Execute()
if err != nil {
return fmt.Errorf("delete affinity group: %w", err)
}
p.Info("Deleted affinity group %q for %q\n", affinityGroupLabel, projectLabel)
return nil
},
}
return cmd
}
func buildRequest(ctx context.Context, model inputModel, apiClient *iaas.APIClient) iaas.ApiDeleteAffinityGroupRequest {
return apiClient.DeleteAffinityGroup(ctx, model.ProjectId, model.AffinityGroupId)
}
func parseInput(p *print.Printer, cmd *cobra.Command, cliArgs []string) (*inputModel, error) {
globalFlags := globalflags.Parse(p, cmd)
if globalFlags.ProjectId == "" {
return nil, &errors.ProjectIdError{}
}
model := inputModel{
GlobalFlagModel: globalFlags,
AffinityGroupId: cliArgs[0],
}
if p.IsVerbosityDebug() {
modelStr, err := print.BuildDebugStrFromInputModel(model)
if err != nil {
p.Debug(print.ErrorLevel, "convert model to string for debugging: %v", err)
} else {
p.Debug(print.DebugLevel, "parsed input values: %s", modelStr)
}
}
return &model, nil
}
package describe
import (
"context"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
)
const projectIdFlag = globalflags.ProjectIdFlag
type testCtxKey struct{}
var (
testCtx = context.WithValue(context.Background(), &testCtxKey{}, projectIdFlag)
testClient = &iaas.APIClient{}
testProjectId = uuid.NewString()
testAffinityGroupId = uuid.NewString()
)
func fixtureArgValues(mods ...func(argValues []string)) []string {
argValues := []string{
testAffinityGroupId,
}
for _, mod := range mods {
mod(argValues)
}
return argValues
}
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
}
for _, mod := range mods {
mod(flagValues)
}
return flagValues
}
func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
Verbosity: globalflags.VerbosityDefault,
ProjectId: testProjectId,
},
AffinityGroupId: testAffinityGroupId,
}
for _, mod := range mods {
mod(model)
}
return model
}
func fixtureRequest(mods ...func(request *iaas.ApiGetAffinityGroupRequest)) iaas.ApiGetAffinityGroupRequest {
request := testClient.GetAffinityGroup(testCtx, testProjectId, testAffinityGroupId)
for _, mod := range mods {
mod(&request)
}
return request
}
func TestParseInput(t *testing.T) {
tests := []struct {
description string
argValues []string
flagValues map[string]string
isValid bool
expectedModel *inputModel
}{
{
description: "base",
argValues: fixtureArgValues(),
flagValues: fixtureFlagValues(),
isValid: true,
expectedModel: fixtureInputModel(),
},
{
description: "without args",
argValues: []string{},
flagValues: fixtureFlagValues(),
isValid: false,
},
{
description: "without flags",
argValues: fixtureArgValues(),
flagValues: map[string]string{},
isValid: false,
},
{},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
p := print.NewPrinter()
cmd := NewCmd(p)
err := globalflags.Configure(cmd.Flags())
if err != nil {
t.Fatalf("configure global flags: %v", err)
}
for flag, value := range tt.flagValues {
err = cmd.Flags().Set(flag, value)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("setting flag --%s=%s: %v", flag, value, err)
}
}
err = cmd.ValidateArgs(tt.argValues)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error validating args: %v", err)
}
err = cmd.ValidateRequiredFlags()
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error validating flags: %v", err)
}
model, err := parseInput(p, cmd, tt.argValues)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error parsing input: %v", err)
}
if !tt.isValid {
t.Fatalf("did not fail on invalid input")
}
diff := cmp.Diff(model, tt.expectedModel)
if diff != "" {
t.Fatalf("data does not match: %s", diff)
}
})
}
}
func TestBuildRequest(t *testing.T) {
tests := []struct {
description string
model inputModel
expectedRequest iaas.ApiGetAffinityGroupRequest
}{
{
description: "base",
model: *fixtureInputModel(),
expectedRequest: fixtureRequest(),
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
request := buildRequest(testCtx, tt.model, testClient)
diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmpopts.EquateComparable(testCtx),
)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
}
})
}
}
func TestOutputResult(t *testing.T) {
tests := []struct {
description string
model inputModel
isValid bool
response iaas.AffinityGroup
}{
{
description: "empty",
model: inputModel{},
isValid: true,
response: iaas.AffinityGroup{},
},
}
p := print.NewPrinter()
p.Cmd = NewCmd(p)
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
err := outputResult(p, tt.model, tt.response)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error output result: %v", err)
return
}
if !tt.isValid {
t.Fatalf("did not fail on invalid input")
return
}
})
}
}
package describe
import (
"context"
"encoding/json"
"fmt"
"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
)
type inputModel struct {
*globalflags.GlobalFlagModel
AffinityGroupId string
}
const (
affinityGroupId = "AFFINITY_GROUP_ID"
)
func NewCmd(p *print.Printer) *cobra.Command {
cmd := &cobra.Command{
Use: fmt.Sprintf("describe %s", affinityGroupId),
Short: "Show details of an affinity group",
Long: `Show details of an affinity group.`,
Args: args.SingleArg(affinityGroupId, utils.ValidateUUID),
Example: examples.Build(
examples.NewExample(
`Get details about an affinity group with the ID "xxx"`,
"$ stackit beta affinity-group describe xxx",
),
),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
model, err := parseInput(p, cmd, args)
if err != nil {
return err
}
// Configure API client
apiClient, err := client.ConfigureClient(p)
if err != nil {
return err
}
// Call API
request := buildRequest(ctx, *model, apiClient)
result, err := request.Execute()
if err != nil {
return fmt.Errorf("get affinity group: %w", err)
}
if err := outputResult(p, *model, *result); err != nil {
return err
}
return nil
},
}
return cmd
}
func buildRequest(ctx context.Context, model inputModel, apiClient *iaas.APIClient) iaas.ApiGetAffinityGroupRequest {
return apiClient.GetAffinityGroup(ctx, model.ProjectId, model.AffinityGroupId)
}
func parseInput(p *print.Printer, cmd *cobra.Command, cliArgs []string) (*inputModel, error) {
globalFlags := globalflags.Parse(p, cmd)
if globalFlags.ProjectId == "" {
return nil, &errors.ProjectIdError{}
}
model := inputModel{
GlobalFlagModel: globalFlags,
AffinityGroupId: cliArgs[0],
}
if p.IsVerbosityDebug() {
modelStr, err := print.BuildDebugStrFromInputModel(model)
if err != nil {
p.Debug(print.ErrorLevel, "convert model to string for debugging: %v", err)
} else {
p.Debug(print.DebugLevel, "parsed input values: %s", modelStr)
}
}
return &model, nil
}
func outputResult(p *print.Printer, model inputModel, resp iaas.AffinityGroup) error {
var outputFormat string
if model.GlobalFlagModel != nil {
outputFormat = model.GlobalFlagModel.OutputFormat
}
switch outputFormat {
case print.JSONOutputFormat:
details, err := json.MarshalIndent(resp, "", " ")
if err != nil {
return fmt.Errorf("marshal affinity group: %w", err)
}
p.Outputln(string(details))
case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {
return fmt.Errorf("marshal affinity group: %w", err)
}
p.Outputln(string(details))
default:
table := tables.NewTable()
if resp.HasId() {
table.AddRow("ID", utils.PtrString(resp.Id))
table.AddSeparator()
}
if resp.Name != nil {
table.AddRow("NAME", utils.PtrString(resp.Name))
table.AddSeparator()
}
if resp.Policy != nil {
table.AddRow("POLICY", utils.PtrString(resp.Policy))
table.AddSeparator()
}
if resp.HasMembers() {
table.AddRow("Members", utils.JoinStringPtr(resp.Members, ", "))
table.AddSeparator()
}
if err := table.Display(p); err != nil {
return fmt.Errorf("render table: %w", err)
}
}
return nil
}
package list
import (
"context"
"strconv"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
)
const projectIdFlag = globalflags.ProjectIdFlag
type testCtxKey struct{}
var (
testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
testClient = &iaas.APIClient{}
testProjectId = uuid.NewString()
)
const (
testLimit = 10
)
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
}
for _, mod := range mods {
mod(flagValues)
}
return flagValues
}
func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
Verbosity: globalflags.VerbosityDefault,
ProjectId: testProjectId,
},
}
for _, mod := range mods {
mod(model)
}
return model
}
func fixtureRequest(mods ...func(request *iaas.ApiListAffinityGroupsRequest)) iaas.ApiListAffinityGroupsRequest {
request := testClient.ListAffinityGroups(testCtx, testProjectId)
for _, mod := range mods {
mod(&request)
}
return request
}
func TestParseInput(t *testing.T) {
tests := []struct {
description string
flagValues map[string]string
isValid bool
expectedModel *inputModel
}{
{
description: "base",
flagValues: fixtureFlagValues(),
isValid: true,
expectedModel: fixtureInputModel(),
},
{
description: "without flags",
flagValues: map[string]string{},
isValid: false,
},
{
description: "with limit flag",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues["limit"] = strconv.Itoa(testLimit)
}),
isValid: true,
expectedModel: fixtureInputModel(func(model *inputModel) {
model.Limit = utils.Ptr(int64(testLimit))
}),
},
{
description: "with limit flag == 0",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues["limit"] = strconv.Itoa(0)
}),
isValid: false,
},
{
description: "with limit flag < 0",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues["limit"] = strconv.Itoa(-1)
}),
isValid: false,
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
p := print.NewPrinter()
cmd := NewCmd(p)
if err := globalflags.Configure(cmd.Flags()); err != nil {
t.Fatalf("configure global flags: %v", err)
}
for flag, value := range tt.flagValues {
if err := cmd.Flags().Set(flag, value); err != nil {
if !tt.isValid {
return
}
t.Fatalf("setting flag --%s=%s: %v", flag, value, err)
}
}
if err := cmd.ValidateRequiredFlags(); err != nil {
if !tt.isValid {
return
}
t.Fatalf("error validating flags: %v", err)
}
model, err := parseInput(p, cmd)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error parsing flags: %v", err)
}
if !tt.isValid {
t.Fatalf("did not fail on invalid input")
}
diff := cmp.Diff(model, tt.expectedModel)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
}
})
}
}
func TestBuildRequest(t *testing.T) {
tests := []struct {
description string
model inputModel
expectedRequest iaas.ApiListAffinityGroupsRequest
}{
{
description: "base",
model: *fixtureInputModel(),
expectedRequest: fixtureRequest(),
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
request := buildRequest(testCtx, tt.model, testClient)
diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmpopts.EquateComparable(testCtx))
if diff != "" {
t.Fatalf("Request does not match: %s", diff)
}
})
}
}
func TestOutputResult(t *testing.T) {
tests := []struct {
description string
model inputModel
response []iaas.AffinityGroup
isValid bool
}{
{
description: "empty",
model: inputModel{},
response: []iaas.AffinityGroup{},
isValid: true,
},
}
p := print.NewPrinter()
p.Cmd = NewCmd(p)
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
err := outputResult(p, tt.model, tt.response)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error output result: %v", err)
return
}
if !tt.isValid {
t.Fatalf("did not fail on invalid input")
return
}
})
}
}
package list
import (
"context"
"encoding/json"
"fmt"
"github.com/goccy/go-yaml"
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
"github.com/stackitcloud/stackit-cli/internal/pkg/flags"
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
)
type inputModel struct {
*globalflags.GlobalFlagModel
Limit *int64
}
const limitFlag = "limit"
func NewCmd(p *print.Printer) *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "Lists affinity groups",
Long: `Lists affinity groups.`,
Args: args.NoArgs,
Example: examples.Build(
examples.NewExample(
"Lists all affinity groups",
"$ stackit beta affinity-group list",
),
examples.NewExample(
"Lists up to 10 affinity groups",
"$ stackit beta affinity-group list --limit=10",
),
),
RunE: func(cmd *cobra.Command, _ []string) error {
ctx := context.Background()
model, err := parseInput(p, cmd)
if err != nil {
return err
}
// Configure API client
apiClient, err := client.ConfigureClient(p)
if err != nil {
return err
}
// Call API
request := buildRequest(ctx, *model, apiClient)
result, err := request.Execute()
if err != nil {
return fmt.Errorf("list affinity groups: %w", err)
}
if items := result.Items; items != nil {
if model.Limit != nil && len(*items) > int(*model.Limit) {
*items = (*items)[:*model.Limit]
}
return outputResult(p, *model, *items)
}
p.Outputln("No affinity groups found")
return nil
},
}
configureFlags(cmd)
return cmd
}
func configureFlags(cmd *cobra.Command) {
cmd.Flags().Int64(limitFlag, 0, "Limit the output to the first n elements")
}
func buildRequest(ctx context.Context, model inputModel, apiClient *iaas.APIClient) iaas.ApiListAffinityGroupsRequest {
return apiClient.ListAffinityGroups(ctx, model.ProjectId)
}
func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
globalFlags := globalflags.Parse(p, cmd)
if globalFlags.ProjectId == "" {
return nil, &errors.ProjectIdError{}
}
limit := flags.FlagToInt64Pointer(p, cmd, limitFlag)
if limit != nil && *limit < 1 {
return nil, &errors.FlagValidationError{
Flag: limitFlag,
Details: "must be greater than 0",
}
}
model := inputModel{
GlobalFlagModel: globalFlags,
Limit: limit,
}
if p.IsVerbosityDebug() {
modelStr, err := print.BuildDebugStrFromInputModel(model)
if err != nil {
p.Debug(print.ErrorLevel, "convert model to string for debugging: %v", err)
} else {
p.Debug(print.DebugLevel, "parsed input values: %s", modelStr)
}
}
return &model, nil
}
func outputResult(p *print.Printer, model inputModel, items []iaas.AffinityGroup) error {
var outputFormat string
if model.GlobalFlagModel != nil {
outputFormat = model.GlobalFlagModel.OutputFormat
}
switch outputFormat {
case print.JSONOutputFormat:
details, err := json.MarshalIndent(items, "", " ")
if err != nil {
return fmt.Errorf("marshal affinity groups: %w", err)
}
p.Outputln(string(details))
case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(items, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {
return fmt.Errorf("marshal affinity groups: %w", err)
}
p.Outputln(string(details))
default:
table := tables.NewTable()
table.SetHeader("ID", "NAME", "POLICY")
for _, item := range items {
table.AddRow(
utils.PtrString(item.Id),
utils.PtrString(item.Name),
utils.PtrString(item.Policy),
)
table.AddSeparator()
}
if err := table.Display(p); err != nil {
return fmt.Errorf("render table: %w", err)
}
}
return nil
}
+1
-0

@@ -44,2 +44,3 @@ ## stackit beta

* [stackit](./stackit.md) - Manage STACKIT resources using the command line
* [stackit beta affinity-group](./stackit_beta_affinity-group.md) - Manage server affinity groups
* [stackit beta image](./stackit_beta_image.md) - Manage server images

@@ -46,0 +47,0 @@ * [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for SSH key pairs

+6
-6

@@ -7,3 +7,3 @@ module github.com/stackitcloud/stackit-cli

github.com/fatih/color v1.18.0
github.com/goccy/go-yaml v1.15.17
github.com/goccy/go-yaml v1.15.22
github.com/golang-jwt/jwt/v5 v5.2.1

@@ -13,3 +13,3 @@ github.com/google/go-cmp v0.6.0

github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf
github.com/jedib0t/go-pretty/v6 v6.6.5
github.com/jedib0t/go-pretty/v6 v6.6.6
github.com/lmittmann/tint v1.0.7

@@ -31,3 +31,3 @@ github.com/mattn/go-colorable v0.1.14

github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.5.0
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.3.0
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.4.0
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.5.0

@@ -73,3 +73,3 @@ github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v0.4.0

github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect

@@ -79,3 +79,3 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect

github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect

@@ -90,3 +90,3 @@ github.com/sagikazarmark/locafero v0.4.0 // indirect

github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.20.1
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v0.11.1
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.0.0
github.com/stackitcloud/stackit-sdk-go/services/observability v0.2.1

@@ -93,0 +93,0 @@ github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.20.1

+14
-13

@@ -29,4 +29,4 @@ al.essio.dev/pkg/shellescape v1.5.1 h1:86HrALUujYS/h+GtqoB26SBEdkWfmMI6FubjXlsXyho=

github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/goccy/go-yaml v1.15.17 h1:dK4FbbTTEOZTLH/NW3/xBqg0JdC14YKVmYwS9GT3H60=
github.com/goccy/go-yaml v1.15.17/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/goccy/go-yaml v1.15.22 h1:iQI1hvCoiYYiVFq76P4AI8ImgDOfgiyKnl/AWjK8/gA=
github.com/goccy/go-yaml v1.15.22/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=

@@ -60,4 +60,4 @@ github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=

github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf/go.mod h1:yrqSXGoD/4EKfF26AOGzscPOgTTJcyAwM2rpixWT+t4=
github.com/jedib0t/go-pretty/v6 v6.6.5 h1:9PgMJOVBedpgYLI56jQRJYqngxYAAzfEUua+3NgSqAo=
github.com/jedib0t/go-pretty/v6 v6.6.5/go.mod h1:Uq/HrbhuFty5WSVNfjpQQe47x16RwVGXIveNGEyGtHs=
github.com/jedib0t/go-pretty/v6 v6.6.6 h1:LyezkL+1SuqH2z47e5IMQkYUIcs2BD+MnpdPRiRcN0c=
github.com/jedib0t/go-pretty/v6 v6.6.6/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=

@@ -83,4 +83,4 @@ github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=

github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=

@@ -101,4 +101,4 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=

github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=

@@ -141,4 +141,4 @@ github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=

github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.17.0/go.mod h1:5hMtm08NrL+QcgKl94zUDrY7VEzKRcvCJOEOvENBxqc=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v0.11.1 h1:Df3fTAHaVgyiiyp9LyTTQI8jXSVeGo49eW5ya4AATCY=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v0.11.1/go.mod h1:V2LEHKyTaaiEBi9L3v62mNQ7xyJSred4OK+himLJOZQ=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.0.0 h1:/0n2zcH1nMw2noroGhz0fgu2YqtNo9v3AsVhXMRtmtw=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.0.0/go.mod h1:0XumGX33DT6ItyD8yMlogSPWvpIuoqN7RZBrpUBPX+k=
github.com/stackitcloud/stackit-sdk-go/services/observability v0.2.1 h1:sIz4wJIz6/9Eh6nSoi2sQ+Ef53iOrFsqLKIp2oRkmgo=

@@ -162,4 +162,4 @@ github.com/stackitcloud/stackit-sdk-go/services/observability v0.2.1/go.mod h1:okcRTrNDTI3d7MQcYJMliK0qoXeLq0b1wvZuEqgJIWE=

github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.5.0/go.mod h1:thrCIDBjEHAcihjWUOMJ5mbYVhOWfS/bLTBJ+yl5W4g=
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.3.0 h1:x39lier26DANhGoo3Ko9Ta7ZeXwhW97fD6zPFX6xvNc=
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.3.0/go.mod h1:m/lZ3XH3wdKkkFb6vHxi0MhhMdRL2uAuCATeYChh+s0=
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.4.0 h1:kHzmcwSs1vgwSHIjgRlDoavKyzByOxSEUJ1XfYZvqn4=
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.4.0/go.mod h1:m/lZ3XH3wdKkkFb6vHxi0MhhMdRL2uAuCATeYChh+s0=
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.5.0 h1:yf9BxAZEG2hdaekWxaNt2BOX/4qmGkl0d268ggR+tCU=

@@ -182,4 +182,5 @@ github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.5.0/go.mod h1:Wpqj80yGruCNYGr2yxqhRaLLj4gPSkhJqZyWRXUh/QU=

github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=

@@ -186,0 +187,0 @@ github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=

@@ -6,3 +6,4 @@ package beta

image "github.com/stackitcloud/stackit-cli/internal/cmd/beta/image"
affinityGroups "github.com/stackitcloud/stackit-cli/internal/cmd/beta/affinity-groups"
"github.com/stackitcloud/stackit-cli/internal/cmd/beta/image"
keypair "github.com/stackitcloud/stackit-cli/internal/cmd/beta/key-pair"

@@ -60,2 +61,3 @@ "github.com/stackitcloud/stackit-cli/internal/cmd/beta/network"

cmd.AddCommand(quota.NewCmd(p))
cmd.AddCommand(affinityGroups.NewCmd(p))
}

@@ -390,3 +390,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -399,5 +399,5 @@ return fmt.Errorf("marshal image: %w", err)

default:
p.Outputf("Created image %q with id %s\n", model.Name, *model.Id)
p.Outputf("Created image %q with id %s\n", model.Name, utils.PtrString(model.Id))
return nil
}
}

@@ -148,3 +148,3 @@ package list

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(items, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(items, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -151,0 +151,0 @@ return fmt.Errorf("marshal image list: %w", err)

@@ -197,1 +197,40 @@ package create

}
func Test_outputResult(t *testing.T) {
type args struct {
item *iaas.Keypair
outputFormat string
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "empty",
args: args{
item: nil,
outputFormat: "",
},
wantErr: true,
},
{
name: "base",
args: args{
item: &iaas.Keypair{},
outputFormat: "",
},
wantErr: false,
},
}
p := print.NewPrinter()
p.Cmd = NewCmd(p)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := outputResult(p, tt.args.outputFormat, tt.args.item); (err != nil) != tt.wantErr {
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

@@ -85,3 +85,3 @@ package create

return outputResult(p, model, resp)
return outputResult(p, model.GlobalFlagModel.OutputFormat, resp)
},

@@ -145,4 +145,8 @@ }

func outputResult(p *print.Printer, model *inputModel, item *iaas.Keypair) error {
switch model.OutputFormat {
func outputResult(p *print.Printer, outputFormat string, item *iaas.Keypair) error {
if item == nil {
return fmt.Errorf("no key pair found")
}
switch outputFormat {
case print.JSONOutputFormat:

@@ -155,3 +159,3 @@ details, err := json.MarshalIndent(item, "", " ")

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(item, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(item, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -162,5 +166,8 @@ return fmt.Errorf("marshal key pair: %w", err)

default:
p.Outputf("Created key pair %q.\nkey pair Fingerprint: %q\n", *item.Name, *item.Fingerprint)
p.Outputf("Created key pair %q.\nkey pair Fingerprint: %q\n",
utils.PtrString(item.Name),
utils.PtrString(item.Fingerprint),
)
}
return nil
}

@@ -189,1 +189,33 @@ package describe

}
func Test_outputResult(t *testing.T) {
type args struct {
outputFormat string
showOnlyPublicKey bool
keyPair iaas.Keypair
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "base",
args: args{
outputFormat: "",
showOnlyPublicKey: false,
keyPair: iaas.Keypair{},
},
wantErr: false,
},
}
p := print.NewPrinter()
p.Cmd = NewCmd(p)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := outputResult(p, tt.args.outputFormat, tt.args.showOnlyPublicKey, tt.args.keyPair); (err != nil) != tt.wantErr {
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

@@ -9,2 +9,4 @@ package describe

"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -73,3 +75,7 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/examples"

return outputResult(p, model.OutputFormat, model.PublicKey, resp)
if keypair := resp; keypair != nil {
return outputResult(p, model.OutputFormat, model.PublicKey, *keypair)
}
p.Outputln("No keypair found.")
return nil
},

@@ -112,3 +118,3 @@ }

func outputResult(p *print.Printer, outputFormat string, showOnlyPublicKey bool, keyPair *iaas.Keypair) error {
func outputResult(p *print.Printer, outputFormat string, showOnlyPublicKey bool, keyPair iaas.Keypair) error {
switch outputFormat {

@@ -131,3 +137,3 @@ case print.JSONOutputFormat:

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(keyPair, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(keyPair, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if showOnlyPublicKey {

@@ -137,3 +143,3 @@ onlyPublicKey := map[string]string{

}
details, err = yaml.MarshalWithOptions(onlyPublicKey, yaml.IndentSequence(true))
details, err = yaml.MarshalWithOptions(onlyPublicKey, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
}

@@ -153,6 +159,6 @@

table := tables.NewTable()
table.AddRow("KEY PAIR NAME", *keyPair.Name)
table.AddRow("KEY PAIR NAME", utils.PtrString(keyPair.Name))
table.AddSeparator()
if *keyPair.Labels != nil && len(*keyPair.Labels) > 0 {
if keyPair.Labels != nil && len(*keyPair.Labels) > 0 {
var labels []string

@@ -166,13 +172,17 @@ for key, value := range *keyPair.Labels {

table.AddRow("FINGERPRINT", *keyPair.Fingerprint)
table.AddRow("FINGERPRINT", utils.PtrString(keyPair.Fingerprint))
table.AddSeparator()
truncatedPublicKey := (*keyPair.PublicKey)[:maxLengthPublicKey] + "..."
truncatedPublicKey := ""
if keyPair.PublicKey != nil {
truncatedPublicKey = (*keyPair.PublicKey)[:maxLengthPublicKey] + "..."
}
table.AddRow("PUBLIC KEY", truncatedPublicKey)
table.AddSeparator()
table.AddRow("CREATED AT", *keyPair.CreatedAt)
table.AddRow("CREATED AT", utils.PtrString(keyPair.CreatedAt))
table.AddSeparator()
table.AddRow("UPDATED AT", *keyPair.UpdatedAt)
table.AddRow("UPDATED AT", utils.PtrString(keyPair.UpdatedAt))
table.AddSeparator()

@@ -179,0 +189,0 @@

@@ -189,1 +189,35 @@ package list

}
func Test_outputResult(t *testing.T) {
type args struct {
outputFormat string
keyPairs []iaas.Keypair
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "empty",
args: args{
outputFormat: "",
keyPairs: []iaas.Keypair{
{},
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := print.NewPrinter()
p.Cmd = NewCmd(p)
if err := outputResult(p, tt.args.outputFormat, tt.args.keyPairs); (err != nil) != tt.wantErr {
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

@@ -9,2 +9,4 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -148,3 +150,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(keyPairs, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(keyPairs, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -163,7 +165,15 @@ return fmt.Errorf("marshal key pairs: %w", err)

var labels []string
for key, value := range *keyPair.Labels {
labels = append(labels, fmt.Sprintf("%s: %s", key, value))
if keyPair.Labels != nil {
for key, value := range *keyPair.Labels {
labels = append(labels, fmt.Sprintf("%s: %s", key, value))
}
}
table.AddRow(*keyPair.Name, strings.Join(labels, ", "), *keyPair.Fingerprint, *keyPair.CreatedAt, *keyPair.UpdatedAt)
table.AddRow(
utils.PtrString(keyPair.Name),
strings.Join(labels, ", "),
utils.PtrString(keyPair.Fingerprint),
utils.PtrString(keyPair.CreatedAt),
utils.PtrString(keyPair.UpdatedAt),
)
}

@@ -170,0 +180,0 @@

@@ -144,9 +144,3 @@ package update

model, err := parseInput(p, cmd, tt.argValues)
if err != nil {
if !tt.isValid {
return
}
t.Fatalf("error parsing flags: %v", err)
}
model := parseInput(p, cmd, tt.argValues)

@@ -156,3 +150,3 @@ if !tt.isValid {

}
diff := cmp.Diff(model, tt.expectedModel)
diff := cmp.Diff(&model, tt.expectedModel)
if diff != "" {

@@ -193,1 +187,36 @@ t.Fatalf("Data does not match: %s", diff)

}
func Test_outputResult(t *testing.T) {
type args struct {
model inputModel
keyPair iaas.Keypair
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "empty",
args: args{},
wantErr: false,
},
{
name: "base",
args: args{
model: inputModel{},
keyPair: iaas.Keypair{},
},
wantErr: false,
},
}
p := print.NewPrinter()
p.Cmd = NewCmd(p)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := outputResult(p, tt.args.model, tt.args.keyPair); (err != nil) != tt.wantErr {
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

@@ -46,6 +46,3 @@ package update

ctx := context.Background()
model, err := parseInput(p, cmd, args)
if err != nil {
return err
}
model := parseInput(p, cmd, args)

@@ -67,3 +64,3 @@ // Configure API client

// Call API
req := buildRequest(ctx, model, apiClient)
req := buildRequest(ctx, &model, apiClient)
resp, err := req.Execute()

@@ -73,4 +70,7 @@ if err != nil {

}
if resp == nil {
return fmt.Errorf("response is nil")
}
return outputResult(p, model, resp)
return outputResult(p, model, *resp)
},

@@ -106,3 +106,3 @@ }

func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) {
func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) inputModel {
keyPairName := inputArgs[0]

@@ -126,7 +126,11 @@ globalFlags := globalflags.Parse(p, cmd)

return &model, nil
return model
}
func outputResult(p *print.Printer, model *inputModel, keyPair *iaas.Keypair) error {
switch model.OutputFormat {
func outputResult(p *print.Printer, model inputModel, keyPair iaas.Keypair) error {
var outputFormat string
if model.GlobalFlagModel != nil {
outputFormat = model.GlobalFlagModel.OutputFormat
}
switch outputFormat {
case print.JSONOutputFormat:

@@ -139,3 +143,3 @@ details, err := json.MarshalIndent(keyPair, "", " ")

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(keyPair, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(keyPair, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -146,5 +150,5 @@ return fmt.Errorf("marshal key pair: %w", err)

default:
p.Outputf("Updated labels of key pair %q\n", *model.KeyPairName)
p.Outputf("Updated labels of key pair %q\n", utils.PtrString(model.KeyPairName))
}
return nil
}

@@ -192,3 +192,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(networkArea, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(networkArea, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -201,5 +201,5 @@ return fmt.Errorf("marshal network area: %w", err)

default:
p.Outputf("Created STACKIT Network Area for organization %q.\nNetwork area ID: %s\n", orgLabel, *networkArea.AreaId)
p.Outputf("Created STACKIT Network Area for organization %q.\nNetwork area ID: %s\n", orgLabel, utils.PtrString(networkArea.AreaId))
return nil
}
}

@@ -140,3 +140,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(networkArea, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(networkArea, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -164,7 +164,7 @@ return fmt.Errorf("marshal network area: %w", err)

table := tables.NewTable()
table.AddRow("ID", *networkArea.AreaId)
table.AddRow("ID", utils.PtrString(networkArea.AreaId))
table.AddSeparator()
table.AddRow("NAME", *networkArea.Name)
table.AddRow("NAME", utils.PtrString(networkArea.Name))
table.AddSeparator()
table.AddRow("STATE", *networkArea.State)
table.AddRow("STATE", utils.PtrString(networkArea.State))
table.AddSeparator()

@@ -179,22 +179,24 @@ if len(networkRanges) > 0 {

}
if networkArea.Ipv4.TransferNetwork != nil {
table.AddRow("TRANSFER RANGE", *networkArea.Ipv4.TransferNetwork)
table.AddSeparator()
if networkArea.Ipv4 != nil {
if networkArea.Ipv4.TransferNetwork != nil {
table.AddRow("TRANSFER RANGE", *networkArea.Ipv4.TransferNetwork)
table.AddSeparator()
}
if networkArea.Ipv4.DefaultNameservers != nil && len(*networkArea.Ipv4.DefaultNameservers) > 0 {
table.AddRow("DNS NAME SERVERS", strings.Join(*networkArea.Ipv4.DefaultNameservers, ","))
table.AddSeparator()
}
if networkArea.Ipv4.DefaultPrefixLen != nil {
table.AddRow("DEFAULT PREFIX LENGTH", *networkArea.Ipv4.DefaultPrefixLen)
table.AddSeparator()
}
if networkArea.Ipv4.MaxPrefixLen != nil {
table.AddRow("MAX PREFIX LENGTH", *networkArea.Ipv4.MaxPrefixLen)
table.AddSeparator()
}
if networkArea.Ipv4.MinPrefixLen != nil {
table.AddRow("MIN PREFIX LENGTH", *networkArea.Ipv4.MinPrefixLen)
table.AddSeparator()
}
}
if networkArea.Ipv4.DefaultNameservers != nil {
table.AddRow("DNS NAME SERVERS", strings.Join(*networkArea.Ipv4.DefaultNameservers, ","))
table.AddSeparator()
}
if networkArea.Ipv4.DefaultPrefixLen != nil {
table.AddRow("DEFAULT PREFIX LENGTH", *networkArea.Ipv4.DefaultPrefixLen)
table.AddSeparator()
}
if networkArea.Ipv4.MaxPrefixLen != nil {
table.AddRow("MAX PREFIX LENGTH", *networkArea.Ipv4.MaxPrefixLen)
table.AddSeparator()
}
if networkArea.Ipv4.MinPrefixLen != nil {
table.AddRow("MIN PREFIX LENGTH", *networkArea.Ipv4.MinPrefixLen)
table.AddSeparator()
}
if len(attachedProjects) > 0 {

@@ -204,3 +206,3 @@ table.AddRow("ATTACHED PROJECTS IDS", strings.Join(attachedProjects, "\n"))

} else {
table.AddRow("# ATTACHED PROJECTS", *networkArea.ProjectCount)
table.AddRow("# ATTACHED PROJECTS", utils.PtrString(networkArea.ProjectCount))
table.AddSeparator()

@@ -207,0 +209,0 @@ }

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -20,5 +21,4 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
"github.com/spf13/cobra"
)

@@ -157,3 +157,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(networkAreas, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(networkAreas, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -170,3 +170,16 @@ return fmt.Errorf("marshal area: %w", err)

for _, networkArea := range networkAreas {
table.AddRow(*networkArea.AreaId, *networkArea.Name, *networkArea.State, len(*networkArea.Ipv4.NetworkRanges), *networkArea.ProjectCount)
networkRanges := "n/a"
if ipv4 := networkArea.Ipv4; ipv4 != nil {
if netRange := ipv4.NetworkRanges; netRange != nil {
networkRanges = fmt.Sprint(len(*netRange))
}
}
table.AddRow(
utils.PtrString(networkArea.AreaId),
utils.PtrString(networkArea.Name),
utils.PtrString(networkArea.State),
networkRanges,
utils.PtrString(networkArea.ProjectCount),
)
table.AddSeparator()

@@ -173,0 +186,0 @@ }

@@ -15,3 +15,4 @@ package create

"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"

@@ -61,3 +62,3 @@

// Get network area label
networkAreaLabel, err := utils.GetNetworkAreaName(ctx, apiClient, *model.OrganizationId, *model.NetworkAreaId)
networkAreaLabel, err := iaasUtils.GetNetworkAreaName(ctx, apiClient, *model.OrganizationId, *model.NetworkAreaId)
if err != nil {

@@ -87,3 +88,3 @@ p.Debug(print.ErrorLevel, "get network area name: %v", err)

networkRange, err := utils.GetNetworkRangeFromAPIResponse(*model.NetworkRange, resp.Items)
networkRange, err := iaasUtils.GetNetworkRangeFromAPIResponse(*model.NetworkRange, resp.Items)
if err != nil {

@@ -154,3 +155,3 @@ return err

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(networkRange, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(networkRange, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -163,5 +164,5 @@ return fmt.Errorf("marshal network range: %w", err)

default:
p.Outputf("Created network range for SNA %q.\nNetwork range ID: %s\n", networkAreaLabel, *networkRange.NetworkRangeId)
p.Outputf("Created network range for SNA %q.\nNetwork range ID: %s\n", networkAreaLabel, utils.PtrString(networkRange.NetworkRangeId))
return nil
}
}

@@ -122,3 +122,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(networkRange, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(networkRange, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -132,5 +132,5 @@ return fmt.Errorf("marshal network range: %w", err)

table := tables.NewTable()
table.AddRow("ID", *networkRange.NetworkRangeId)
table.AddRow("ID", utils.PtrString(networkRange.NetworkRangeId))
table.AddSeparator()
table.AddRow("Network range", *networkRange.Prefix)
table.AddRow("Network range", utils.PtrString(networkRange.Prefix))

@@ -137,0 +137,0 @@ err := table.Display(p)

@@ -153,3 +153,3 @@ package list

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(networkRanges, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(networkRanges, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -156,0 +156,0 @@ return fmt.Errorf("marshal network ranges: %w", err)

@@ -179,3 +179,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(route, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(route, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -188,5 +188,5 @@ return fmt.Errorf("marshal static route: %w", err)

default:
p.Outputf("Created static route for SNA %q.\nStatic route ID: %s\n", networkAreaLabel, *route.RouteId)
p.Outputf("Created static route for SNA %q.\nStatic route ID: %s\n", networkAreaLabel, utils.PtrString(route.RouteId))
return nil
}
}

@@ -127,3 +127,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(route, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(route, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -137,7 +137,7 @@ return fmt.Errorf("marshal static route: %w", err)

table := tables.NewTable()
table.AddRow("ID", *route.RouteId)
table.AddRow("ID", utils.PtrString(route.RouteId))
table.AddSeparator()
table.AddRow("PREFIX", *route.Prefix)
table.AddRow("PREFIX", utils.PtrString(route.Prefix))
table.AddSeparator()
table.AddRow("NEXTHOP", *route.Nexthop)
table.AddRow("NEXTHOP", utils.PtrString(route.Nexthop))
if route.Labels != nil && len(*route.Labels) > 0 {

@@ -144,0 +144,0 @@ labels := []string{}

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,5 +20,4 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
"github.com/spf13/cobra"
)

@@ -155,3 +155,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(routes, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(routes, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -168,3 +168,7 @@ return fmt.Errorf("marshal static routes: %w", err)

for _, route := range routes {
table.AddRow(*route.RouteId, *route.Nexthop, *route.Prefix)
table.AddRow(
utils.PtrString(route.RouteId),
utils.PtrString(route.Nexthop),
utils.PtrString(route.Prefix),
)
}

@@ -171,0 +175,0 @@

@@ -155,3 +155,3 @@ package update

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(route, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(route, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -164,5 +164,5 @@ return fmt.Errorf("marshal static route: %w", err)

default:
p.Outputf("Updated static route for SNA %q.\nStatic route ID: %s\n", networkAreaLabel, *route.RouteId)
p.Outputf("Updated static route for SNA %q.\nStatic route ID: %s\n", networkAreaLabel, utils.PtrString(route.RouteId))
return nil
}
}

@@ -174,3 +174,3 @@ package update

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(networkArea, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(networkArea, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -177,0 +177,0 @@ return fmt.Errorf("marshal network area: %w", err)

@@ -240,3 +240,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(nic, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(nic, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -249,5 +249,5 @@ return fmt.Errorf("marshal network interface: %w", err)

default:
p.Outputf("Created network interface for project %q.\nNIC ID: %s\n", model.ProjectId, *nic.Id)
p.Outputf("Created network interface for project %q.\nNIC ID: %s\n", model.ProjectId, utils.PtrString(nic.Id))
return nil
}
}

@@ -130,3 +130,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(nic, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(nic, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -156,5 +156,5 @@ return fmt.Errorf("marshal network interface: %w", err)

}
table.AddRow("MAC", *nic.Mac)
table.AddRow("MAC", utils.PtrString(nic.Mac))
table.AddSeparator()
table.AddRow("NIC SECURITY", *nic.NicSecurity)
table.AddRow("NIC SECURITY", utils.PtrString(nic.NicSecurity))
if nic.AllowedAddresses != nil && len(*nic.AllowedAddresses) > 0 {

@@ -177,5 +177,5 @@ allowedAddresses := []string{}

table.AddSeparator()
table.AddRow("STATUS", *nic.Status)
table.AddRow("STATUS", utils.PtrString(nic.Status))
table.AddSeparator()
table.AddRow("TYPE", *nic.Type)
table.AddRow("TYPE", utils.PtrString(nic.Type))
if nic.SecurityGroups != nil && len(*nic.SecurityGroups) > 0 {

@@ -182,0 +182,0 @@ table.AddSeparator()

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,5 +20,4 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
"github.com/spf13/cobra"
)

@@ -167,3 +167,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(nics, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(nics, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -180,7 +180,9 @@ return fmt.Errorf("marshal nics: %w", err)

for _, nic := range nics {
name := ""
if nic.Name != nil {
name = *nic.Name
}
table.AddRow(*nic.Id, name, *nic.NicSecurity, *nic.Status, *nic.Type)
table.AddRow(
utils.PtrString(nic.Id),
utils.PtrString(nic.Name),
utils.PtrString(nic.NicSecurity),
utils.PtrString(nic.Status),
utils.PtrString(nic.Type),
)
table.AddSeparator()

@@ -187,0 +189,0 @@ }

@@ -232,3 +232,3 @@ package update

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(nic, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(nic, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -235,0 +235,0 @@ return fmt.Errorf("marshal network interface: %w", err)

@@ -248,3 +248,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(network, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(network, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -251,0 +251,0 @@ return fmt.Errorf("marshal network: %w", err)

@@ -114,3 +114,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(network, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(network, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -144,7 +144,7 @@ return fmt.Errorf("marshal network: %w", err)

table := tables.NewTable()
table.AddRow("ID", *network.NetworkId)
table.AddRow("ID", utils.PtrString(network.NetworkId))
table.AddSeparator()
table.AddRow("NAME", *network.Name)
table.AddRow("NAME", utils.PtrString(network.Name))
table.AddSeparator()
table.AddRow("STATE", *network.State)
table.AddRow("STATE", utils.PtrString(network.State))
table.AddSeparator()

@@ -151,0 +151,0 @@

@@ -7,3 +7,2 @@ package list

"fmt"
"strings"

@@ -20,2 +19,3 @@ "github.com/goccy/go-yaml"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"

@@ -148,3 +148,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(networks, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(networks, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -170,8 +170,12 @@ return fmt.Errorf("marshal network: %w", err)

}
prefixes := ""
if network.Prefixes != nil && len(*network.Prefixes) > 0 {
prefixes = strings.Join(*network.Prefixes, ", ")
}
prefixes := utils.JoinStringPtr(network.Prefixes, ", ")
table.AddRow(*network.NetworkId, *network.Name, *network.State, publicIp, prefixes, routed)
table.AddRow(
utils.PtrString(network.NetworkId),
utils.PtrString(network.Name),
utils.PtrString(network.State),
publicIp,
prefixes,
routed,
)
table.AddSeparator()

@@ -178,0 +182,0 @@ }

@@ -79,3 +79,3 @@ package associate

p.Outputf("Associated public IP %q with resource %v.\n", publicIpLabel, *resp.GetNetworkInterface())
p.Outputf("Associated public IP %q with resource %v.\n", publicIpLabel, utils.PtrString(resp.GetNetworkInterface()))
return nil

@@ -82,0 +82,0 @@ },

@@ -154,3 +154,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(publicIp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(publicIp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -163,5 +163,5 @@ return fmt.Errorf("marshal public IP: %w", err)

default:
p.Outputf("Created public IP for project %q.\nPublic IP ID: %s\n", projectLabel, *publicIp.Id)
p.Outputf("Created public IP for project %q.\nPublic IP ID: %s\n", projectLabel, utils.PtrString(publicIp.Id))
return nil
}
}

@@ -115,3 +115,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(publicIp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(publicIp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -125,5 +125,5 @@ return fmt.Errorf("marshal public IP: %w", err)

table := tables.NewTable()
table.AddRow("ID", *publicIp.Id)
table.AddRow("ID", utils.PtrString(publicIp.Id))
table.AddSeparator()
table.AddRow("IP ADDRESS", *publicIp.Ip)
table.AddRow("IP ADDRESS", utils.PtrString(publicIp.Ip))
table.AddSeparator()

@@ -130,0 +130,0 @@

@@ -18,2 +18,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"

@@ -159,3 +160,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(publicIps, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(publicIps, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -172,7 +173,8 @@ return fmt.Errorf("marshal public IP: %w", err)

for _, publicIp := range publicIps {
networkInterfaceId := ""
if publicIp.NetworkInterface != nil {
networkInterfaceId = *publicIp.GetNetworkInterface()
}
table.AddRow(*publicIp.Id, *publicIp.Ip, networkInterfaceId)
networkInterfaceId := utils.PtrStringDefault(publicIp.GetNetworkInterface(), "")
table.AddRow(
utils.PtrString(publicIp.Id),
utils.PtrString(publicIp.Ip),
networkInterfaceId,
)
table.AddSeparator()

@@ -179,0 +181,0 @@ }

@@ -159,3 +159,3 @@ package update

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(publicIp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(publicIp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -162,0 +162,0 @@ return fmt.Errorf("marshal public IP: %w", err)

@@ -158,3 +158,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -161,0 +161,0 @@ return fmt.Errorf("marshal security group: %w", err)

@@ -110,3 +110,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -113,0 +113,0 @@ return fmt.Errorf("marshal security group: %w", err)

@@ -132,3 +132,3 @@ package list

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(items, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(items, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -135,0 +135,0 @@ return fmt.Errorf("marshal PostgreSQL Flex instance list: %w", err)

@@ -18,2 +18,3 @@ package create

iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"

@@ -232,3 +233,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(securityGroupRule, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(securityGroupRule, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -245,5 +246,5 @@ return fmt.Errorf("marshal security group rule: %w", err)

}
p.Outputf("%s security group rule for security group %q in project %q.\nSecurity group rule ID: %s\n", operationState, securityGroupName, projectLabel, *securityGroupRule.Id)
p.Outputf("%s security group rule for security group %q in project %q.\nSecurity group rule ID: %s\n", operationState, securityGroupName, projectLabel, utils.PtrString(securityGroupRule.Id))
return nil
}
}

@@ -126,3 +126,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(securityGroupRule, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(securityGroupRule, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -136,3 +136,3 @@ return fmt.Errorf("marshal security group rule: %w", err)

table := tables.NewTable()
table.AddRow("ID", *securityGroupRule.Id)
table.AddRow("ID", utils.PtrString(securityGroupRule.Id))
table.AddSeparator()

@@ -152,3 +152,3 @@

table.AddRow("DIRECTION", *securityGroupRule.Direction)
table.AddRow("DIRECTION", utils.PtrString(securityGroupRule.Direction))
table.AddSeparator()

@@ -155,0 +155,0 @@

@@ -161,3 +161,3 @@ package list

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(securityGroupRules, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(securityGroupRules, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -174,6 +174,3 @@ return fmt.Errorf("marshal security group rules: %w", err)

for _, securityGroupRule := range securityGroupRules {
etherType := ""
if securityGroupRule.Ethertype != nil {
etherType = *securityGroupRule.Ethertype
}
etherType := utils.PtrStringDefault(securityGroupRule.Ethertype, "")

@@ -180,0 +177,0 @@ protocolName := ""

@@ -16,2 +16,3 @@ package create

"github.com/stackitcloud/stackit-cli/internal/pkg/services/serverbackup/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -154,3 +155,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -163,5 +164,5 @@ return fmt.Errorf("marshal server backup: %w", err)

default:
p.Outputf("Triggered creation of server backup for server %s. Backup ID: %s\n", model.ServerId, *resp.Id)
p.Outputf("Triggered creation of server backup for server %s. Backup ID: %s\n", model.ServerId, utils.PtrString(resp.Id))
return nil
}
}

@@ -123,3 +123,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(backup, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(backup, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -133,19 +133,16 @@ return fmt.Errorf("marshal server backup: %w", err)

table := tables.NewTable()
table.AddRow("ID", *backup.Id)
table.AddRow("ID", utils.PtrString(backup.Id))
table.AddSeparator()
table.AddRow("NAME", *backup.Name)
table.AddRow("NAME", utils.PtrString(backup.Name))
table.AddSeparator()
table.AddRow("SIZE (GB)", *backup.Size)
table.AddRow("SIZE (GB)", utils.PtrString(backup.Size))
table.AddSeparator()
table.AddRow("STATUS", *backup.Status)
table.AddRow("STATUS", utils.PtrString(backup.Status))
table.AddSeparator()
table.AddRow("CREATED AT", *backup.CreatedAt)
table.AddRow("CREATED AT", utils.PtrString(backup.CreatedAt))
table.AddSeparator()
table.AddRow("EXPIRES AT", *backup.ExpireAt)
table.AddRow("EXPIRES AT", utils.PtrString(backup.ExpireAt))
table.AddSeparator()
lastRestored := ""
if backup.LastRestoredAt != nil {
lastRestored = *backup.LastRestoredAt
}
lastRestored := utils.PtrStringDefault(backup.LastRestoredAt, "")
table.AddRow("LAST RESTORED AT", lastRestored)

@@ -152,0 +149,0 @@ table.AddSeparator()

@@ -9,3 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/serverbackup"

@@ -142,3 +141,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(backups, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(backups, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -156,7 +155,13 @@ return fmt.Errorf("marshal Server Backup list: %w", err)

lastRestored := ""
if s.LastRestoredAt != nil {
lastRestored = *s.LastRestoredAt
}
table.AddRow(*s.Id, *s.Name, *s.Size, *s.Status, *s.CreatedAt, *s.ExpireAt, lastRestored, len(*s.VolumeBackups))
lastRestored := utils.PtrStringDefault(s.LastRestoredAt, "")
table.AddRow(
utils.PtrString(s.Id),
utils.PtrString(s.Name),
utils.PtrString(s.Size),
utils.PtrString(s.Status),
utils.PtrString(s.CreatedAt),
utils.PtrString(s.ExpireAt),
lastRestored,
len(*s.VolumeBackups),
)
}

@@ -163,0 +168,0 @@ err := table.Display(p)

@@ -16,2 +16,3 @@ package create

"github.com/stackitcloud/stackit-cli/internal/pkg/services/serverbackup/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -173,3 +174,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -182,5 +183,5 @@ return fmt.Errorf("marshal server backup schedule: %w", err)

default:
p.Outputf("Created server backup schedule for server %s. Backup Schedule ID: %d\n", model.ServerId, *resp.Id)
p.Outputf("Created server backup schedule for server %s. Backup Schedule ID: %s\n", model.ServerId, utils.PtrString(resp.Id))
return nil
}
}

@@ -7,3 +7,2 @@ package describe

"fmt"
"strings"

@@ -19,2 +18,3 @@ "github.com/goccy/go-yaml"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -125,3 +125,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(schedule, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(schedule, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -135,9 +135,9 @@ return fmt.Errorf("marshal server backup schedule: %w", err)

table := tables.NewTable()
table.AddRow("SCHEDULE ID", *schedule.Id)
table.AddRow("SCHEDULE ID", utils.PtrString(schedule.Id))
table.AddSeparator()
table.AddRow("SCHEDULE NAME", *schedule.Name)
table.AddRow("SCHEDULE NAME", utils.PtrString(schedule.Name))
table.AddSeparator()
table.AddRow("ENABLED", *schedule.Enabled)
table.AddRow("ENABLED", utils.PtrString(schedule.Enabled))
table.AddSeparator()
table.AddRow("RRULE", *schedule.Rrule)
table.AddRow("RRULE", utils.PtrString(schedule.Rrule))
table.AddSeparator()

@@ -150,7 +150,3 @@ if schedule.BackupProperties != nil {

ids := schedule.BackupProperties.VolumeIds
if ids == nil || len(*ids) == 0 {
table.AddRow("BACKUP VOLUME IDS", "")
} else {
table.AddRow("BACKUP VOLUME IDS", strings.Join(*ids, "\n"))
}
table.AddRow("BACKUP VOLUME IDS", utils.JoinStringPtr(ids, "\n"))
}

@@ -157,0 +153,0 @@ err := table.Display(p)

@@ -7,6 +7,5 @@ package list

"fmt"
"strings"
"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -20,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/serverbackup"

@@ -143,3 +141,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(schedules, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(schedules, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -157,7 +155,20 @@ return fmt.Errorf("marshal Server Backup Schedules list: %w", err)

backupName := ""
retentionPeriod := ""
ids := ""
if s.BackupProperties.VolumeIds != nil && len(*s.BackupProperties.VolumeIds) != 0 {
ids = strings.Join(*s.BackupProperties.VolumeIds, ",")
if s.BackupProperties != nil {
backupName = utils.PtrString(s.BackupProperties.Name)
retentionPeriod = utils.PtrString(s.BackupProperties.RetentionPeriod)
ids = utils.JoinStringPtr(s.BackupProperties.VolumeIds, ",")
}
table.AddRow(*s.Id, *s.Name, *s.Enabled, *s.Rrule, *s.BackupProperties.Name, *s.BackupProperties.RetentionPeriod, ids)
table.AddRow(
utils.PtrString(s.Id),
utils.PtrString(s.Name),
utils.PtrString(s.Enabled),
utils.PtrString(s.Rrule),
backupName,
retentionPeriod,
ids,
)
}

@@ -164,0 +175,0 @@ err := table.Display(p)

@@ -16,2 +16,3 @@ package update

"github.com/stackitcloud/stackit-cli/internal/pkg/services/serverbackup/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -198,3 +199,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -207,5 +208,5 @@ return fmt.Errorf("marshal update server backup schedule: %w", err)

default:
p.Info("Updated server backup schedule %d\n", *resp.Id)
p.Info("Updated server backup schedule %s\n", utils.PtrString(resp.Id))
return nil
}
}

@@ -9,2 +9,3 @@ package create

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,4 +19,3 @@ cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

runcommandUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/runcommand/utils"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/runcommand"

@@ -153,3 +153,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -162,5 +162,5 @@ return fmt.Errorf("marshal server command: %w", err)

default:
p.Outputf("Created server command for server %s. Command ID: %d\n", model.ServerId, *resp.Id)
p.Outputf("Created server command for server %s. Command ID: %s\n", model.ServerId, utils.PtrString(resp.Id))
return nil
}
}

@@ -9,2 +9,3 @@ package describe

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/runcommand"

@@ -124,3 +124,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(command, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(command, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -134,19 +134,19 @@ return fmt.Errorf("marshal server command: %w", err)

table := tables.NewTable()
table.AddRow("ID", *command.Id)
table.AddRow("ID", utils.PtrString(command.Id))
table.AddSeparator()
table.AddRow("COMMAND TEMPLATE NAME", *command.CommandTemplateName)
table.AddRow("COMMAND TEMPLATE NAME", utils.PtrString(command.CommandTemplateName))
table.AddSeparator()
table.AddRow("COMMAND TEMPLATE TITLE", *command.CommandTemplateTitle)
table.AddRow("COMMAND TEMPLATE TITLE", utils.PtrString(command.CommandTemplateTitle))
table.AddSeparator()
table.AddRow("STATUS", *command.Status)
table.AddRow("STATUS", utils.PtrString(command.Status))
table.AddSeparator()
table.AddRow("STARTED AT", *command.StartedAt)
table.AddRow("STARTED AT", utils.PtrString(command.StartedAt))
table.AddSeparator()
table.AddRow("FINISHED AT", *command.FinishedAt)
table.AddRow("FINISHED AT", utils.PtrString(command.FinishedAt))
table.AddSeparator()
table.AddRow("EXIT CODE", *command.ExitCode)
table.AddRow("EXIT CODE", utils.PtrString(command.ExitCode))
table.AddSeparator()
table.AddRow("COMMAND SCRIPT", *command.Script)
table.AddRow("COMMAND SCRIPT", utils.PtrString(command.Script))
table.AddSeparator()
table.AddRow("COMMAND OUTPUT", *command.Output)
table.AddRow("COMMAND OUTPUT", utils.PtrString(command.Output))
table.AddSeparator()

@@ -153,0 +153,0 @@ err := table.Display(p)

@@ -9,3 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/runcommand"

@@ -142,3 +141,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(commands, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(commands, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -155,3 +154,10 @@ return fmt.Errorf("marshal server command list: %w", err)

s := commands[i]
table.AddRow(*s.Id, *s.CommandTemplateName, *s.CommandTemplateTitle, *s.Status, *s.StartedAt, *s.FinishedAt)
table.AddRow(
utils.PtrString(s.Id),
utils.PtrString(s.CommandTemplateName),
utils.PtrString(s.CommandTemplateTitle),
utils.PtrString(s.Status),
utils.PtrString(s.StartedAt),
utils.PtrString(s.FinishedAt),
)
}

@@ -158,0 +164,0 @@ err := table.Display(p)

@@ -10,2 +10,3 @@ package describe

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/runcommand"

@@ -125,3 +125,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(commandTemplate, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(commandTemplate, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -135,10 +135,12 @@ return fmt.Errorf("marshal server command template: %w", err)

table := tables.NewTable()
table.AddRow("NAME", *commandTemplate.Name)
table.AddRow("NAME", utils.PtrString(commandTemplate.Name))
table.AddSeparator()
table.AddRow("TITLE", *commandTemplate.Title)
table.AddRow("TITLE", utils.PtrString(commandTemplate.Title))
table.AddSeparator()
table.AddRow("DESCRIPTION", *commandTemplate.Description)
table.AddRow("DESCRIPTION", utils.PtrString(commandTemplate.Description))
table.AddSeparator()
table.AddRow("OS TYPE", strings.Join(*commandTemplate.OsType, "\n"))
table.AddSeparator()
if commandTemplate.OsType != nil {
table.AddRow("OS TYPE", strings.Join(*commandTemplate.OsType, "\n"))
table.AddSeparator()
}
if commandTemplate.ParameterSchema != nil {

@@ -145,0 +147,0 @@ table.AddRow("PARAMS", *commandTemplate.ParameterSchema)

@@ -7,6 +7,5 @@ package list

"fmt"
"strings"
"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -20,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/runcommand"

@@ -136,3 +134,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(templates, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(templates, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -149,3 +147,13 @@ return fmt.Errorf("marshal server command template list: %w", err)

s := templates[i]
table.AddRow(*s.Name, strings.Join(*s.OsType, ","), *s.Title)
var osType string
if s.OsType != nil && len(*s.OsType) > 0 {
osType = utils.JoinStringPtr(s.OsType, ",")
}
table.AddRow(
utils.PtrString(s.Name),
osType,
utils.PtrString(s.Title),
)
}

@@ -152,0 +160,0 @@ err := table.Display(p)

@@ -122,3 +122,3 @@ package console

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(serverUrl, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(serverUrl, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -131,2 +131,5 @@ return fmt.Errorf("marshal url: %w", err)

default:
if serverUrl.GetUrl() == nil {
return fmt.Errorf("server url is nil")
}
// unescape url in order to get rid of e.g. %40

@@ -133,0 +136,0 @@ unescapedURL, err := url.PathUnescape(*serverUrl.GetUrl())

@@ -348,3 +348,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(server, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(server, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -357,5 +357,5 @@ return fmt.Errorf("marshal server: %w", err)

default:
p.Outputf("Created server for project %q.\nServer ID: %s\n", projectLabel, *server.Id)
p.Outputf("Created server for project %q.\nServer ID: %s\n", projectLabel, utils.PtrString(server.Id))
return nil
}
}

@@ -119,3 +119,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(server, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(server, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -133,9 +133,9 @@ return fmt.Errorf("marshal server: %w", err)

table.AddRow("ID", *server.Id)
table.AddRow("ID", utils.PtrString(server.Id))
table.AddSeparator()
table.AddRow("NAME", *server.Name)
table.AddRow("NAME", utils.PtrString(server.Name))
table.AddSeparator()
table.AddRow("STATE", *server.Status)
table.AddRow("STATE", utils.PtrString(server.Status))
table.AddSeparator()
table.AddRow("AVAILABILITY ZONE", *server.AvailabilityZone)
table.AddRow("AVAILABILITY ZONE", utils.PtrString(server.AvailabilityZone))
table.AddSeparator()

@@ -146,3 +146,3 @@ if server.BootVolume != nil && server.BootVolume.Id != nil {

}
table.AddRow("POWER STATUS", *server.PowerStatus)
table.AddRow("POWER STATUS", utils.PtrString(server.PowerStatus))
table.AddSeparator()

@@ -149,0 +149,0 @@

@@ -160,3 +160,3 @@ package list

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(servers, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(servers, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -163,0 +163,0 @@ return fmt.Errorf("marshal server: %w", err)

@@ -154,3 +154,3 @@ package log

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(log, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(log, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -157,0 +157,0 @@ return fmt.Errorf("marshal url: %w", err)

@@ -114,3 +114,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(machineType, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(machineType, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -117,0 +117,0 @@ return fmt.Errorf("marshal server machine type: %w", err)

@@ -148,3 +148,3 @@ package list

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(machineTypes, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(machineTypes, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -151,0 +151,0 @@ return fmt.Errorf("marshal machineTypes: %w", err)

@@ -17,2 +17,3 @@ package attach

iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"

@@ -110,3 +111,3 @@ )

}
p.Info("Attached network interface %q to server %q\n", *model.NicId, serverLabel)
p.Info("Attached network interface %q to server %q\n", utils.PtrString(model.NicId), serverLabel)

@@ -113,0 +114,0 @@ return nil

@@ -17,2 +17,3 @@ package detach

iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"

@@ -110,3 +111,3 @@ )

}
p.Info("Detached network interface %q from server %q\n", *model.NicId, serverLabel)
p.Info("Detached network interface %q from server %q\n", utils.PtrString(model.NicId), serverLabel)

@@ -113,0 +114,0 @@ return nil

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,5 +20,4 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
"github.com/spf13/cobra"
)

@@ -154,3 +154,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(serverNics, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(serverNics, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -168,3 +168,3 @@ return fmt.Errorf("marshal server network interfaces: %w", err)

nic := serverNics[i]
table.AddRow(*nic.Id, serverId)
table.AddRow(utils.PtrString(nic.Id), serverId)
}

@@ -171,0 +171,0 @@ table.EnableAutoMergeOnColumns(2)

@@ -16,2 +16,3 @@ package create

"github.com/stackitcloud/stackit-cli/internal/pkg/services/serverosupdate/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -137,3 +138,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -146,5 +147,5 @@ return fmt.Errorf("marshal server os-update: %w", err)

default:
p.Outputf("Triggered creation of server os-update for server %s. Update ID: %d\n", model.ServerId, *resp.Id)
p.Outputf("Triggered creation of server os-update for server %s. Update ID: %s\n", model.ServerId, utils.PtrString(resp.Id))
return nil
}
}

@@ -9,2 +9,3 @@ package describe

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/serverupdate"

@@ -124,3 +124,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(update, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(update, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -134,24 +134,15 @@ return fmt.Errorf("marshal server update: %w", err)

table := tables.NewTable()
table.AddRow("ID", *update.Id)
table.AddRow("ID", utils.PtrString(update.Id))
table.AddSeparator()
table.AddRow("STATUS", *update.Status)
table.AddRow("STATUS", utils.PtrString(update.Status))
table.AddSeparator()
if update.InstalledUpdates != nil {
table.AddRow("INSTALLED UPDATES", *update.InstalledUpdates)
} else {
table.AddRow("INSTALLED UPDATES", "...")
}
installedUpdates := utils.PtrStringDefault(update.InstalledUpdates, "n/a")
table.AddRow("INSTALLED UPDATES", installedUpdates)
table.AddSeparator()
if update.FailedUpdates != nil {
table.AddRow("FAILED UPDATES", *update.FailedUpdates)
} else {
table.AddRow("FAILED UPDATES", "...")
}
table.AddRow("START DATE", *update.StartDate)
failedUpdates := utils.PtrStringDefault(update.FailedUpdates, "n/a")
table.AddRow("FAILED UPDATES", failedUpdates)
table.AddRow("START DATE", utils.PtrString(update.StartDate))
table.AddSeparator()
if update.EndDate != nil {
table.AddRow("END DATE", *update.EndDate)
} else {
table.AddRow("END DATE", "...")
}
table.AddRow("END DATE", utils.PtrString(update.EndDate))
table.AddSeparator()

@@ -158,0 +149,0 @@

@@ -9,4 +9,2 @@ package list

"github.com/goccy/go-yaml"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -20,3 +18,5 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/goccy/go-yaml"
"github.com/spf13/cobra"

@@ -143,3 +143,3 @@ "github.com/stackitcloud/stackit-sdk-go/services/serverupdate"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(updates, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(updates, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -157,8 +157,5 @@ return fmt.Errorf("marshal server os-update list: %w", err)

endDate := "..."
if s.EndDate != nil {
endDate = *s.EndDate
}
endDate := utils.PtrStringDefault(s.EndDate, "n/a")
installed := "..."
installed := "n/a"
if s.InstalledUpdates != nil {

@@ -168,3 +165,3 @@ installed = strconv.FormatInt(*s.InstalledUpdates, 10)

failed := "..."
failed := "n/a"
if s.FailedUpdates != nil {

@@ -174,3 +171,10 @@ failed = strconv.FormatInt(*s.FailedUpdates, 10)

table.AddRow(*s.Id, *s.Status, installed, failed, *s.StartDate, endDate)
table.AddRow(
utils.PtrString(s.Id),
utils.PtrString(s.Status),
installed,
failed,
utils.PtrString(s.StartDate),
endDate,
)
}

@@ -177,0 +181,0 @@ err := table.Display(p)

@@ -16,2 +16,3 @@ package create

"github.com/stackitcloud/stackit-cli/internal/pkg/services/serverosupdate/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -157,3 +158,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -166,5 +167,5 @@ return fmt.Errorf("marshal server os-update schedule: %w", err)

default:
p.Outputf("Created server os-update schedule for server %s. os-update Schedule ID: %d\n", model.ServerId, *resp.Id)
p.Outputf("Created server os-update schedule for server %s. os-update Schedule ID: %s\n", model.ServerId, utils.PtrString(resp.Id))
return nil
}
}

@@ -9,2 +9,3 @@ package describe

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/serverupdate"

@@ -124,3 +124,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(schedule, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(schedule, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -134,11 +134,11 @@ return fmt.Errorf("marshal server os-update schedule: %w", err)

table := tables.NewTable()
table.AddRow("SCHEDULE ID", *schedule.Id)
table.AddRow("SCHEDULE ID", utils.PtrString(schedule.Id))
table.AddSeparator()
table.AddRow("SCHEDULE NAME", *schedule.Name)
table.AddRow("SCHEDULE NAME", utils.PtrString(schedule.Name))
table.AddSeparator()
table.AddRow("ENABLED", *schedule.Enabled)
table.AddRow("ENABLED", utils.PtrString(schedule.Enabled))
table.AddSeparator()
table.AddRow("RRULE", *schedule.Rrule)
table.AddRow("RRULE", utils.PtrString(schedule.Rrule))
table.AddSeparator()
table.AddRow("MAINTENANCE WINDOW", *schedule.MaintenanceWindow)
table.AddRow("MAINTENANCE WINDOW", utils.PtrString(schedule.MaintenanceWindow))
table.AddSeparator()

@@ -145,0 +145,0 @@

@@ -9,3 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/serverupdate"

@@ -142,3 +141,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(schedules, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(schedules, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -155,3 +154,9 @@ return fmt.Errorf("marshal Server os-update Schedules list: %w", err)

s := schedules[i]
table.AddRow(*s.Id, *s.Name, *s.Enabled, *s.Rrule, *s.MaintenanceWindow)
table.AddRow(
utils.PtrString(s.Id),
utils.PtrString(s.Name),
utils.PtrString(s.Enabled),
utils.PtrString(s.Rrule),
utils.PtrString(s.MaintenanceWindow),
)
}

@@ -158,0 +163,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package update

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -17,4 +18,3 @@ cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/services/serverosupdate/client"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/serverupdate"

@@ -182,3 +182,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -191,5 +191,5 @@ return fmt.Errorf("marshal update server os-update schedule: %w", err)

default:
p.Info("Updated server os-update schedule %d\n", *resp.Id)
p.Info("Updated server os-update schedule %s\n", utils.PtrString(resp.Id))
return nil
}
}

@@ -96,3 +96,3 @@ package rescue

}
p.Info("%s server %q. Image %q is used as temporary boot image\n", operationState, serverLabel, *model.ImageId)
p.Info("%s server %q. Image %q is used as temporary boot image\n", operationState, serverLabel, utils.PtrString(model.ImageId))

@@ -99,0 +99,0 @@ return nil

@@ -134,3 +134,3 @@ package attach

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(serviceAccounts, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(serviceAccounts, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -137,0 +137,0 @@ return fmt.Errorf("marshal service account: %w", err)

@@ -134,3 +134,3 @@ package detach

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(service, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(service, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -137,0 +137,0 @@ return fmt.Errorf("marshal service account: %w", err)

@@ -151,3 +151,3 @@ package list

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(serviceAccounts, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(serviceAccounts, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -154,0 +154,0 @@ return fmt.Errorf("marshal service accounts list: %w", err)

@@ -157,3 +157,3 @@ package update

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(server, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(server, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -160,0 +160,0 @@ return fmt.Errorf("marshal server: %w", err)

@@ -157,3 +157,3 @@ package attach

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -160,0 +160,0 @@ return fmt.Errorf("marshal server volume: %w", err)

@@ -141,3 +141,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -151,7 +151,7 @@ return fmt.Errorf("marshal server volume: %w", err)

table := tables.NewTable()
table.AddRow("SERVER ID", *volume.ServerId)
table.AddRow("SERVER ID", utils.PtrString(volume.ServerId))
table.AddSeparator()
table.AddRow("SERVER NAME", serverLabel)
table.AddSeparator()
table.AddRow("VOLUME ID", *volume.VolumeId)
table.AddRow("VOLUME ID", utils.PtrString(volume.VolumeId))
table.AddSeparator()

@@ -158,0 +158,0 @@ // check if name is set

@@ -9,3 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -20,5 +20,4 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
"github.com/spf13/cobra"
)

@@ -143,3 +142,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(volumes, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(volumes, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -156,3 +155,3 @@ return fmt.Errorf("marshal server volume list: %w", err)

s := volumes[i]
table.AddRow(*s.ServerId, serverLabel, *s.VolumeId, volumeNames[i])
table.AddRow(utils.PtrString(s.ServerId), serverLabel, utils.PtrString(s.VolumeId), volumeNames[i])
}

@@ -159,0 +158,0 @@ err := table.Display(p)

@@ -153,3 +153,3 @@ package update

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -156,0 +156,0 @@ return fmt.Errorf("marshal server volume: %w", err)

@@ -146,3 +146,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -149,0 +149,0 @@ return fmt.Errorf("marshal SQLServer Flex database: %w", err)

@@ -9,2 +9,3 @@ package describe

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,5 +19,4 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex"
"github.com/spf13/cobra"
)

@@ -125,3 +125,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(database, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(database, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -136,5 +136,5 @@ return fmt.Errorf("marshal SQLServer Flex database: %w", err)

table := tables.NewTable()
table.AddRow("ID", *database.Id)
table.AddRow("ID", utils.PtrString(database.Id))
table.AddSeparator()
table.AddRow("NAME", *database.Name)
table.AddRow("NAME", utils.PtrString(database.Name))
table.AddSeparator()

@@ -141,0 +141,0 @@ if database.Options != nil {

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,5 +20,4 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex"
"github.com/spf13/cobra"
)

@@ -152,3 +152,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(databases, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(databases, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -165,3 +165,3 @@ return fmt.Errorf("marshal SQLServer Flex database list: %w", err)

database := databases[i]
table.AddRow(*database.Id, *database.Name)
table.AddRow(utils.PtrString(database.Id), utils.PtrString(database.Name))
}

@@ -168,0 +168,0 @@ err := table.Display(p)

@@ -275,3 +275,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -288,5 +288,5 @@ return fmt.Errorf("marshal SQLServerFlex instance: %w", err)

}
p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, *resp.Id)
p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Id))
return nil
}
}

@@ -112,3 +112,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -121,25 +121,28 @@ return fmt.Errorf("marshal SQLServer Flex instance: %w", err)

default:
aclsArray := *instance.Acl.Items
acls := strings.Join(aclsArray, ",")
var acls string
if instance.Acl != nil && instance.Acl.HasItems() {
aclsArray := *instance.Acl.Items
acls = strings.Join(aclsArray, ",")
}
table := tables.NewTable()
table.AddRow("ID", *instance.Id)
table.AddRow("ID", utils.PtrString(instance.Id))
table.AddSeparator()
table.AddRow("NAME", *instance.Name)
table.AddRow("NAME", utils.PtrString(instance.Name))
table.AddSeparator()
table.AddRow("STATUS", *instance.Status)
table.AddRow("STATUS", utils.PtrString(instance.Status))
table.AddSeparator()
table.AddRow("STORAGE SIZE (GB)", *instance.Storage.Size)
table.AddRow("STORAGE SIZE (GB)", utils.PtrString(instance.Storage.Size))
table.AddSeparator()
table.AddRow("VERSION", *instance.Version)
table.AddRow("VERSION", utils.PtrString(instance.Version))
table.AddSeparator()
table.AddRow("BACKUP SCHEDULE (UTC)", *instance.BackupSchedule)
table.AddRow("BACKUP SCHEDULE (UTC)", utils.PtrString(instance.BackupSchedule))
table.AddSeparator()
table.AddRow("ACL", acls)
table.AddSeparator()
table.AddRow("FLAVOR DESCRIPTION", *instance.Flavor.Description)
table.AddRow("FLAVOR DESCRIPTION", utils.PtrString(instance.Flavor.Description))
table.AddSeparator()
table.AddRow("CPU", *instance.Flavor.Cpu)
table.AddRow("CPU", utils.PtrString(instance.Flavor.Cpu))
table.AddSeparator()
table.AddRow("RAM (GB)", *instance.Flavor.Memory)
table.AddRow("RAM (GB)", utils.PtrString(instance.Flavor.Memory))
table.AddSeparator()

@@ -146,0 +149,0 @@

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex"

@@ -145,3 +145,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -158,3 +158,7 @@ return fmt.Errorf("marshal SQLServer Flex instance list: %w", err)

instance := instances[i]
table.AddRow(*instance.Id, *instance.Name, *instance.Status)
table.AddRow(
utils.PtrString(instance.Id),
utils.PtrString(instance.Name),
utils.PtrString(instance.Status),
)
}

@@ -161,0 +165,0 @@ err := table.Display(p)

@@ -260,3 +260,3 @@ package update

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -263,0 +263,0 @@ return fmt.Errorf("marshal update SQLServerFlex instance: %w", err)

@@ -290,3 +290,3 @@ package options

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(options, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(options, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -293,0 +293,0 @@ return fmt.Errorf("marshal SQL Server Flex options: %w", err)

@@ -19,2 +19,3 @@ package create

sqlserverflexUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/sqlserverflex/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex"

@@ -157,3 +158,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -166,5 +167,5 @@ return fmt.Errorf("marshal SQLServer Flex user: %w", err)

default:
p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, *user.Id)
p.Outputf("Username: %s\n", *user.Username)
p.Outputf("Password: %s\n", *user.Password)
p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, utils.PtrString(user.Id))
p.Outputf("Username: %s\n", utils.PtrString(user.Username))
p.Outputf("Password: %s\n", utils.PtrString(user.Password))
if user.Roles != nil && len(*user.Roles) != 0 {

@@ -171,0 +172,0 @@ p.Outputf("Roles: [%v]\n", strings.Join(*user.Roles, ", "))

@@ -18,2 +18,3 @@ package describe

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -132,3 +133,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -142,5 +143,5 @@ return fmt.Errorf("marshal SQLServer Flex user: %w", err)

table := tables.NewTable()
table.AddRow("ID", *user.Id)
table.AddRow("ID", utils.PtrString(user.Id))
table.AddSeparator()
table.AddRow("USERNAME", *user.Username)
table.AddRow("USERNAME", utils.PtrString(user.Username))
if user.Roles != nil && len(*user.Roles) != 0 {

@@ -147,0 +148,0 @@ table.AddSeparator()

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex"

@@ -153,3 +153,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(users, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(users, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -166,3 +166,6 @@ return fmt.Errorf("marshal SQLServer Flex user list: %w", err)

user := users[i]
table.AddRow(*user.Id, *user.Username)
table.AddRow(
utils.PtrString(user.Id),
utils.PtrString(user.Username),
)
}

@@ -169,0 +172,0 @@ err := table.Display(p)

@@ -17,2 +17,3 @@ package resetpassword

sqlserverflexUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/sqlserverflex/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -147,3 +148,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -157,4 +158,4 @@ return fmt.Errorf("marshal SQLServer Flex reset password: %w", err)

p.Outputf("Reset password for user %q of instance %q\n\n", userLabel, instanceLabel)
p.Outputf("Username: %s\n", *user.Username)
p.Outputf("New password: %s\n", *user.Password)
p.Outputf("Username: %s\n", utils.PtrString(user.Username))
p.Outputf("New password: %s\n", utils.PtrString(user.Password))
if user.Uri != nil && *user.Uri != "" {

@@ -161,0 +162,0 @@ p.Outputf("New URI: %s\n", *user.Uri)

@@ -212,3 +212,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -221,5 +221,5 @@ return fmt.Errorf("marshal volume: %w", err)

default:
p.Outputf("Created volume for project %q.\nVolume ID: %s\n", projectLabel, *volume.Id)
p.Outputf("Created volume for project %q.\nVolume ID: %s\n", projectLabel, utils.PtrString(volume.Id))
return nil
}
}

@@ -115,3 +115,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -125,13 +125,13 @@ return fmt.Errorf("marshal volume: %w", err)

table := tables.NewTable()
table.AddRow("ID", *volume.Id)
table.AddRow("ID", utils.PtrString(volume.Id))
table.AddSeparator()
table.AddRow("NAME", *volume.Name)
table.AddRow("NAME", utils.PtrString(volume.Name))
table.AddSeparator()
table.AddRow("STATE", *volume.Status)
table.AddRow("STATE", utils.PtrString(volume.Status))
table.AddSeparator()
table.AddRow("VOLUME SIZE (GB)", *volume.Size)
table.AddRow("VOLUME SIZE (GB)", utils.PtrString(volume.Size))
table.AddSeparator()
table.AddRow("PERFORMANCE CLASS", *volume.PerformanceClass)
table.AddRow("PERFORMANCE CLASS", utils.PtrString(volume.PerformanceClass))
table.AddSeparator()
table.AddRow("AVAILABILITY ZONE", *volume.AvailabilityZone)
table.AddRow("AVAILABILITY ZONE", utils.PtrString(volume.AvailabilityZone))
table.AddSeparator()

@@ -138,0 +138,0 @@

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,5 +20,4 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
"github.com/spf13/cobra"
)

@@ -160,3 +160,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(volumes, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(volumes, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -173,7 +173,10 @@ return fmt.Errorf("marshal volume: %w", err)

for _, volume := range volumes {
serverId := ""
if volume.ServerId != nil {
serverId = *volume.ServerId
}
table.AddRow(*volume.Id, *volume.Name, *volume.Status, serverId, *volume.AvailabilityZone, *volume.Size)
table.AddRow(
utils.PtrString(volume.Id),
utils.PtrString(volume.Name),
utils.PtrString(volume.Status),
utils.PtrString(volume.ServerId),
utils.PtrString(volume.AvailabilityZone),
utils.PtrString(volume.Size),
)
table.AddSeparator()

@@ -180,0 +183,0 @@ }

@@ -115,3 +115,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(performanceClass, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(performanceClass, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -125,3 +125,3 @@ return fmt.Errorf("marshal volume performance class: %w", err)

table := tables.NewTable()
table.AddRow("NAME", *performanceClass.Name)
table.AddRow("NAME", utils.PtrString(performanceClass.Name))
table.AddSeparator()

@@ -128,0 +128,0 @@ table.AddRow("DESCRIPTION", utils.PtrString(performanceClass.Description))

@@ -18,2 +18,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"

@@ -159,3 +160,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(performanceClasses, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(performanceClasses, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -172,3 +173,3 @@ return fmt.Errorf("marshal volume performance class: %w", err)

for _, performanceClass := range performanceClasses {
table.AddRow(*performanceClass.Name, *performanceClass.Description)
table.AddRow(utils.PtrString(performanceClass.Name), utils.PtrString(performanceClass.Description))
table.AddSeparator()

@@ -175,0 +176,0 @@ }

@@ -166,3 +166,3 @@ package update

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(volume, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -169,0 +169,0 @@ return fmt.Errorf("marshal volume: %w", err)

@@ -87,3 +87,3 @@ package list

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(configData, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(configData, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -90,0 +90,0 @@ return fmt.Errorf("marshal config list: %w", err)

@@ -103,3 +103,3 @@ package list

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(profiles, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(profiles, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -106,0 +106,0 @@ return fmt.Errorf("marshal config list: %w", err)

@@ -194,3 +194,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -207,5 +207,5 @@ return fmt.Errorf("marshal DNS record-set: %w", err)

}
p.Outputf("%s record set for zone %s. Record set ID: %s\n", operationState, zoneLabel, *resp.Rrset.Id)
p.Outputf("%s record set for zone %s. Record set ID: %s\n", operationState, zoneLabel, utils.PtrString(resp.Rrset.Id))
return nil
}
}

@@ -127,3 +127,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(recordSet, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(recordSet, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -143,11 +143,11 @@ return fmt.Errorf("marshal DNS record set: %w", err)

table := tables.NewTable()
table.AddRow("ID", *recordSet.Id)
table.AddRow("ID", utils.PtrString(recordSet.Id))
table.AddSeparator()
table.AddRow("NAME", *recordSet.Name)
table.AddRow("NAME", utils.PtrString(recordSet.Name))
table.AddSeparator()
table.AddRow("STATE", *recordSet.State)
table.AddRow("STATE", utils.PtrString(recordSet.State))
table.AddSeparator()
table.AddRow("TTL", *recordSet.Ttl)
table.AddRow("TTL", utils.PtrString(recordSet.Ttl))
table.AddSeparator()
table.AddRow("TYPE", *recordSet.Type)
table.AddRow("TYPE", utils.PtrString(recordSet.Type))
table.AddSeparator()

@@ -154,0 +154,0 @@ table.AddRow("RECORDS DATA", recordsDataJoin)

@@ -11,2 +11,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -21,4 +22,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/dns"

@@ -264,3 +264,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(recordSets, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(recordSets, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -282,3 +282,10 @@ return fmt.Errorf("marshal DNS record set list: %w", err)

recordDataJoin := strings.Join(recordData, ", ")
table.AddRow(*rs.Id, *rs.Name, *rs.State, *rs.Ttl, *rs.Type, recordDataJoin)
table.AddRow(
utils.PtrString(rs.Id),
utils.PtrString(rs.Name),
utils.PtrString(rs.State),
utils.PtrString(rs.Ttl),
utils.PtrString(rs.Type),
recordDataJoin,
)
}

@@ -285,0 +292,0 @@ err := table.Display(p)

@@ -173,3 +173,3 @@ package clone

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -186,5 +186,5 @@ return fmt.Errorf("marshal DNS zone: %w", err)

}
p.Outputf("%s zone for project %q. Zone ID: %s\n", operationState, projectLabel, *resp.Zone.Id)
p.Outputf("%s zone for project %q. Zone ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Zone.Id))
return nil
}
}

@@ -18,2 +18,3 @@ package create

"github.com/stackitcloud/stackit-cli/internal/pkg/spinner"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -210,3 +211,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -223,5 +224,5 @@ return fmt.Errorf("marshal DNS zone: %w", err)

}
p.Outputf("%s zone for project %q. Zone ID: %s\n", operationState, projectLabel, *resp.Zone.Id)
p.Outputf("%s zone for project %q. Zone ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Zone.Id))
return nil
}
}

@@ -112,3 +112,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(zone, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(zone, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -122,31 +122,31 @@ return fmt.Errorf("marshal DNS zone: %w", err)

table := tables.NewTable()
table.AddRow("ID", *zone.Id)
table.AddRow("ID", utils.PtrString(zone.Id))
table.AddSeparator()
table.AddRow("NAME", *zone.Name)
table.AddRow("NAME", utils.PtrString(zone.Name))
table.AddSeparator()
table.AddRow("DESCRIPTION", *zone.Description)
table.AddRow("DESCRIPTION", utils.PtrString(zone.Description))
table.AddSeparator()
table.AddRow("STATE", *zone.State)
table.AddRow("STATE", utils.PtrString(zone.State))
table.AddSeparator()
table.AddRow("TYPE", *zone.Type)
table.AddRow("TYPE", utils.PtrString(zone.Type))
table.AddSeparator()
table.AddRow("DNS NAME", *zone.DnsName)
table.AddRow("DNS NAME", utils.PtrString(zone.DnsName))
table.AddSeparator()
table.AddRow("REVERSE ZONE", *zone.IsReverseZone)
table.AddRow("REVERSE ZONE", utils.PtrString(zone.IsReverseZone))
table.AddSeparator()
table.AddRow("RECORD COUNT", *zone.RecordCount)
table.AddRow("RECORD COUNT", utils.PtrString(zone.RecordCount))
table.AddSeparator()
table.AddRow("CONTACT EMAIL", *zone.ContactEmail)
table.AddRow("CONTACT EMAIL", utils.PtrString(zone.ContactEmail))
table.AddSeparator()
table.AddRow("DEFAULT TTL", *zone.DefaultTTL)
table.AddRow("DEFAULT TTL", utils.PtrString(zone.DefaultTTL))
table.AddSeparator()
table.AddRow("SERIAL NUMBER", *zone.SerialNumber)
table.AddRow("SERIAL NUMBER", utils.PtrString(zone.SerialNumber))
table.AddSeparator()
table.AddRow("REFRESH TIME", *zone.RefreshTime)
table.AddRow("REFRESH TIME", utils.PtrString(zone.RefreshTime))
table.AddSeparator()
table.AddRow("RETRY TIME", *zone.RetryTime)
table.AddRow("RETRY TIME", utils.PtrString(zone.RetryTime))
table.AddSeparator()
table.AddRow("EXPIRE TIME", *zone.ExpireTime)
table.AddRow("EXPIRE TIME", utils.PtrString(zone.ExpireTime))
table.AddSeparator()
table.AddRow("NEGATIVE CACHE", *zone.NegativeCache)
table.AddRow("NEGATIVE CACHE", utils.PtrString(zone.NegativeCache))
err := table.Display(p)

@@ -153,0 +153,0 @@ if err != nil {

@@ -20,2 +20,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -252,3 +253,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(zones, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(zones, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -265,3 +266,9 @@ return fmt.Errorf("marshal DNS zone list: %w", err)

z := zones[i]
table.AddRow(*z.Id, *z.Name, *z.State, *z.Type, *z.DnsName, *z.RecordCount)
table.AddRow(utils.PtrString(z.Id),
utils.PtrString(z.Name),
utils.PtrString(z.State),
utils.PtrString(z.Type),
utils.PtrString(z.DnsName),
utils.PtrString(z.RecordCount),
)
}

@@ -268,0 +275,0 @@ err := table.Display(p)

@@ -9,6 +9,3 @@ package create

"github.com/google/uuid"
"github.com/stackitcloud/stackit-cli/internal/pkg/projectname"
"github.com/stackitcloud/stackit-sdk-go/services/loadbalancer"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -20,6 +17,7 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/projectname"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/spinner"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/loadbalancer"
"github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/wait"

@@ -113,3 +111,3 @@ )

}
p.Outputf("%s load balancer with name %q \n", operationState, *model.Payload.Name)
p.Outputf("%s load balancer with name %q \n", operationState, utils.PtrString(model.Payload.Name))
return nil

@@ -116,0 +114,0 @@ },

@@ -17,2 +17,3 @@ package describe

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -112,3 +113,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(loadBalancer, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(loadBalancer, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -165,6 +166,3 @@ return fmt.Errorf("marshal load balancer: %w", err)

externalAdress := "-"
if loadBalancer.ExternalAddress != nil {
externalAdress = *loadBalancer.ExternalAddress
}
externalAddress := utils.PtrStringDefault(loadBalancer.ExternalAddress, "-")

@@ -180,5 +178,5 @@ errorDescriptions := []string{}

table.SetTitle("Load Balancer")
table.AddRow("NAME", *loadBalancer.Name)
table.AddRow("NAME", utils.PtrString(loadBalancer.Name))
table.AddSeparator()
table.AddRow("STATE", *loadBalancer.Status)
table.AddRow("STATE", utils.PtrString(loadBalancer.Status))
table.AddSeparator()

@@ -191,3 +189,3 @@ if len(errorDescriptions) > 0 {

table.AddSeparator()
table.AddRow("ATTACHED PUBLIC IP", externalAdress)
table.AddRow("ATTACHED PUBLIC IP", externalAddress)
table.AddSeparator()

@@ -206,3 +204,8 @@ table.AddRow("ATTACHED NETWORK ID", networkId)

listener := listeners[i]
table.AddRow(*listener.Name, *listener.Port, *listener.Protocol, *listener.TargetPool)
table.AddRow(
utils.PtrString(listener.Name),
utils.PtrString(listener.Port),
utils.PtrString(listener.Protocol),
utils.PtrString(listener.TargetPool),
)
}

@@ -217,5 +220,5 @@ return table

for _, targetPool := range targetPools {
table.AddRow(*targetPool.Name, *targetPool.TargetPort, len(*targetPool.Targets))
table.AddRow(utils.PtrString(targetPool.Name), utils.PtrString(targetPool.TargetPort), len(*targetPool.Targets))
}
return table
}

@@ -18,2 +18,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -145,3 +146,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(loadBalancers, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(loadBalancers, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -158,7 +159,10 @@ return fmt.Errorf("marshal load balancer list: %w", err)

l := loadBalancers[i]
externalAdress := "-"
if l.ExternalAddress != nil {
externalAdress = *l.ExternalAddress
}
table.AddRow(*l.Name, *l.Status, externalAdress, len(*l.Listeners), len(*l.TargetPools))
externalAdress := utils.PtrStringDefault(l.ExternalAddress, "-")
table.AddRow(
utils.PtrString(l.Name),
utils.PtrString(l.Status),
externalAdress,
len(*l.Listeners),
len(*l.TargetPools),
)
}

@@ -165,0 +169,0 @@ err := table.Display(p)

@@ -162,3 +162,3 @@ package add

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -171,5 +171,5 @@ return fmt.Errorf("marshal Load Balancer observability credentials: %w", err)

default:
p.Outputf("Added Load Balancer observability credentials on project %q. Credentials reference: %q\n", projectLabel, *resp.Credential.CredentialsRef)
p.Outputf("Added Load Balancer observability credentials on project %q. Credentials reference: %q\n", projectLabel, utils.PtrString(resp.Credential.CredentialsRef))
return nil
}
}

@@ -16,2 +16,3 @@ package describe

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -109,3 +110,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -118,8 +119,13 @@ return fmt.Errorf("marshal Load Balancer observability credentials: %w", err)

default:
if credentials == nil || credentials.Credential == nil {
p.Info("No credentials found")
return nil
}
table := tables.NewTable()
table.AddRow("REFERENCE", *credentials.Credential.CredentialsRef)
table.AddRow("REFERENCE", utils.PtrString(credentials.Credential.CredentialsRef))
table.AddSeparator()
table.AddRow("DISPLAY NAME", *credentials.Credential.DisplayName)
table.AddRow("DISPLAY NAME", utils.PtrString(credentials.Credential.DisplayName))
table.AddSeparator()
table.AddRow("USERNAME", *credentials.Credential.Username)
table.AddRow("USERNAME", utils.PtrString(credentials.Credential.Username))
table.AddSeparator()

@@ -126,0 +132,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,6 +19,5 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/utils"
lbUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/loadbalancer"

@@ -97,3 +97,3 @@ )

}
credentials, err = utils.FilterCredentials(ctx, apiClient, credentials, model.ProjectId, filterOp)
credentials, err = lbUtils.FilterCredentials(ctx, apiClient, credentials, model.ProjectId, filterOp)
if err != nil {

@@ -183,3 +183,3 @@ return fmt.Errorf("filter credentials: %w", err)

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -196,3 +196,3 @@ return fmt.Errorf("marshal Load Balancer observability credentials list: %w", err)

c := credentials[i]
table.AddRow(*c.CredentialsRef, *c.DisplayName, *c.Username)
table.AddRow(utils.PtrString(c.CredentialsRef), utils.PtrString(c.DisplayName), utils.PtrString(c.Username))
}

@@ -215,10 +215,10 @@ err := table.Display(p)

if !used && !unused {
return utils.OP_FILTER_NOP, nil
return lbUtils.OP_FILTER_NOP, nil
}
if used {
return utils.OP_FILTER_USED, nil
return lbUtils.OP_FILTER_USED, nil
}
return utils.OP_FILTER_UNUSED, nil
return lbUtils.OP_FILTER_UNUSED, nil
}

@@ -101,3 +101,3 @@ package quota

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(quota, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(quota, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -104,0 +104,0 @@ return fmt.Errorf("marshal quota: %w", err)

@@ -11,2 +11,3 @@ package describe

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,6 +20,5 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/utils"
lbUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/loadbalancer"

@@ -72,3 +72,3 @@ )

targetPool := utils.FindLoadBalancerTargetPoolByName(*resp.TargetPools, model.TargetPoolName)
targetPool := lbUtils.FindLoadBalancerTargetPoolByName(*resp.TargetPools, model.TargetPoolName)
if targetPool == nil {

@@ -78,3 +78,3 @@ return fmt.Errorf("target pool not found")

listener := utils.FindLoadBalancerListenerByTargetPool(*resp.Listeners, *targetPool.Name)
listener := lbUtils.FindLoadBalancerListenerByTargetPool(*resp.Listeners, *targetPool.Name)

@@ -145,3 +145,3 @@ return outputResult(p, model.OutputFormat, *targetPool, listener)

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(output, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(output, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -191,3 +191,7 @@ return fmt.Errorf("marshal load balancer: %w", err)

if listener != nil {
listenerStr = fmt.Sprintf("%s (Port:%d, Protocol: %s)", *listener.Name, *listener.Port, *listener.Protocol)
listenerStr = fmt.Sprintf("%s (Port:%s, Protocol: %s)",
utils.PtrString(listener.Name),
utils.PtrString(listener.Port),
utils.PtrString(listener.Protocol),
)
}

@@ -194,0 +198,0 @@

@@ -139,3 +139,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -148,18 +148,19 @@ return fmt.Errorf("marshal LogMe credentials: %w", err)

default:
p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, *resp.Id)
p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, utils.PtrString(resp.Id))
// The username field cannot be set by the user so we only display it if it's not returned empty
username := *resp.Raw.Credentials.Username
if username != "" {
p.Outputf("Username: %s\n", *resp.Raw.Credentials.Username)
if resp.HasRaw() && resp.Raw.Credentials != nil {
if username := resp.Raw.Credentials.Username; username != nil && *username != "" {
p.Outputf("Username: %s\n", utils.PtrString(username))
}
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", utils.PtrString(resp.Raw.Credentials.Password))
}
p.Outputf("Host: %s\n", utils.PtrString(resp.Raw.Credentials.Host))
p.Outputf("Port: %s\n", utils.PtrString(resp.Raw.Credentials.Port))
}
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", *resp.Raw.Credentials.Password)
}
p.Outputf("Host: %s\n", *resp.Raw.Credentials.Host)
p.Outputf("Port: %d\n", *resp.Raw.Credentials.Port)
p.Outputf("URI: %s\n", *resp.Uri)
p.Outputf("URI: %s\n", utils.PtrString(resp.Uri))
return nil
}
}

@@ -125,3 +125,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -135,13 +135,16 @@ return fmt.Errorf("marshal LogMe credentials: %w", err)

table := tables.NewTable()
table.AddRow("ID", *credentials.Id)
table.AddRow("ID", utils.PtrString(credentials.Id))
table.AddSeparator()
// The username field cannot be set by the user so we only display it if it's not returned empty
username := *credentials.Raw.Credentials.Username
if username != "" {
table.AddRow("USERNAME", *credentials.Raw.Credentials.Username)
table.AddSeparator()
if raw := credentials.Raw; raw != nil {
if cred := raw.Credentials; cred != nil {
if username := cred.Username; username != nil && *username != "" {
table.AddRow("USERNAME", *username)
table.AddSeparator()
}
table.AddRow("PASSWORD", utils.PtrString(cred.Password))
table.AddSeparator()
table.AddRow("URI", utils.PtrString(cred.Uri))
}
}
table.AddRow("PASSWORD", *credentials.Raw.Credentials.Password)
table.AddSeparator()
table.AddRow("URI", *credentials.Raw.Credentials.Uri)
err := table.Display(p)

@@ -148,0 +151,0 @@ if err != nil {

@@ -18,2 +18,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -149,3 +150,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -162,3 +163,3 @@ return fmt.Errorf("marshal LogMe credentials list: %w", err)

c := credentials[i]
table.AddRow(*c.Id)
table.AddRow(utils.PtrString(c.Id))
}

@@ -165,0 +166,0 @@ err := table.Display(p)

@@ -265,3 +265,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -278,5 +278,5 @@ return fmt.Errorf("marshal LogMe instance: %w", err)

}
p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, *resp.InstanceId)
p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, utils.PtrString(resp.InstanceId))
return nil
}
}

@@ -113,3 +113,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -123,11 +123,11 @@ return fmt.Errorf("marshal LogMe instance: %w", err)

table := tables.NewTable()
table.AddRow("ID", *instance.InstanceId)
table.AddRow("ID", utils.PtrString(instance.InstanceId))
table.AddSeparator()
table.AddRow("NAME", *instance.Name)
table.AddRow("NAME", utils.PtrString(instance.Name))
table.AddSeparator()
table.AddRow("LAST OPERATION TYPE", *instance.LastOperation.Type)
table.AddRow("LAST OPERATION TYPE", utils.PtrString(instance.LastOperation.Type))
table.AddSeparator()
table.AddRow("LAST OPERATION STATE", *instance.LastOperation.State)
table.AddRow("LAST OPERATION STATE", utils.PtrString(instance.LastOperation.State))
table.AddSeparator()
table.AddRow("PLAN ID", *instance.PlanId)
table.AddRow("PLAN ID", utils.PtrString(instance.PlanId))
// Only show ACL if it's present and not empty

@@ -134,0 +134,0 @@ acl := (*instance.Parameters)[aclParameterKey]

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/logme"

@@ -145,3 +145,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -158,3 +158,8 @@ return fmt.Errorf("marshal LogMe instance list: %w", err)

instance := instances[i]
table.AddRow(*instance.InstanceId, *instance.Name, *instance.LastOperation.Type, *instance.LastOperation.State)
table.AddRow(
utils.PtrString(instance.InstanceId),
utils.PtrString(instance.Name),
utils.PtrString(instance.LastOperation.Type),
utils.PtrString(instance.LastOperation.State),
)
}

@@ -161,0 +166,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package plans

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/logme"

@@ -145,3 +145,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -160,3 +160,9 @@ return fmt.Errorf("marshal LogMe plans: %w", err)

p := (*o.Plans)[j]
table.AddRow(*o.Name, *o.Version, *p.Id, *p.Name, *p.Description)
table.AddRow(
utils.PtrString(o.Name),
utils.PtrString(o.Version),
utils.PtrString(p.Id),
utils.PtrString(p.Name),
utils.PtrString(p.Description),
)
}

@@ -163,0 +169,0 @@ table.AddSeparator()

@@ -140,3 +140,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -149,18 +149,19 @@ return fmt.Errorf("marshal MariaDB credentials list: %w", err)

default:
p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, *resp.Id)
p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, utils.PtrString(resp.Id))
// The username field cannot be set by the user, so we only display it if it's not returned empty
username := *resp.Raw.Credentials.Username
if username != "" {
p.Outputf("Username: %s\n", *resp.Raw.Credentials.Username)
if resp.HasRaw() && resp.Raw.Credentials != nil {
if username := resp.Raw.Credentials.Username; username != nil && *username != "" {
p.Outputf("Username: %s\n", *username)
}
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", utils.PtrString(resp.Raw.Credentials.Password))
}
p.Outputf("Host: %s\n", utils.PtrString(resp.Raw.Credentials.Host))
p.Outputf("Port: %s\n", utils.PtrString(resp.Raw.Credentials.Port))
}
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", *resp.Raw.Credentials.Password)
}
p.Outputf("Host: %s\n", *resp.Raw.Credentials.Host)
p.Outputf("Port: %d\n", *resp.Raw.Credentials.Port)
p.Outputf("URI: %s\n", *resp.Uri)
p.Outputf("URI: %s\n", utils.PtrString(resp.Uri))
return nil
}
}

@@ -125,3 +125,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -138,10 +138,11 @@ return fmt.Errorf("marshal MariaDB credentials: %w", err)

// The username field cannot be set by the user so we only display it if it's not returned empty
username := *credentials.Raw.Credentials.Username
if username != "" {
table.AddRow("USERNAME", *credentials.Raw.Credentials.Username)
if credentials.HasRaw() && credentials.Raw.Credentials != nil {
if username := credentials.Raw.Credentials.Username; username != nil && *username != "" {
table.AddRow("USERNAME", *username)
table.AddSeparator()
}
table.AddRow("PASSWORD", utils.PtrString(credentials.Raw.Credentials.Password))
table.AddSeparator()
table.AddRow("URI", utils.PtrString(credentials.Raw.Credentials.Uri))
}
table.AddRow("PASSWORD", *credentials.Raw.Credentials.Password)
table.AddSeparator()
table.AddRow("URI", *credentials.Raw.Credentials.Uri)
err := table.Display(p)

@@ -148,0 +149,0 @@ if err != nil {

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/mariadb"

@@ -150,3 +150,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -163,3 +163,3 @@ return fmt.Errorf("marshal MariaDB credentials list: %w", err)

c := credentials[i]
table.AddRow(*c.Id)
table.AddRow(utils.PtrString(c.Id))
}

@@ -166,0 +166,0 @@ err := table.Display(p)

@@ -265,3 +265,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -278,5 +278,5 @@ return fmt.Errorf("marshal MariaDB instance: %w", err)

}
p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, *resp.InstanceId)
p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, utils.PtrString(resp.InstanceId))
return nil
}
}

@@ -113,3 +113,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -123,11 +123,11 @@ return fmt.Errorf("marshal MariaDB instance: %w", err)

table := tables.NewTable()
table.AddRow("ID", *instance.InstanceId)
table.AddRow("ID", utils.PtrString(instance.InstanceId))
table.AddSeparator()
table.AddRow("NAME", *instance.Name)
table.AddRow("NAME", utils.PtrString(instance.Name))
table.AddSeparator()
table.AddRow("LAST OPERATION TYPE", *instance.LastOperation.Type)
table.AddRow("LAST OPERATION TYPE", utils.PtrString(instance.LastOperation.Type))
table.AddSeparator()
table.AddRow("LAST OPERATION STATE", *instance.LastOperation.State)
table.AddRow("LAST OPERATION STATE", utils.PtrString(instance.LastOperation.State))
table.AddSeparator()
table.AddRow("PLAN ID", *instance.PlanId)
table.AddRow("PLAN ID", utils.PtrString(instance.PlanId))
// Only show ACL if it's present and not empty

@@ -134,0 +134,0 @@ acl := (*instance.Parameters)[aclParameterKey]

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/mariadb"

@@ -145,3 +145,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -158,3 +158,8 @@ return fmt.Errorf("marshal MariaDB instance list: %w", err)

instance := instances[i]
table.AddRow(*instance.InstanceId, *instance.Name, *instance.LastOperation.Type, *instance.LastOperation.State)
table.AddRow(
utils.PtrString(instance.InstanceId),
utils.PtrString(instance.Name),
utils.PtrString(instance.LastOperation.Type),
utils.PtrString(instance.LastOperation.State),
)
}

@@ -161,0 +166,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package plans

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/mariadb"

@@ -145,3 +145,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -160,3 +160,9 @@ return fmt.Errorf("marshal MariaDB plans: %w", err)

plan := (*o.Plans)[j]
table.AddRow(*o.Name, *o.Version, *plan.Id, *plan.Name, *plan.Description)
table.AddRow(
utils.PtrString(o.Name),
utils.PtrString(o.Version),
utils.PtrString(plan.Id),
utils.PtrString(plan.Name),
utils.PtrString(plan.Description),
)
}

@@ -163,0 +169,0 @@ table.AddSeparator()

@@ -9,3 +9,2 @@ package describe

"github.com/goccy/go-yaml"
"github.com/inhies/go-bytesize"
"github.com/spf13/cobra"

@@ -19,4 +18,5 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/args"

"github.com/stackitcloud/stackit-cli/internal/pkg/services/mongodbflex/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/mongodbflex/utils"
mongoUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/mongodbflex/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"

@@ -65,3 +65,3 @@ )

instanceLabel, err := utils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId)
instanceLabel, err := mongoUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId)
if err != nil {

@@ -85,3 +85,3 @@ p.Debug(print.ErrorLevel, "get instance name: %v", err)

restoreJobState := utils.GetRestoreStatus(model.BackupId, restoreJobs)
restoreJobState := mongoUtils.GetRestoreStatus(model.BackupId, restoreJobs)
return outputResult(p, cmd, model.OutputFormat, restoreJobState, *resp.Item)

@@ -143,3 +143,3 @@ },

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(backup, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(backup, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -153,9 +153,10 @@ return fmt.Errorf("marshal MongoDB Flex backup: %w", err)

table := tables.NewTable()
table.AddRow("ID", *backup.Id)
table.AddRow("ID", utils.PtrString(backup.Id))
table.AddSeparator()
table.AddRow("CREATED AT", *backup.StartTime)
table.AddRow("CREATED AT", utils.PtrString(backup.StartTime))
table.AddSeparator()
table.AddRow("EXPIRES AT", *backup.EndTime)
table.AddRow("EXPIRES AT", utils.PtrString(backup.EndTime))
table.AddSeparator()
table.AddRow("BACKUP SIZE", bytesize.New(float64(*backup.Size)))
backupSize := utils.PtrByteSizeDefault(backup.Size, "n/a")
table.AddRow("BACKUP SIZE", backupSize)
table.AddSeparator()

@@ -162,0 +163,0 @@ table.AddRow("RESTORE STATUS", restoreStatus)

@@ -9,3 +9,2 @@ package list

"github.com/goccy/go-yaml"
"github.com/inhies/go-bytesize"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -20,2 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -160,3 +160,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(backups, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(backups, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -174,3 +174,9 @@ return fmt.Errorf("marshal MongoDB Flex backups list: %w", err)

restoreStatus := mongodbflexUtils.GetRestoreStatus(*backup.Id, restoreJobs)
table.AddRow(*backup.Id, *backup.StartTime, *backup.EndTime, bytesize.New(float64(*backup.Size)), restoreStatus)
backupSize := utils.PtrByteSizeDefault(backup.Size, "n/a")
table.AddRow(
utils.PtrString(backup.Id),
utils.PtrString(backup.StartTime),
utils.PtrString(backup.EndTime),
backupSize,
restoreStatus)
}

@@ -177,0 +183,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package restorejobs

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"

@@ -154,3 +154,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(restoreJobs, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(restoreJobs, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -168,3 +168,9 @@ return fmt.Errorf("marshal MongoDB Flex restore jobs list: %w", err)

table.AddRow(*restoreJob.Id, *restoreJob.BackupID, *restoreJob.InstanceId, *restoreJob.Date, *restoreJob.Status)
table.AddRow(
utils.PtrString(restoreJob.Id),
utils.PtrString(restoreJob.BackupID),
utils.PtrString(restoreJob.InstanceId),
utils.PtrString(restoreJob.Date),
utils.PtrString(restoreJob.Status),
)
}

@@ -171,0 +177,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package schedule

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"

@@ -135,3 +135,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(output, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(output, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -145,14 +145,16 @@ return fmt.Errorf("marshal MongoDB Flex backup schedule: %w", err)

table := tables.NewTable()
table.AddRow("BACKUP SCHEDULE (UTC)", *instance.BackupSchedule)
table.AddRow("BACKUP SCHEDULE (UTC)", utils.PtrString(instance.BackupSchedule))
table.AddSeparator()
table.AddRow("DAILY SNAPSHOT RETENTION (DAYS)", (*instance.Options)["dailySnapshotRetentionDays"])
table.AddSeparator()
table.AddRow("MONTHLY SNAPSHOT RETENTION (MONTHS)", (*instance.Options)["monthlySnapshotRetentionMonths"])
table.AddSeparator()
table.AddRow("POINT IN TIME WINDOW (HOURS)", (*instance.Options)["pointInTimeWindowHours"])
table.AddSeparator()
table.AddRow("SNAPSHOT RETENTION (DAYS)", (*instance.Options)["snapshotRetentionDays"])
table.AddSeparator()
table.AddRow("WEEKLY SNAPSHOT RETENTION (WEEKS)", (*instance.Options)["weeklySnapshotRetentionWeeks"])
table.AddSeparator()
if instance.Options != nil {
table.AddRow("DAILY SNAPSHOT RETENTION (DAYS)", (*instance.Options)["dailySnapshotRetentionDays"])
table.AddSeparator()
table.AddRow("MONTHLY SNAPSHOT RETENTION (MONTHS)", (*instance.Options)["monthlySnapshotRetentionMonths"])
table.AddSeparator()
table.AddRow("POINT IN TIME WINDOW (HOURS)", (*instance.Options)["pointInTimeWindowHours"])
table.AddSeparator()
table.AddRow("SNAPSHOT RETENTION (DAYS)", (*instance.Options)["snapshotRetentionDays"])
table.AddSeparator()
table.AddRow("WEEKLY SNAPSHOT RETENTION (WEEKS)", (*instance.Options)["weeklySnapshotRetentionWeeks"])
table.AddSeparator()
}
err := table.Display(p)

@@ -159,0 +161,0 @@ if err != nil {

@@ -287,3 +287,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -300,5 +300,5 @@ return fmt.Errorf("marshal MongoDBFlex instance: %w", err)

}
p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, *resp.Id)
p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Id))
return nil
}
}

@@ -113,3 +113,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -144,14 +144,20 @@ return fmt.Errorf("marshal MongoDB Flex instance: %w", err)

table.AddSeparator()
table.AddRow("FLAVOR DESCRIPTION", *instance.Flavor.Description)
table.AddSeparator()
if instance.HasFlavor() && instance.Flavor.HasDescription() {
table.AddRow("FLAVOR DESCRIPTION", *instance.Flavor.Description)
table.AddSeparator()
}
table.AddRow("TYPE", instanceType)
table.AddSeparator()
table.AddRow("REPLICAS", *instance.Replicas)
if instance.HasReplicas() {
table.AddRow("REPLICAS", *instance.Replicas)
table.AddSeparator()
}
if instance.HasFlavor() {
table.AddRow("CPU", utils.PtrString(instance.Flavor.Cpu))
table.AddSeparator()
table.AddRow("RAM (GB)", utils.PtrString(instance.Flavor.Memory))
table.AddSeparator()
}
table.AddRow("BACKUP SCHEDULE (UTC)", utils.PtrString(instance.BackupSchedule))
table.AddSeparator()
table.AddRow("CPU", *instance.Flavor.Cpu)
table.AddSeparator()
table.AddRow("RAM (GB)", *instance.Flavor.Memory)
table.AddSeparator()
table.AddRow("BACKUP SCHEDULE (UTC)", *instance.BackupSchedule)
table.AddSeparator()
err = table.Display(p)

@@ -158,0 +164,0 @@ if err != nil {

@@ -18,2 +18,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -144,3 +145,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -157,3 +158,7 @@ return fmt.Errorf("marshal MongoDB Flex instance list: %w", err)

instance := instances[i]
table.AddRow(*instance.Id, *instance.Name, *instance.Status)
table.AddRow(
utils.PtrString(instance.Id),
utils.PtrString(instance.Name),
utils.PtrString(instance.Status),
)
}

@@ -160,0 +165,0 @@ err := table.Display(p)

@@ -321,3 +321,3 @@ package update

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -324,0 +324,0 @@ return fmt.Errorf("marshal update MongoDBFlex instance: %w", err)

@@ -9,2 +9,3 @@ package options

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -17,4 +18,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/examples"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"

@@ -198,3 +198,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(options, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(options, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -237,3 +237,9 @@ return fmt.Errorf("marshal MongoDB Flex options: %w", err)

f := flavors[i]
table.AddRow(*f.Id, *f.Cpu, *f.Memory, *f.Description, *f.Categories)
table.AddRow(
utils.PtrString(f.Id),
utils.PtrString(f.Cpu),
utils.PtrString(f.Memory),
utils.PtrString(f.Description),
utils.PtrString(f.Categories),
)
}

@@ -261,3 +267,7 @@ return table

sc := storages[i]
table.AddRow(*storagesResp.StorageRange.Min, *storagesResp.StorageRange.Max, sc)
table.AddRow(
utils.PtrString(storagesResp.StorageRange.Min),
utils.PtrString(storagesResp.StorageRange.Max),
sc,
)
}

@@ -264,0 +274,0 @@ table.EnableAutoMergeOnColumns(1, 2, 3)

@@ -18,2 +18,3 @@ package create

mongodbflexUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/mongodbflex/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"

@@ -163,3 +164,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -172,10 +173,10 @@ return fmt.Errorf("marshal MongoDB Flex user: %w", err)

default:
p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, *user.Id)
p.Outputf("Username: %s\n", *user.Username)
p.Outputf("Password: %s\n", *user.Password)
p.Outputf("Roles: %v\n", *user.Roles)
p.Outputf("Database: %s\n", *user.Database)
p.Outputf("Host: %s\n", *user.Host)
p.Outputf("Port: %d\n", *user.Port)
p.Outputf("URI: %s\n", *user.Uri)
p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, utils.PtrString(user.Id))
p.Outputf("Username: %s\n", utils.PtrString(user.Username))
p.Outputf("Password: %s\n", utils.PtrString(user.Password))
p.Outputf("Roles: %v\n", utils.PtrString(user.Roles))
p.Outputf("Database: %s\n", utils.PtrString(user.Database))
p.Outputf("Host: %s\n", utils.PtrString(user.Host))
p.Outputf("Port: %s\n", utils.PtrString(user.Port))
p.Outputf("URI: %s\n", utils.PtrString(user.Uri))

@@ -182,0 +183,0 @@ return nil

@@ -131,3 +131,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -141,13 +141,13 @@ return fmt.Errorf("marshal MongoDB Flex user: %w", err)

table := tables.NewTable()
table.AddRow("ID", *user.Id)
table.AddRow("ID", utils.PtrString(user.Id))
table.AddSeparator()
table.AddRow("USERNAME", *user.Username)
table.AddRow("USERNAME", utils.PtrString(user.Username))
table.AddSeparator()
table.AddRow("ROLES", *user.Roles)
table.AddRow("ROLES", utils.PtrString(user.Roles))
table.AddSeparator()
table.AddRow("DATABASE", *user.Database)
table.AddRow("DATABASE", utils.PtrString(user.Database))
table.AddSeparator()
table.AddRow("HOST", *user.Host)
table.AddRow("HOST", utils.PtrString(user.Host))
table.AddSeparator()
table.AddRow("PORT", *user.Port)
table.AddRow("PORT", utils.PtrString(user.Port))

@@ -154,0 +154,0 @@ err := table.Display(p)

@@ -18,2 +18,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -152,3 +153,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(users, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(users, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -165,3 +166,6 @@ return fmt.Errorf("marshal MongoDB Flex user list: %w", err)

user := users[i]
table.AddRow(*user.Id, *user.Username)
table.AddRow(
utils.PtrString(user.Id),
utils.PtrString(user.Username),
)
}

@@ -168,0 +172,0 @@ err := table.Display(p)

@@ -147,3 +147,3 @@ package resetpassword

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -157,7 +157,7 @@ return fmt.Errorf("marshal MongoDB Flex reset password: %w", err)

p.Outputf("Reset password for user %q of instance %q\n\n", userLabel, instanceLabel)
p.Outputf("Username: %s\n", *user.Username)
p.Outputf("New password: %s\n", *user.Password)
p.Outputf("New URI: %s\n", *user.Uri)
p.Outputf("Username: %s\n", utils.PtrString(user.Username))
p.Outputf("New password: %s\n", utils.PtrString(user.Password))
p.Outputf("New URI: %s\n", utils.PtrString(user.Uri))
return nil
}
}

@@ -17,2 +17,3 @@ package create

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -24,2 +25,3 @@ type testCtxKey struct{}

var testProjectId = uuid.NewString()
var testRegion = "eu01"
var testBucketName = "my-bucket"

@@ -40,2 +42,3 @@

projectIdFlag: testProjectId,
regionFlag: testRegion,
}

@@ -53,2 +56,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -64,3 +68,3 @@ BucketName: testBucketName,

func fixtureRequest(mods ...func(request *objectstorage.ApiCreateBucketRequest)) objectstorage.ApiCreateBucketRequest {
request := testClient.CreateBucket(testCtx, testProjectId, testBucketName)
request := testClient.CreateBucket(testCtx, testProjectId, testRegion, testBucketName)
for _, mod := range mods {

@@ -67,0 +71,0 @@ mod(&request)

@@ -65,3 +65,3 @@ package create

// Check if the project is enabled before trying to create
enabled, err := utils.ProjectEnabled(ctx, apiClient, model.ProjectId)
enabled, err := utils.ProjectEnabled(ctx, apiClient, model.ProjectId, model.Region)
if err != nil {

@@ -87,3 +87,3 @@ return fmt.Errorf("check if Object Storage is enabled: %w", err)

s.Start("Creating bucket")
_, err = wait.CreateBucketWaitHandler(ctx, apiClient, model.ProjectId, model.BucketName).WaitWithContext(ctx)
_, err = wait.CreateBucketWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.BucketName).WaitWithContext(ctx)
if err != nil {

@@ -127,3 +127,3 @@ return fmt.Errorf("wait for Object Storage bucket creation: %w", err)

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiCreateBucketRequest {
req := apiClient.CreateBucket(ctx, model.ProjectId, model.BucketName)
req := apiClient.CreateBucket(ctx, model.ProjectId, model.Region, model.BucketName)
return req

@@ -143,3 +143,3 @@ }

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -146,0 +146,0 @@ return fmt.Errorf("marshal Object Storage bucket: %w", err)

@@ -17,2 +17,3 @@ package delete

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -24,2 +25,3 @@ type testCtxKey struct{}

var testProjectId = uuid.NewString()
var testRegion = "eu01"
var testBucketName = "my-bucket"

@@ -40,2 +42,3 @@

projectIdFlag: testProjectId,
regionFlag: testRegion,
}

@@ -53,2 +56,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -64,3 +68,3 @@ BucketName: testBucketName,

func fixtureRequest(mods ...func(request *objectstorage.ApiDeleteBucketRequest)) objectstorage.ApiDeleteBucketRequest {
request := testClient.DeleteBucket(testCtx, testProjectId, testBucketName)
request := testClient.DeleteBucket(testCtx, testProjectId, testRegion, testBucketName)
for _, mod := range mods {

@@ -67,0 +71,0 @@ mod(&request)

@@ -72,3 +72,3 @@ package delete

s.Start("Deleting bucket")
_, err = wait.DeleteBucketWaitHandler(ctx, apiClient, model.ProjectId, model.BucketName).WaitWithContext(ctx)
_, err = wait.DeleteBucketWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.BucketName).WaitWithContext(ctx)
if err != nil {

@@ -117,4 +117,4 @@ return fmt.Errorf("wait for Object Storage bucket deletion: %w", err)

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiDeleteBucketRequest {
req := apiClient.DeleteBucket(ctx, model.ProjectId, model.BucketName)
req := apiClient.DeleteBucket(ctx, model.ProjectId, model.Region, model.BucketName)
return req
}

@@ -17,2 +17,3 @@ package describe

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -24,2 +25,3 @@ type testCtxKey struct{}

var testProjectId = uuid.NewString()
var testRegion = "eu01"
var testBucketName = "my-bucket"

@@ -40,2 +42,3 @@

projectIdFlag: testProjectId,
regionFlag: testRegion,
}

@@ -53,2 +56,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -64,3 +68,3 @@ BucketName: testBucketName,

func fixtureRequest(mods ...func(request *objectstorage.ApiGetBucketRequest)) objectstorage.ApiGetBucketRequest {
request := testClient.GetBucket(testCtx, testProjectId, testBucketName)
request := testClient.GetBucket(testCtx, testProjectId, testRegion, testBucketName)
for _, mod := range mods {

@@ -67,0 +71,0 @@ mod(&request)

@@ -16,2 +16,3 @@ package describe

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -96,3 +97,3 @@ "github.com/spf13/cobra"

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiGetBucketRequest {
req := apiClient.GetBucket(ctx, model.ProjectId, model.BucketName)
req := apiClient.GetBucket(ctx, model.ProjectId, model.Region, model.BucketName)
return req

@@ -112,3 +113,3 @@ }

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(bucket, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(bucket, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -122,9 +123,9 @@ return fmt.Errorf("marshal Object Storage bucket: %w", err)

table := tables.NewTable()
table.AddRow("Name", *bucket.Name)
table.AddRow("Name", utils.PtrString(bucket.Name))
table.AddSeparator()
table.AddRow("Region", *bucket.Region)
table.AddRow("Region", utils.PtrString(bucket.Region))
table.AddSeparator()
table.AddRow("URL (Path Style)", *bucket.UrlPathStyle)
table.AddRow("URL (Path Style)", utils.PtrString(bucket.UrlPathStyle))
table.AddSeparator()
table.AddRow("URL (Virtual Hosted Style)", *bucket.UrlVirtualHostedStyle)
table.AddRow("URL (Virtual Hosted Style)", utils.PtrString(bucket.UrlVirtualHostedStyle))
table.AddSeparator()

@@ -131,0 +132,0 @@ err := table.Display(p)

@@ -19,2 +19,3 @@ package list

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -26,2 +27,3 @@ type testCtxKey struct{}

var testProjectId = uuid.NewString()
var testRegion = "eu01"

@@ -32,2 +34,3 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {

limitFlag: "10",
regionFlag: testRegion,
}

@@ -45,2 +48,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -56,3 +60,3 @@ Limit: utils.Ptr(int64(10)),

func fixtureRequest(mods ...func(request *objectstorage.ApiListBucketsRequest)) objectstorage.ApiListBucketsRequest {
request := testClient.ListBuckets(testCtx, testProjectId)
request := testClient.ListBuckets(testCtx, testProjectId, testRegion)
for _, mod := range mods {

@@ -59,0 +63,0 @@ mod(&request)

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/objectstorage"

@@ -130,3 +130,3 @@ )

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiListBucketsRequest {
req := apiClient.ListBuckets(ctx, model.ProjectId)
req := apiClient.ListBuckets(ctx, model.ProjectId, model.Region)
return req

@@ -146,3 +146,3 @@ }

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(buckets, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(buckets, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -159,3 +159,8 @@ return fmt.Errorf("marshal Object Storage bucket list: %w", err)

bucket := buckets[i]
table.AddRow(*bucket.Name, *bucket.Region, *bucket.UrlPathStyle, *bucket.UrlVirtualHostedStyle)
table.AddRow(
utils.PtrString(bucket.Name),
utils.PtrString(bucket.Region),
utils.PtrString(bucket.UrlPathStyle),
utils.PtrString(bucket.UrlVirtualHostedStyle),
)
}

@@ -162,0 +167,0 @@ err := table.Display(p)

@@ -18,2 +18,3 @@ package create

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -26,2 +27,3 @@ type testCtxKey struct{}

var testCredentialsGroupName = "test-name"
var testRegion = "eu01"

@@ -32,2 +34,3 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {

credentialsGroupNameFlag: testCredentialsGroupName,
regionFlag: testRegion,
}

@@ -45,2 +48,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -66,3 +70,3 @@ CredentialsGroupName: testCredentialsGroupName,

func fixtureRequest(mods ...func(request *objectstorage.ApiCreateCredentialsGroupRequest)) objectstorage.ApiCreateCredentialsGroupRequest {
request := testClient.CreateCredentialsGroup(testCtx, testProjectId)
request := testClient.CreateCredentialsGroup(testCtx, testProjectId, testRegion)
request = request.CreateCredentialsGroupPayload(fixturePayload())

@@ -69,0 +73,0 @@ for _, mod := range mods {

@@ -108,3 +108,3 @@ package create

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiCreateCredentialsGroupRequest {
req := apiClient.CreateCredentialsGroup(ctx, model.ProjectId)
req := apiClient.CreateCredentialsGroup(ctx, model.ProjectId, model.Region)
req = req.CreateCredentialsGroupPayload(objectstorage.CreateCredentialsGroupPayload{

@@ -127,3 +127,3 @@ DisplayName: utils.Ptr(model.CredentialsGroupName),

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -136,6 +136,9 @@ return fmt.Errorf("marshal Object Storage credentials group: %w", err)

default:
p.Outputf("Created credentials group %q. Credentials group ID: %s\n\n", *resp.CredentialsGroup.DisplayName, *resp.CredentialsGroup.CredentialsGroupId)
p.Outputf("URN: %s\n", *resp.CredentialsGroup.Urn)
p.Outputf("Created credentials group %q. Credentials group ID: %s\n\n",
utils.PtrString(resp.CredentialsGroup.DisplayName),
utils.PtrString(resp.CredentialsGroup.CredentialsGroupId),
)
p.Outputf("URN: %s\n", utils.PtrString(resp.CredentialsGroup.Urn))
return nil
}
}

@@ -17,2 +17,3 @@ package delete

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -25,2 +26,3 @@ type testCtxKey struct{}

var testCredentialsGroupId = uuid.NewString()
var testRegion = "eu01"

@@ -40,2 +42,3 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {

projectIdFlag: testProjectId,
regionFlag: testRegion,
}

@@ -53,2 +56,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -64,3 +68,3 @@ CredentialsGroupId: testCredentialsGroupId,

func fixtureRequest(mods ...func(request *objectstorage.ApiDeleteCredentialsGroupRequest)) objectstorage.ApiDeleteCredentialsGroupRequest {
request := testClient.DeleteCredentialsGroup(testCtx, testProjectId, testCredentialsGroupId)
request := testClient.DeleteCredentialsGroup(testCtx, testProjectId, testRegion, testCredentialsGroupId)
for _, mod := range mods {

@@ -67,0 +71,0 @@ mod(&request)

@@ -53,3 +53,3 @@ package delete

credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId)
credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId, model.Region)
if err != nil {

@@ -108,4 +108,4 @@ p.Debug(print.ErrorLevel, "get credentials group name: %v", err)

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiDeleteCredentialsGroupRequest {
req := apiClient.DeleteCredentialsGroup(ctx, model.ProjectId, model.CredentialsGroupId)
req := apiClient.DeleteCredentialsGroup(ctx, model.ProjectId, model.Region, model.CredentialsGroupId)
return req
}

@@ -18,2 +18,3 @@ package list

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -25,2 +26,3 @@ type testCtxKey struct{}

var testProjectId = uuid.NewString()
var testRegion = "eu01"

@@ -31,2 +33,3 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {

limitFlag: "10",
regionFlag: "eu01",
}

@@ -44,2 +47,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -55,3 +59,3 @@ Limit: utils.Ptr(int64(10)),

func fixtureRequest(mods ...func(request *objectstorage.ApiListCredentialsGroupsRequest)) objectstorage.ApiListCredentialsGroupsRequest {
request := testClient.ListCredentialsGroups(testCtx, testProjectId)
request := testClient.ListCredentialsGroups(testCtx, testProjectId, testRegion)
for _, mod := range mods {

@@ -58,0 +62,0 @@ mod(&request)

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/objectstorage"

@@ -122,3 +122,3 @@ )

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiListCredentialsGroupsRequest {
req := apiClient.ListCredentialsGroups(ctx, model.ProjectId)
req := apiClient.ListCredentialsGroups(ctx, model.ProjectId, model.Region)
return req

@@ -138,3 +138,3 @@ }

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentialsGroups, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentialsGroups, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -151,3 +151,7 @@ return fmt.Errorf("marshal Object Storage credentials group list: %w", err)

c := credentialsGroups[i]
table.AddRow(*c.CredentialsGroupId, *c.DisplayName, *c.Urn)
table.AddRow(
utils.PtrString(c.CredentialsGroupId),
utils.PtrString(c.DisplayName),
utils.PtrString(c.Urn),
)
}

@@ -154,0 +158,0 @@ err := table.Display(p)

@@ -19,2 +19,3 @@ package create

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -28,2 +29,3 @@ type testCtxKey struct{}

var testExpirationDate = "2024-01-01T00:00:00Z"
var testRegion = "eu01"

@@ -35,2 +37,3 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {

expireDateFlag: testExpirationDate,
regionFlag: testRegion,
}

@@ -53,2 +56,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -79,3 +83,3 @@ ExpireDate: utils.Ptr(testExpirationDate),

func fixtureRequest(mods ...func(request *objectstorage.ApiCreateAccessKeyRequest)) objectstorage.ApiCreateAccessKeyRequest {
request := testClient.CreateAccessKey(testCtx, testProjectId)
request := testClient.CreateAccessKey(testCtx, testProjectId, testRegion)
request = request.CreateAccessKeyPayload(fixturePayload())

@@ -82,0 +86,0 @@ request = request.CredentialsGroup(testCredentialsGroupId)

@@ -10,4 +10,2 @@ package create

"github.com/goccy/go-yaml"
objectStorageUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/object-storage/utils"
"github.com/spf13/cobra"

@@ -21,2 +19,4 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/args"

"github.com/stackitcloud/stackit-cli/internal/pkg/services/object-storage/client"
objectStorageUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/object-storage/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/objectstorage"

@@ -65,3 +65,3 @@ )

credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId)
credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId, model.Region)
if err != nil {

@@ -135,3 +135,3 @@ p.Debug(print.ErrorLevel, "get credentials group name: %v", err)

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiCreateAccessKeyRequest {
req := apiClient.CreateAccessKey(ctx, model.ProjectId)
req := apiClient.CreateAccessKey(ctx, model.ProjectId, model.Region)
req = req.CredentialsGroup(model.CredentialsGroupId)

@@ -155,3 +155,3 @@ req = req.CreateAccessKeyPayload(objectstorage.CreateAccessKeyPayload{

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -169,5 +169,5 @@ return fmt.Errorf("marshal Object Storage credentials: %w", err)

p.Outputf("Created credentials in group %q. Credentials ID: %s\n\n", credentialsGroupLabel, *resp.KeyId)
p.Outputf("Access Key ID: %s\n", *resp.AccessKey)
p.Outputf("Secret Access Key: %s\n", *resp.SecretAccessKey)
p.Outputf("Created credentials in group %q. Credentials ID: %s\n\n", credentialsGroupLabel, utils.PtrString(resp.KeyId))
p.Outputf("Access Key ID: %s\n", utils.PtrString(resp.AccessKey))
p.Outputf("Secret Access Key: %s\n", utils.PtrString(resp.SecretAccessKey))
p.Outputf("Expire Date: %s\n", expireDate)

@@ -174,0 +174,0 @@

@@ -17,2 +17,3 @@ package delete

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -26,2 +27,3 @@ type testCtxKey struct{}

var testCredentialsId = "keyID"
var testRegion = "eu01"

@@ -42,2 +44,3 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {

credentialsGroupIdFlag: testCredentialsGroupId,
regionFlag: testRegion,
}

@@ -55,2 +58,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -67,3 +71,3 @@ CredentialsGroupId: testCredentialsGroupId,

func fixtureRequest(mods ...func(request *objectstorage.ApiDeleteAccessKeyRequest)) objectstorage.ApiDeleteAccessKeyRequest {
request := testClient.DeleteAccessKey(testCtx, testProjectId, testCredentialsId)
request := testClient.DeleteAccessKey(testCtx, testProjectId, testRegion, testCredentialsId)
request = request.CredentialsGroup(testCredentialsGroupId)

@@ -70,0 +74,0 @@ for _, mod := range mods {

@@ -54,3 +54,3 @@ package delete

credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId)
credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId, model.Region)
if err != nil {

@@ -61,3 +61,3 @@ p.Debug(print.ErrorLevel, "get credentials group name: %v", err)

credentialsLabel, err := objectStorageUtils.GetCredentialsName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId, model.CredentialsId)
credentialsLabel, err := objectStorageUtils.GetCredentialsName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId, model.CredentialsId, model.Region)
if err != nil {

@@ -125,5 +125,5 @@ p.Debug(print.ErrorLevel, "get credentials name: %v", err)

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiDeleteAccessKeyRequest {
req := apiClient.DeleteAccessKey(ctx, model.ProjectId, model.CredentialsId)
req := apiClient.DeleteAccessKey(ctx, model.ProjectId, model.Region, model.CredentialsId)
req = req.CredentialsGroup(model.CredentialsGroupId)
return req
}

@@ -18,2 +18,3 @@ package list

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -26,2 +27,3 @@ type testCtxKey struct{}

var testCredentialsGroupId = uuid.NewString()
var testRegion = "eu01"

@@ -33,2 +35,3 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {

limitFlag: "10",
regionFlag: testRegion,
}

@@ -46,2 +49,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -58,3 +62,3 @@ CredentialsGroupId: testCredentialsGroupId,

func fixtureRequest(mods ...func(request *objectstorage.ApiListAccessKeysRequest)) objectstorage.ApiListAccessKeysRequest {
request := testClient.ListAccessKeys(testCtx, testProjectId)
request := testClient.ListAccessKeys(testCtx, testProjectId, testRegion)
request = request.CredentialsGroup(testCredentialsGroupId)

@@ -61,0 +65,0 @@ for _, mod := range mods {

@@ -9,4 +9,3 @@ package list

"github.com/goccy/go-yaml"
objectStorageUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/object-storage/utils"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,5 +18,5 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/services/object-storage/client"
objectStorageUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/object-storage/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/objectstorage"

@@ -75,3 +74,3 @@ )

if len(credentials) == 0 {
credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId)
credentialsGroupLabel, err := objectStorageUtils.GetCredentialsGroupName(ctx, apiClient, model.ProjectId, model.CredentialsGroupId, model.Region)
if err != nil {

@@ -138,3 +137,3 @@ p.Debug(print.ErrorLevel, "get credentials group name: %v", err)

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiListAccessKeysRequest {
req := apiClient.ListAccessKeys(ctx, model.ProjectId)
req := apiClient.ListAccessKeys(ctx, model.ProjectId, model.Region)
req = req.CredentialsGroup(model.CredentialsGroupId)

@@ -155,3 +154,3 @@ return req

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -169,7 +168,4 @@ return fmt.Errorf("marshal Object Storage credentials list: %w", err)

expiresAt := "Never"
if c.Expires != nil {
expiresAt = *c.Expires
}
table.AddRow(*c.KeyId, *c.DisplayName, expiresAt)
expiresAt := utils.PtrStringDefault(c.Expires, "Never")
table.AddRow(utils.PtrString(c.KeyId), utils.PtrString(c.DisplayName), expiresAt)
}

@@ -176,0 +172,0 @@ err := table.Display(p)

@@ -18,2 +18,3 @@ package disable

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -25,2 +26,3 @@ type testCtxKey struct{}

var testProjectId = uuid.NewString()
var testRegion = "eu01"

@@ -30,2 +32,3 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {

projectIdFlag: testProjectId,
regionFlag: testRegion,
}

@@ -43,2 +46,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -53,3 +57,3 @@ }

func fixtureRequest(mods ...func(request *objectstorage.ApiDisableServiceRequest)) objectstorage.ApiDisableServiceRequest {
request := testClient.DisableService(testCtx, testProjectId)
request := testClient.DisableService(testCtx, testProjectId, testRegion)
for _, mod := range mods {

@@ -56,0 +60,0 @@ mod(&request)

@@ -102,4 +102,4 @@ package disable

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiDisableServiceRequest {
req := apiClient.DisableService(ctx, model.ProjectId)
req := apiClient.DisableService(ctx, model.ProjectId, model.Region)
return req
}

@@ -18,2 +18,3 @@ package enable

var projectIdFlag = globalflags.ProjectIdFlag
var regionFlag = globalflags.RegionFlag

@@ -25,2 +26,3 @@ type testCtxKey struct{}

var testProjectId = uuid.NewString()
var testRegion = "eu01"

@@ -30,2 +32,3 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {

projectIdFlag: testProjectId,
regionFlag: testRegion,
}

@@ -43,2 +46,3 @@ for _, mod := range mods {

Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},

@@ -53,3 +57,3 @@ }

func fixtureRequest(mods ...func(request *objectstorage.ApiEnableServiceRequest)) objectstorage.ApiEnableServiceRequest {
request := testClient.EnableService(testCtx, testProjectId)
request := testClient.EnableService(testCtx, testProjectId, testRegion)
for _, mod := range mods {

@@ -56,0 +60,0 @@ mod(&request)

@@ -102,4 +102,4 @@ package enable

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiEnableServiceRequest {
req := apiClient.EnableService(ctx, model.ProjectId)
req := apiClient.EnableService(ctx, model.ProjectId, model.Region)
return req
}

@@ -18,2 +18,3 @@ package create

observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/observability"

@@ -124,3 +125,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -140,5 +141,7 @@ return fmt.Errorf("marshal Observability credentials: %w", err)

p.Outputf("Password: %s\n", *resp.Credentials.Password)
if resp.Credentials != nil {
p.Outputf("Password: %s\n", utils.PtrString(resp.Credentials.Password))
}
return nil
}
}

@@ -18,2 +18,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -138,3 +139,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -151,3 +152,3 @@ return fmt.Errorf("marshal Observability credentials list: %w", err)

c := credentials[i]
table.AddRow(*c.Name)
table.AddRow(utils.PtrString(c.Name))
}

@@ -154,0 +155,0 @@ err := table.Display(p)

@@ -138,3 +138,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(grafanaConfigs, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(grafanaConfigs, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -153,9 +153,9 @@ return fmt.Errorf("marshal Grafana configs: %w", err)

table := tables.NewTable()
table.AddRow("GRAFANA DASHBOARD", *instance.Instance.GrafanaUrl)
table.AddRow("GRAFANA DASHBOARD", utils.PtrString(instance.Instance.GrafanaUrl))
table.AddSeparator()
table.AddRow("PUBLIC READ ACCESS", *grafanaConfigs.PublicReadAccess)
table.AddRow("PUBLIC READ ACCESS", utils.PtrString(grafanaConfigs.PublicReadAccess))
table.AddSeparator()
table.AddRow("SINGLE SIGN-ON", *grafanaConfigs.UseStackitSso)
table.AddRow("SINGLE SIGN-ON", utils.PtrString(grafanaConfigs.UseStackitSso))
table.AddSeparator()
table.AddRow("INITIAL ADMIN USER (DEFAULT)", *instance.Instance.GrafanaAdminUser)
table.AddRow("INITIAL ADMIN USER (DEFAULT)", utils.PtrString(instance.Instance.GrafanaAdminUser))
table.AddSeparator()

@@ -162,0 +162,0 @@ table.AddRow("INITIAL ADMIN PASSWORD (DEFAULT)", initialAdminPassword)

@@ -19,2 +19,3 @@ package create

"github.com/stackitcloud/stackit-cli/internal/pkg/spinner"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -214,3 +215,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -227,5 +228,5 @@ return fmt.Errorf("marshal Observability instance: %w", err)

}
p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, *resp.InstanceId)
p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, utils.PtrString(resp.InstanceId))
return nil
}
}

@@ -111,3 +111,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -121,22 +121,26 @@ return fmt.Errorf("marshal Observability instance: %w", err)

table := tables.NewTable()
table.AddRow("ID", *instance.Id)
table.AddRow("ID", utils.PtrString(instance.Id))
table.AddSeparator()
table.AddRow("NAME", *instance.Name)
table.AddRow("NAME", utils.PtrString(instance.Name))
table.AddSeparator()
table.AddRow("STATUS", *instance.Status)
table.AddRow("STATUS", utils.PtrString(instance.Status))
table.AddSeparator()
table.AddRow("PLAN NAME", *instance.PlanName)
table.AddRow("PLAN NAME", utils.PtrString(instance.PlanName))
table.AddSeparator()
table.AddRow("METRIC SAMPLES (PER MIN)", *instance.Instance.Plan.TotalMetricSamples)
table.AddSeparator()
table.AddRow("LOGS (GB)", *instance.Instance.Plan.LogsStorage)
table.AddSeparator()
table.AddRow("TRACES (GB)", *instance.Instance.Plan.TracesStorage)
table.AddSeparator()
table.AddRow("NOTIFICATION RULES", *instance.Instance.Plan.AlertRules)
table.AddSeparator()
table.AddRow("GRAFANA USERS", *instance.Instance.Plan.GrafanaGlobalUsers)
table.AddSeparator()
table.AddRow("GRAFANA URL", *instance.Instance.GrafanaUrl)
table.AddSeparator()
if inst := instance.Instance; inst != nil {
if plan := inst.Plan; plan != nil {
table.AddRow("METRIC SAMPLES (PER MIN)", utils.PtrString(plan.TotalMetricSamples))
table.AddSeparator()
table.AddRow("LOGS (GB)", utils.PtrString(plan.LogsStorage))
table.AddSeparator()
table.AddRow("TRACES (GB)", utils.PtrString(plan.TracesStorage))
table.AddSeparator()
table.AddRow("NOTIFICATION RULES", utils.PtrString(plan.AlertRules))
table.AddSeparator()
table.AddRow("GRAFANA USERS", utils.PtrString(plan.GrafanaGlobalUsers))
table.AddSeparator()
}
table.AddRow("GRAFANA URL", utils.PtrString(inst.GrafanaUrl))
table.AddSeparator()
}
err := table.Display(p)

@@ -143,0 +147,0 @@ if err != nil {

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/observability"

@@ -145,3 +145,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -158,3 +158,8 @@ return fmt.Errorf("marshal Observability instance list: %w", err)

instance := instances[i]
table.AddRow(*instance.Id, *instance.Name, *instance.PlanName, *instance.Status)
table.AddRow(
utils.PtrString(instance.Id),
utils.PtrString(instance.Name),
utils.PtrString(instance.PlanName),
utils.PtrString(instance.Status),
)
}

@@ -161,0 +166,0 @@ err := table.Display(p)

@@ -8,3 +8,2 @@ package plans

"github.com/goccy/go-yaml"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,3 +18,5 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/goccy/go-yaml"
"github.com/spf13/cobra"

@@ -145,3 +146,3 @@ "github.com/stackitcloud/stackit-sdk-go/services/observability"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -158,3 +159,7 @@ return fmt.Errorf("marshal Observability plans: %w", err)

o := plans[i]
table.AddRow(*o.Id, *o.Name, *o.Description)
table.AddRow(
utils.PtrString(o.Id),
utils.PtrString(o.Name),
utils.PtrString(o.Description),
)
table.AddSeparator()

@@ -161,0 +166,0 @@ }

@@ -17,2 +17,3 @@ package create

"github.com/stackitcloud/stackit-cli/internal/pkg/spinner"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -122,3 +123,3 @@ "github.com/spf13/cobra"

}
p.Outputf("%s scrape configuration with name %q for Observability instance %q\n", operationState, *jobName, instanceLabel)
p.Outputf("%s scrape configuration with name %q for Observability instance %q\n", operationState, utils.PtrString(jobName), instanceLabel)
return nil

@@ -125,0 +126,0 @@ },

@@ -10,2 +10,3 @@ package describe

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,5 +20,4 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/observability"
"github.com/spf13/cobra"
)

@@ -115,3 +115,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(config, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(config, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -153,11 +153,11 @@ return fmt.Errorf("marshal scrape configuration: %w", err)

table := tables.NewTable()
table.AddRow("NAME", *config.JobName)
table.AddRow("NAME", utils.PtrString(config.JobName))
table.AddSeparator()
table.AddRow("METRICS PATH", *config.MetricsPath)
table.AddRow("METRICS PATH", utils.PtrString(config.MetricsPath))
table.AddSeparator()
table.AddRow("SCHEME", *config.Scheme)
table.AddRow("SCHEME", utils.PtrString(config.Scheme))
table.AddSeparator()
table.AddRow("SCRAPE INTERVAL", *config.ScrapeInterval)
table.AddRow("SCRAPE INTERVAL", utils.PtrString(config.ScrapeInterval))
table.AddSeparator()
table.AddRow("SCRAPE TIMEOUT", *config.ScrapeTimeout)
table.AddRow("SCRAPE TIMEOUT", utils.PtrString(config.ScrapeTimeout))
table.AddSeparator()

@@ -171,5 +171,5 @@ table.AddRow("SAML2", saml2Enabled)

table.AddSeparator()
table.AddRow("USERNAME", *config.BasicAuth.Username)
table.AddRow("USERNAME", utils.PtrString(config.BasicAuth.Username))
table.AddSeparator()
table.AddRow("PASSWORD", *config.BasicAuth.Password)
table.AddRow("PASSWORD", utils.PtrString(config.BasicAuth.Password))
}

@@ -176,0 +176,0 @@ table.AddSeparator()

@@ -17,2 +17,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -141,3 +142,3 @@ observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(configs, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(configs, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -165,3 +166,7 @@ return fmt.Errorf("marshal scrape configurations list: %w", err)

table.AddRow(*c.JobName, targets, *c.ScrapeInterval)
table.AddRow(
utils.PtrString(c.JobName),
targets,
utils.PtrString(c.ScrapeInterval),
)
}

@@ -168,0 +173,0 @@ err := table.Display(p)

@@ -140,3 +140,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -149,14 +149,16 @@ return fmt.Errorf("marshal OpenSearch credentials: %w", err)

default:
p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, *resp.Id) // The username field cannot be set by the user so we only display it if it's not returned empty
username := *resp.Raw.Credentials.Username
if username != "" {
p.Outputf("Username: %s\n", *resp.Raw.Credentials.Username)
p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, utils.PtrString(resp.Id))
// The username field cannot be set by the user so we only display it if it's not returned empty
if resp.HasRaw() && resp.Raw.Credentials != nil {
if username := resp.Raw.Credentials.Username; username != nil && *username != "" {
p.Outputf("Username: %s\n", *username)
}
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", utils.PtrString(resp.Raw.Credentials.Password))
}
p.Outputf("Host: %s\n", utils.PtrString(resp.Raw.Credentials.Host))
p.Outputf("Port: %s\n", utils.PtrString(resp.Raw.Credentials.Port))
}
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", *resp.Raw.Credentials.Password)
}
p.Outputf("Host: %s\n", *resp.Raw.Credentials.Host)
p.Outputf("Port: %d\n", *resp.Raw.Credentials.Port)
p.Outputf("URI: %s\n", *resp.Uri)

@@ -163,0 +165,0 @@ return nil

@@ -125,3 +125,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -135,13 +135,14 @@ return fmt.Errorf("marshal OpenSearch credentials: %w", err)

table := tables.NewTable()
table.AddRow("ID", *credentials.Id)
table.AddRow("ID", utils.PtrString(credentials.Id))
table.AddSeparator()
// The username field cannot be set by the user so we only display it if it's not returned empty
username := *credentials.Raw.Credentials.Username
if username != "" {
table.AddRow("USERNAME", *credentials.Raw.Credentials.Username)
if credentials.HasRaw() && credentials.Raw.Credentials != nil {
if username := credentials.Raw.Credentials.Username; username != nil && *username != "" {
table.AddRow("USERNAME", *username)
table.AddSeparator()
}
table.AddRow("PASSWORD", utils.PtrString(credentials.Raw.Credentials.Password))
table.AddSeparator()
table.AddRow("URI", utils.PtrString(credentials.Raw.Credentials.Uri))
}
table.AddRow("PASSWORD", *credentials.Raw.Credentials.Password)
table.AddSeparator()
table.AddRow("URI", *credentials.Raw.Credentials.Uri)
err := table.Display(p)

@@ -148,0 +149,0 @@ if err != nil {

@@ -8,3 +8,2 @@ package list

"github.com/goccy/go-yaml"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,3 +18,5 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/goccy/go-yaml"
"github.com/spf13/cobra"

@@ -150,3 +151,3 @@ "github.com/stackitcloud/stackit-sdk-go/services/opensearch"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -163,3 +164,3 @@ return fmt.Errorf("marshal OpenSearch credentials list: %w", err)

c := credentials[i]
table.AddRow(*c.Id)
table.AddRow(utils.PtrString(c.Id))
}

@@ -166,0 +167,0 @@ err := table.Display(p)

@@ -270,3 +270,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -273,0 +273,0 @@ return fmt.Errorf("marshal OpenSearch instance: %w", err)

@@ -113,3 +113,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -123,11 +123,11 @@ return fmt.Errorf("marshal OpenSearch instance: %w", err)

table := tables.NewTable()
table.AddRow("ID", *instance.InstanceId)
table.AddRow("ID", utils.PtrString(instance.InstanceId))
table.AddSeparator()
table.AddRow("NAME", *instance.Name)
table.AddRow("NAME", utils.PtrString(instance.Name))
table.AddSeparator()
table.AddRow("LAST OPERATION TYPE", *instance.LastOperation.Type)
table.AddRow("LAST OPERATION TYPE", utils.PtrString(instance.LastOperation.Type))
table.AddSeparator()
table.AddRow("LAST OPERATION STATE", *instance.LastOperation.State)
table.AddRow("LAST OPERATION STATE", utils.PtrString(instance.LastOperation.State))
table.AddSeparator()
table.AddRow("PLAN ID", *instance.PlanId)
table.AddRow("PLAN ID", utils.PtrString(instance.PlanId))
// Only show ACL if it's present and not empty

@@ -134,0 +134,0 @@ acl := (*instance.Parameters)[aclParameterKey]

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/opensearch"

@@ -145,3 +145,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -158,3 +158,8 @@ return fmt.Errorf("marshal OpenSearch instance list: %w", err)

instance := instances[i]
table.AddRow(*instance.InstanceId, *instance.Name, *instance.LastOperation.Type, *instance.LastOperation.State)
table.AddRow(
utils.PtrString(instance.InstanceId),
utils.PtrString(instance.Name),
utils.PtrString(instance.LastOperation.Type),
utils.PtrString(instance.LastOperation.State),
)
}

@@ -161,0 +166,0 @@ err := table.Display(p)

@@ -18,2 +18,3 @@ package plans

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -144,3 +145,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -159,3 +160,9 @@ return fmt.Errorf("marshal OpenSearch plans: %w", err)

plan := (*o.Plans)[j]
table.AddRow(*o.Name, *o.Version, *plan.Id, *plan.Name, *plan.Description)
table.AddRow(
utils.PtrString(o.Name),
utils.PtrString(o.Version),
utils.PtrString(plan.Id),
utils.PtrString(plan.Name),
utils.PtrString(plan.Description),
)
}

@@ -162,0 +169,0 @@ table.AddSeparator()

@@ -18,2 +18,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -171,3 +172,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(members, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(members, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -188,3 +189,3 @@ return fmt.Errorf("marshal members: %w", err)

}
table.AddRow(*m.Subject, *m.Role)
table.AddRow(utils.PtrString(m.Subject), utils.PtrString(m.Role))
}

@@ -191,0 +192,0 @@

@@ -17,2 +17,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -144,3 +145,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(roles, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(roles, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -159,3 +160,8 @@ return fmt.Errorf("marshal roles: %w", err)

p := (*r.Permissions)[j]
table.AddRow(*r.Name, *r.Description, *p.Name, *p.Description)
table.AddRow(
utils.PtrString(r.Name),
utils.PtrString(r.Description),
utils.PtrString(p.Name),
utils.PtrString(p.Description),
)
}

@@ -162,0 +168,0 @@ table.AddSeparator()

@@ -7,7 +7,5 @@ package describe

"fmt"
"time"
"github.com/goccy/go-yaml"
"github.com/inhies/go-bytesize"
"github.com/spf13/cobra"

@@ -22,2 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/args"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"

@@ -129,3 +128,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(backup, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(backup, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -139,10 +138,12 @@ return fmt.Errorf("marshal backup for PostgreSQL Flex backup: %w", err)

table := tables.NewTable()
table.AddRow("ID", *backup.Id)
table.AddRow("ID", utils.PtrString(backup.Id))
table.AddSeparator()
table.AddRow("CREATED AT", *backup.StartTime)
table.AddRow("CREATED AT", utils.PtrString(backup.StartTime))
table.AddSeparator()
table.AddRow("EXPIRES AT", backupExpireDate)
table.AddSeparator()
table.AddRow("BACKUP SIZE", bytesize.New(float64(*backup.Size)))
backupSize := utils.PtrByteSizeDefault(backup.Size, "n/a")
table.AddRow("BACKUP SIZE", backupSize)
err := table.Display(p)

@@ -149,0 +150,0 @@ if err != nil {

@@ -9,3 +9,2 @@ package list

"github.com/goccy/go-yaml"
"github.com/inhies/go-bytesize"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -20,2 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -149,3 +149,3 @@ "time"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(backups, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(backups, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -169,3 +169,9 @@ return fmt.Errorf("marshal PostgreSQL Flex backup list: %w", err)

table.AddRow(*backup.Id, *backup.StartTime, backupExpireDate, bytesize.New(float64(*backup.Size)))
backupSize := utils.PtrByteSizeDefault(backup.Size, "n/a")
table.AddRow(
utils.PtrString(backup.Id),
utils.PtrString(backup.StartTime),
backupExpireDate,
backupSize,
)
}

@@ -172,0 +178,0 @@ err := table.Display(p)

@@ -219,3 +219,3 @@ package clone

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -222,0 +222,0 @@ return fmt.Errorf("marshal PostgresFlex instance clone: %w", err)

@@ -287,3 +287,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -290,0 +290,0 @@ return fmt.Errorf("marshal PostgresFlex instance: %w", err)

@@ -115,3 +115,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -124,4 +124,7 @@ return fmt.Errorf("marshal PostgreSQL Flex instance: %w", err)

default:
aclsArray := *instance.Acl.Items
acls := strings.Join(aclsArray, ",")
acls := ""
if instance.HasAcl() && instance.Acl.HasItems() {
aclsArray := *instance.Acl.Items
acls = strings.Join(aclsArray, ",")
}

@@ -135,25 +138,25 @@ instanceType, err := postgresflexUtils.GetInstanceType(*instance.Replicas)

table := tables.NewTable()
table.AddRow("ID", *instance.Id)
table.AddRow("ID", utils.PtrString(instance.Id))
table.AddSeparator()
table.AddRow("NAME", *instance.Name)
table.AddRow("NAME", utils.PtrString(instance.Name))
table.AddSeparator()
table.AddRow("STATUS", cases.Title(language.English).String(*instance.Status))
table.AddRow("STATUS", cases.Title(language.English).String(utils.PtrString(instance.Status)))
table.AddSeparator()
table.AddRow("STORAGE SIZE (GB)", *instance.Storage.Size)
table.AddRow("STORAGE SIZE (GB)", utils.PtrString(instance.Storage.Size))
table.AddSeparator()
table.AddRow("VERSION", *instance.Version)
table.AddRow("VERSION", utils.PtrString(instance.Version))
table.AddSeparator()
table.AddRow("ACL", acls)
table.AddSeparator()
table.AddRow("FLAVOR DESCRIPTION", *instance.Flavor.Description)
table.AddRow("FLAVOR DESCRIPTION", utils.PtrString(instance.Flavor.Description))
table.AddSeparator()
table.AddRow("TYPE", instanceType)
table.AddSeparator()
table.AddRow("REPLICAS", *instance.Replicas)
table.AddRow("REPLICAS", utils.PtrString(instance.Replicas))
table.AddSeparator()
table.AddRow("CPU", *instance.Flavor.Cpu)
table.AddRow("CPU", utils.PtrString(instance.Flavor.Cpu))
table.AddSeparator()
table.AddRow("RAM (GB)", *instance.Flavor.Memory)
table.AddRow("RAM (GB)", utils.PtrString(instance.Flavor.Memory))
table.AddSeparator()
table.AddRow("BACKUP SCHEDULE (UTC)", *instance.BackupSchedule)
table.AddRow("BACKUP SCHEDULE (UTC)", utils.PtrString(instance.BackupSchedule))
table.AddSeparator()

@@ -160,0 +163,0 @@ err = table.Display(p)

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"

@@ -147,3 +147,3 @@ "golang.org/x/text/cases"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -161,3 +161,7 @@ return fmt.Errorf("marshal PostgreSQL Flex instance list: %w", err)

instance := instances[i]
table.AddRow(*instance.Id, *instance.Name, caser.String(*instance.Status))
table.AddRow(
utils.PtrString(instance.Id),
utils.PtrString(instance.Name),
caser.String(utils.PtrString(instance.Status)),
)
}

@@ -164,0 +168,0 @@ err := table.Display(p)

@@ -321,3 +321,3 @@ package update

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -324,0 +324,0 @@ return fmt.Errorf("marshal PostgresFlex instance: %w", err)

@@ -9,2 +9,3 @@ package options

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -17,4 +18,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/examples"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"

@@ -184,3 +184,3 @@ )

options.Storages = &flavorStorages{
FlavorId: *model.FlavorId,
FlavorId: utils.PtrString(model.FlavorId),
Storages: storages,

@@ -199,3 +199,3 @@ }

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(options, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(options, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -238,3 +238,8 @@ return fmt.Errorf("marshal PostgreSQL Flex options: %w", err)

f := flavors[i]
table.AddRow(*f.Id, *f.Cpu, *f.Memory, *f.Description)
table.AddRow(
utils.PtrString(f.Id),
utils.PtrString(f.Cpu),
utils.PtrString(f.Memory),
utils.PtrString(f.Description),
)
}

@@ -262,3 +267,7 @@ return table

sc := storages[i]
table.AddRow(*storagesResp.StorageRange.Min, *storagesResp.StorageRange.Max, sc)
table.AddRow(
utils.PtrString(storagesResp.StorageRange.Min),
utils.PtrString(storagesResp.StorageRange.Max),
sc,
)
}

@@ -265,0 +274,0 @@ table.EnableAutoMergeOnColumns(1, 2, 3)

@@ -9,2 +9,3 @@ package create

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

postgresflexUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/postgresflex/utils"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"

@@ -159,3 +159,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -169,9 +169,9 @@ return fmt.Errorf("marshal PostgresFlex user: %w", err)

user := resp.Item
p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, *user.Id)
p.Outputf("Username: %s\n", *user.Username)
p.Outputf("Password: %s\n", *user.Password)
p.Outputf("Roles: %v\n", *user.Roles)
p.Outputf("Host: %s\n", *user.Host)
p.Outputf("Port: %d\n", *user.Port)
p.Outputf("URI: %s\n", *user.Uri)
p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, utils.PtrString(user.Id))
p.Outputf("Username: %s\n", utils.PtrString(user.Username))
p.Outputf("Password: %s\n", utils.PtrString(user.Password))
p.Outputf("Roles: %v\n", utils.PtrString(user.Roles))
p.Outputf("Host: %s\n", utils.PtrString(user.Host))
p.Outputf("Port: %s\n", utils.PtrString(user.Port))
p.Outputf("URI: %s\n", utils.PtrString(user.Uri))

@@ -178,0 +178,0 @@ return nil

@@ -9,2 +9,3 @@ package describe

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"

@@ -132,3 +132,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -142,11 +142,11 @@ return fmt.Errorf("marshal PostgreSQL Flex user: %w", err)

table := tables.NewTable()
table.AddRow("ID", *user.Id)
table.AddRow("ID", utils.PtrString(user.Id))
table.AddSeparator()
table.AddRow("USERNAME", *user.Username)
table.AddRow("USERNAME", utils.PtrString(user.Username))
table.AddSeparator()
table.AddRow("ROLES", *user.Roles)
table.AddRow("ROLES", utils.PtrString(user.Roles))
table.AddSeparator()
table.AddRow("HOST", *user.Host)
table.AddRow("HOST", utils.PtrString(user.Host))
table.AddSeparator()
table.AddRow("PORT", *user.Port)
table.AddRow("PORT", utils.PtrString(user.Port))

@@ -153,0 +153,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"

@@ -153,3 +153,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(users, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(users, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -166,3 +166,6 @@ return fmt.Errorf("marshal PostgreSQL Flex user list: %w", err)

user := users[i]
table.AddRow(*user.Id, *user.Username)
table.AddRow(
utils.PtrString(user.Id),
utils.PtrString(user.Username),
)
}

@@ -169,0 +172,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package resetpassword

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

postgresflexUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/postgresflex/utils"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"

@@ -148,3 +148,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -158,7 +158,7 @@ return fmt.Errorf("marshal PostgresFlex user: %w", err)

p.Outputf("Reset password for user %q of instance %q\n\n", userLabel, instanceLabel)
p.Outputf("Username: %s\n", *user.Item.Username)
p.Outputf("New password: %s\n", *user.Item.Password)
p.Outputf("New URI: %s\n", *user.Item.Uri)
p.Outputf("Username: %s\n", utils.PtrString(user.Item.Username))
p.Outputf("New password: %s\n", utils.PtrString(user.Item.Password))
p.Outputf("New URI: %s\n", utils.PtrString(user.Item.Uri))
return nil
}
}

@@ -226,3 +226,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -235,5 +235,5 @@ return fmt.Errorf("marshal project: %w", err)

default:
p.Outputf("Created project under the parent with ID %q. Project ID: %s\n", *model.ParentId, *resp.ProjectId)
p.Outputf("Created project under the parent with ID %q. Project ID: %s\n", utils.PtrString(model.ParentId), utils.PtrString(resp.ProjectId))
return nil
}
}

@@ -132,3 +132,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(project, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(project, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -142,11 +142,11 @@ return fmt.Errorf("marshal project details: %w", err)

table := tables.NewTable()
table.AddRow("ID", *project.ProjectId)
table.AddRow("ID", utils.PtrString(project.ProjectId))
table.AddSeparator()
table.AddRow("NAME", *project.Name)
table.AddRow("NAME", utils.PtrString(project.Name))
table.AddSeparator()
table.AddRow("CREATION", *project.CreationTime)
table.AddRow("CREATION", utils.PtrString(project.CreationTime))
table.AddSeparator()
table.AddRow("STATE", *project.LifecycleState)
table.AddRow("STATE", utils.PtrString(project.LifecycleState))
table.AddSeparator()
table.AddRow("PARENT ID", *project.Parent.Id)
table.AddRow("PARENT ID", utils.PtrString(project.Parent.Id))
err := table.Display(p)

@@ -153,0 +153,0 @@ if err != nil {

@@ -10,2 +10,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -20,4 +21,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/auth"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/resourcemanager"

@@ -235,3 +235,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(projects, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(projects, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -248,3 +248,8 @@ return fmt.Errorf("marshal projects list: %w", err)

p := projects[i]
table.AddRow(*p.ProjectId, *p.Name, *p.LifecycleState, *p.Parent.Id)
table.AddRow(
utils.PtrString(p.ProjectId),
utils.PtrString(p.Name),
utils.PtrString(p.LifecycleState),
utils.PtrString(p.Parent.Id),
)
}

@@ -251,0 +256,0 @@

@@ -87,3 +87,3 @@ package add

p.Info("Added the role %q to %s on project %q\n", *model.Role, model.Subject, projectLabel)
p.Info("Added the role %q to %s on project %q\n", utils.PtrString(model.Role), model.Subject, projectLabel)
return nil

@@ -90,0 +90,0 @@ },

@@ -10,2 +10,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -20,4 +21,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/authorization"

@@ -174,3 +174,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(members, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(members, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -191,3 +191,3 @@ return fmt.Errorf("marshal members: %w", err)

}
table.AddRow(*m.Subject, *m.Role)
table.AddRow(utils.PtrString(m.Subject), utils.PtrString(m.Role))
}

@@ -194,0 +194,0 @@

@@ -93,3 +93,3 @@ package remove

p.Info("Removed the role %q from %s on project %q\n", *model.Role, model.Subject, projectLabel)
p.Info("Removed the role %q from %s on project %q\n", utils.PtrString(model.Role), model.Subject, projectLabel)
return nil

@@ -96,0 +96,0 @@ },

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/authorization"

@@ -147,3 +147,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(roles, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(roles, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -162,3 +162,8 @@ return fmt.Errorf("marshal roles: %w", err)

p := (*r.Permissions)[j]
table.AddRow(*r.Name, *r.Description, *p.Name, *p.Description)
table.AddRow(
utils.PtrString(r.Name),
utils.PtrString(r.Description),
utils.PtrString(p.Name),
utils.PtrString(p.Description),
)
}

@@ -165,0 +170,0 @@ table.AddSeparator()

@@ -139,3 +139,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -148,18 +148,19 @@ return fmt.Errorf("marshal RabbitMQ credentials: %w", err)

default:
p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, *resp.Id)
p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, utils.PtrString(resp.Id))
// The username field cannot be set by the user so we only display it if it's not returned empty
username := *resp.Raw.Credentials.Username
if username != "" {
p.Outputf("Username: %s\n", *resp.Raw.Credentials.Username)
if resp.HasRaw() && resp.Raw.Credentials != nil {
if username := resp.Raw.Credentials.Username; username != nil && *username != "" {
p.Outputf("Username: %s\n", *username)
}
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", utils.PtrString(resp.Raw.Credentials.Password))
}
p.Outputf("Host: %s\n", utils.PtrString(resp.Raw.Credentials.Host))
p.Outputf("Port: %s\n", utils.PtrString(resp.Raw.Credentials.Port))
}
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", *resp.Raw.Credentials.Password)
}
p.Outputf("Host: %s\n", *resp.Raw.Credentials.Host)
p.Outputf("Port: %d\n", *resp.Raw.Credentials.Port)
p.Outputf("URI: %s\n", *resp.Uri)
p.Outputf("URI: %s\n", utils.PtrString(resp.Uri))
return nil
}
}

@@ -125,3 +125,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -138,10 +138,11 @@ return fmt.Errorf("marshal RabbitMQ credentials: %w", err)

// The username field cannot be set by the user so we only display it if it's not returned empty
username := *credentials.Raw.Credentials.Username
if username != "" {
table.AddRow("USERNAME", *credentials.Raw.Credentials.Username)
if credentials.HasRaw() && credentials.Raw.Credentials != nil {
if username := credentials.Raw.Credentials.Username; username != nil && *username != "" {
table.AddRow("USERNAME", *username)
table.AddSeparator()
}
table.AddRow("PASSWORD", utils.PtrString(credentials.Raw.Credentials.Password))
table.AddSeparator()
table.AddRow("URI", utils.PtrString(credentials.Raw.Credentials.Uri))
}
table.AddRow("PASSWORD", *credentials.Raw.Credentials.Password)
table.AddSeparator()
table.AddRow("URI", *credentials.Raw.Credentials.Uri)
err := table.Display(p)

@@ -148,0 +149,0 @@ if err != nil {

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/rabbitmq"

@@ -150,3 +150,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -163,3 +163,3 @@ return fmt.Errorf("marshal RabbitMQ credentials list: %w", err)

c := credentials[i]
table.AddRow(*c.Id)
table.AddRow(utils.PtrString(c.Id))
}

@@ -166,0 +166,0 @@ err := table.Display(p)

@@ -270,3 +270,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -273,0 +273,0 @@ return fmt.Errorf("marshal RabbitMQ instance: %w", err)

@@ -113,3 +113,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -123,11 +123,11 @@ return fmt.Errorf("marshal RabbitMQ instance: %w", err)

table := tables.NewTable()
table.AddRow("ID", *instance.InstanceId)
table.AddRow("ID", utils.PtrString(instance.InstanceId))
table.AddSeparator()
table.AddRow("NAME", *instance.Name)
table.AddRow("NAME", utils.PtrString(instance.Name))
table.AddSeparator()
table.AddRow("LAST OPERATION TYPE", *instance.LastOperation.Type)
table.AddRow("LAST OPERATION TYPE", utils.PtrString(instance.LastOperation.Type))
table.AddSeparator()
table.AddRow("LAST OPERATION STATE", *instance.LastOperation.State)
table.AddRow("LAST OPERATION STATE", utils.PtrString(instance.LastOperation.State))
table.AddSeparator()
table.AddRow("PLAN ID", *instance.PlanId)
table.AddRow("PLAN ID", utils.PtrString(instance.PlanId))
// Only show ACL if it's present and not empty

@@ -134,0 +134,0 @@ acl := (*instance.Parameters)[aclParameterKey]

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/rabbitmq"

@@ -145,3 +145,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -158,3 +158,8 @@ return fmt.Errorf("marshal RabbitMQ instance list: %w", err)

instance := instances[i]
table.AddRow(*instance.InstanceId, *instance.Name, *instance.LastOperation.Type, *instance.LastOperation.State)
table.AddRow(
utils.PtrString(instance.InstanceId),
utils.PtrString(instance.Name),
utils.PtrString(instance.LastOperation.Type),
utils.PtrString(instance.LastOperation.State),
)
}

@@ -161,0 +166,0 @@ err := table.Display(p)

@@ -18,2 +18,3 @@ package plans

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -144,3 +145,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -159,3 +160,9 @@ return fmt.Errorf("marshal RabbitMQ plans: %w", err)

plan := (*o.Plans)[j]
table.AddRow(*o.Name, *o.Version, *plan.Id, *plan.Name, *plan.Description)
table.AddRow(
utils.PtrString(o.Name),
utils.PtrString(o.Version),
utils.PtrString(plan.Id),
utils.PtrString(plan.Name),
utils.PtrString(plan.Description),
)
}

@@ -162,0 +169,0 @@ table.AddSeparator()

@@ -141,3 +141,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -152,16 +152,17 @@ return fmt.Errorf("marshal Redis credentials: %w", err)

// The username field cannot be set by the user, so we only display it if it's not returned empty
username := *resp.Raw.Credentials.Username
if username != "" {
p.Outputf("Username: %s\n", *resp.Raw.Credentials.Username)
if resp.HasRaw() && resp.Raw.Credentials != nil {
if username := resp.Raw.Credentials.Username; username != nil && *username != "" {
p.Outputf("Username: %s\n", *username)
}
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", utils.PtrString(resp.Raw.Credentials.Password))
}
p.Outputf("Host: %s\n", utils.PtrString(resp.Raw.Credentials.Host))
p.Outputf("Port: %s\n", utils.PtrString(resp.Raw.Credentials.Port))
}
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", *resp.Raw.Credentials.Password)
}
p.Outputf("Host: %s\n", *resp.Raw.Credentials.Host)
p.Outputf("Port: %d\n", *resp.Raw.Credentials.Port)
p.Outputf("URI: %s\n", *resp.Uri)
p.Outputf("URI: %s\n", utils.PtrString(resp.Uri))
return nil
}
}

@@ -125,3 +125,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -138,10 +138,11 @@ return fmt.Errorf("marshal Redis credentials: %w", err)

// The username field cannot be set by the user so we only display it if it's not returned empty
username := *credentials.Raw.Credentials.Username
if username != "" {
table.AddRow("USERNAME", *credentials.Raw.Credentials.Username)
if credentials.HasRaw() && credentials.Raw.Credentials != nil {
if username := credentials.Raw.Credentials.Username; username != nil && *username != "" {
table.AddRow("USERNAME", *username)
table.AddSeparator()
}
table.AddRow("PASSWORD", utils.PtrString(credentials.Raw.Credentials.Password))
table.AddSeparator()
table.AddRow("URI", utils.PtrString(credentials.Raw.Credentials.Uri))
}
table.AddRow("PASSWORD", *credentials.Raw.Credentials.Password)
table.AddSeparator()
table.AddRow("URI", *credentials.Raw.Credentials.Uri)
err := table.Display(p)

@@ -148,0 +149,0 @@ if err != nil {

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/redis"

@@ -150,3 +150,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(credentials, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -163,3 +163,3 @@ return fmt.Errorf("marshal Redis credentials list: %w", err)

c := credentials[i]
table.AddRow(*c.Id)
table.AddRow(utils.PtrString(c.Id))
}

@@ -166,0 +166,0 @@ err := table.Display(p)

@@ -265,3 +265,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -268,0 +268,0 @@ return fmt.Errorf("marshal Redis instance: %w", err)

@@ -113,3 +113,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instance, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -123,11 +123,11 @@ return fmt.Errorf("marshal Redis instance: %w", err)

table := tables.NewTable()
table.AddRow("ID", *instance.InstanceId)
table.AddRow("ID", utils.PtrString(instance.InstanceId))
table.AddSeparator()
table.AddRow("NAME", *instance.Name)
table.AddRow("NAME", utils.PtrString(instance.Name))
table.AddSeparator()
table.AddRow("LAST OPERATION TYPE", *instance.LastOperation.Type)
table.AddRow("LAST OPERATION TYPE", utils.PtrString(instance.LastOperation.Type))
table.AddSeparator()
table.AddRow("LAST OPERATION STATE", *instance.LastOperation.State)
table.AddRow("LAST OPERATION STATE", utils.PtrString(instance.LastOperation.State))
table.AddSeparator()
table.AddRow("PLAN ID", *instance.PlanId)
table.AddRow("PLAN ID", utils.PtrString(instance.PlanId))
// Only show ACL if it's present and not empty

@@ -134,0 +134,0 @@ acl := (*instance.Parameters)[aclParameterKey]

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/redis"

@@ -145,3 +145,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -158,3 +158,8 @@ return fmt.Errorf("marshal Redis instance list: %w", err)

instance := instances[i]
table.AddRow(*instance.InstanceId, *instance.Name, *instance.LastOperation.Type, *instance.LastOperation.State)
table.AddRow(
utils.PtrString(instance.InstanceId),
utils.PtrString(instance.Name),
utils.PtrString(instance.LastOperation.Type),
utils.PtrString(instance.LastOperation.State),
)
}

@@ -161,0 +166,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package plans

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/redis"

@@ -145,3 +145,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(plans, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -160,3 +160,9 @@ return fmt.Errorf("marshal Redis plans: %w", err)

plan := (*o.Plans)[j]
table.AddRow(*o.Name, *o.Version, *plan.Id, *plan.Name, *plan.Description)
table.AddRow(
utils.PtrString(o.Name),
utils.PtrString(o.Version),
utils.PtrString(plan.Id),
utils.PtrString(plan.Name),
utils.PtrString(plan.Description),
)
}

@@ -163,0 +169,0 @@ table.AddSeparator()

@@ -171,3 +171,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -174,0 +174,0 @@ return fmt.Errorf("marshal Secrets Manager instance: %w", err)

@@ -129,3 +129,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(output, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(output, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -139,13 +139,13 @@ return fmt.Errorf("marshal Secrets Manager instance: %w", err)

table := tables.NewTable()
table.AddRow("ID", *instance.Id)
table.AddRow("ID", utils.PtrString(instance.Id))
table.AddSeparator()
table.AddRow("NAME", *instance.Name)
table.AddRow("NAME", utils.PtrString(instance.Name))
table.AddSeparator()
table.AddRow("STATE", *instance.State)
table.AddRow("STATE", utils.PtrString(instance.State))
table.AddSeparator()
table.AddRow("SECRETS", *instance.SecretCount)
table.AddRow("SECRETS", utils.PtrString(instance.SecretCount))
table.AddSeparator()
table.AddRow("ENGINE", *instance.SecretsEngine)
table.AddRow("ENGINE", utils.PtrString(instance.SecretsEngine))
table.AddSeparator()
table.AddRow("CREATION DATE", *instance.CreationStartDate)
table.AddRow("CREATION DATE", utils.PtrString(instance.CreationStartDate))
table.AddSeparator()

@@ -152,0 +152,0 @@ // Only show ACL if it's present and not empty

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,5 +20,4 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/secretsmanager"
"github.com/spf13/cobra"
)

@@ -146,3 +146,3 @@

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(instances, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -159,3 +159,8 @@ return fmt.Errorf("marshal Secrets Manager instance list: %w", err)

instance := instances[i]
table.AddRow(*instance.Id, *instance.Name, *instance.State, *instance.SecretCount)
table.AddRow(
utils.PtrString(instance.Id),
utils.PtrString(instance.Name),
utils.PtrString(instance.State),
utils.PtrString(instance.SecretCount),
)
}

@@ -162,0 +167,0 @@ err := table.Display(p)

@@ -151,3 +151,3 @@ package create

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -160,7 +160,7 @@ return fmt.Errorf("marshal Secrets Manager user: %w", err)

default:
p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, *resp.Id)
p.Outputf("Username: %s\n", *resp.Username)
p.Outputf("Password: %s\n", *resp.Password)
p.Outputf("Description: %s\n", *resp.Description)
p.Outputf("Write Access: %t\n", *resp.Write)
p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, utils.PtrString(resp.Id))
p.Outputf("Username: %s\n", utils.PtrString(resp.Username))
p.Outputf("Password: %s\n", utils.PtrString(resp.Password))
p.Outputf("Description: %s\n", utils.PtrString(resp.Description))
p.Outputf("Write Access: %s\n", utils.PtrString(resp.Write))

@@ -167,0 +167,0 @@ return nil

@@ -127,3 +127,3 @@ package describe

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(user, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -137,5 +137,5 @@ return fmt.Errorf("marshal Secrets Manager user: %w", err)

table := tables.NewTable()
table.AddRow("ID", *user.Id)
table.AddRow("ID", utils.PtrString(user.Id))
table.AddSeparator()
table.AddRow("USERNAME", *user.Username)
table.AddRow("USERNAME", utils.PtrString(user.Username))
table.AddSeparator()

@@ -150,3 +150,3 @@ if user.Description != nil && *user.Description != "" {

}
table.AddRow("WRITE ACCESS", *user.Write)
table.AddRow("WRITE ACCESS", utils.PtrString(user.Write))

@@ -153,0 +153,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/secretsmanager"

@@ -153,3 +153,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(users, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(users, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -166,3 +166,8 @@ return fmt.Errorf("marshal Secrets Manager user list: %w", err)

user := users[i]
table.AddRow(*user.Id, *user.Username, *user.Description, *user.Write)
table.AddRow(
utils.PtrString(user.Id),
utils.PtrString(user.Username),
utils.PtrString(user.Description),
utils.PtrString(user.Write),
)
}

@@ -169,0 +174,0 @@ err := table.Display(p)

@@ -17,2 +17,3 @@ package create

"github.com/stackitcloud/stackit-cli/internal/pkg/services/service-account/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -133,3 +134,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(serviceAccount, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(serviceAccount, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -142,5 +143,5 @@ return fmt.Errorf("marshal service account: %w", err)

default:
p.Outputf("Created service account for project %q. Email: %s\n", projectLabel, *serviceAccount.Email)
p.Outputf("Created service account for project %q. Email: %s\n", projectLabel, utils.PtrString(serviceAccount.Email))
return nil
}
}

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -18,4 +19,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/serviceaccount"

@@ -155,3 +155,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(keys, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(keys, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -172,3 +172,8 @@ return fmt.Errorf("marshal keys metadata: %w", err)

}
table.AddRow(*k.Id, *k.Active, *k.CreatedAt, validUntil)
table.AddRow(
utils.PtrString(k.Id),
utils.PtrString(k.Active),
utils.PtrString(k.CreatedAt),
validUntil,
)
}

@@ -175,0 +180,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package list

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/serviceaccount"

@@ -137,3 +137,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(serviceAccounts, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(serviceAccounts, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -148,3 +148,6 @@ return fmt.Errorf("marshal service accounts list: %w", err)

account := serviceAccounts[i]
table.AddRow(*account.Id, *account.Email)
table.AddRow(
utils.PtrString(account.Id),
utils.PtrString(account.Email),
)
}

@@ -151,0 +154,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package create

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -17,4 +18,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/services/service-account/client"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/serviceaccount"

@@ -158,3 +158,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(token, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(token, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -167,7 +167,7 @@ return fmt.Errorf("marshal service account access token: %w", err)

default:
p.Outputf("Created access token for service account %s. Token ID: %s\n\n", model.ServiceAccountEmail, *token.Id)
p.Outputf("Valid until: %s\n", *token.ValidUntil)
p.Outputf("Token: %s\n", *token.Token)
p.Outputf("Created access token for service account %s. Token ID: %s\n\n", model.ServiceAccountEmail, utils.PtrString(token.Id))
p.Outputf("Valid until: %s\n", utils.PtrString(token.ValidUntil))
p.Outputf("Token: %s\n", utils.PtrString(token.Token))
return nil
}
}

@@ -17,2 +17,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -158,3 +159,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(tokensMetadata, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(tokensMetadata, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -171,3 +172,8 @@ return fmt.Errorf("marshal tokens metadata: %w", err)

t := tokensMetadata[i]
table.AddRow(*t.Id, *t.Active, *t.CreatedAt, *t.ValidUntil)
table.AddRow(
utils.PtrString(t.Id),
utils.PtrString(t.Active),
utils.PtrString(t.CreatedAt),
utils.PtrString(t.ValidUntil),
)
}

@@ -174,0 +180,0 @@ err := table.Display(p)

@@ -9,2 +9,3 @@ package create

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -22,4 +23,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/spinner"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/ske"

@@ -213,3 +213,3 @@ "github.com/stackitcloud/stackit-sdk-go/services/ske/wait"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -226,5 +226,5 @@ return fmt.Errorf("marshal SKE cluster: %w", err)

}
p.Outputf("%s cluster for project %q. Cluster name: %s\n", operationState, projectLabel, *resp.Name)
p.Outputf("%s cluster for project %q. Cluster name: %s\n", operationState, projectLabel, utils.PtrString(resp.Name))
return nil
}
}

@@ -9,2 +9,3 @@ package describe

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -17,4 +18,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/ske"

@@ -112,3 +112,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(cluster, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(cluster, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -127,7 +127,7 @@ return fmt.Errorf("marshal SKE cluster: %w", err)

table := tables.NewTable()
table.AddRow("NAME", *cluster.Name)
table.AddRow("NAME", utils.PtrString(cluster.Name))
table.AddSeparator()
table.AddRow("STATE", *cluster.Status.Aggregated)
table.AddRow("STATE", utils.PtrString(cluster.Status.Aggregated))
table.AddSeparator()
table.AddRow("VERSION", *cluster.Kubernetes.Version)
table.AddRow("VERSION", utils.PtrString(cluster.Kubernetes.Version))
table.AddSeparator()

@@ -134,0 +134,0 @@ table.AddRow("ACL", acl)

@@ -20,2 +20,3 @@ package list

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -161,3 +162,3 @@ "github.com/spf13/cobra"

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(clusters, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(clusters, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -178,3 +179,9 @@ return fmt.Errorf("marshal SKE cluster list: %w", err)

}
table.AddRow(*c.Name, *c.Status.Aggregated, *c.Kubernetes.Version, len(*c.Nodepools), monitoring)
table.AddRow(
utils.PtrString(c.Name),
utils.PtrString(c.Status.Aggregated),
utils.PtrString(c.Kubernetes.Version),
len(*c.Nodepools),
monitoring,
)
}

@@ -181,0 +188,0 @@ err := table.Display(p)

@@ -173,3 +173,3 @@ package update

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(resp, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -176,0 +176,0 @@ return fmt.Errorf("marshal SKE cluster: %w", err)

@@ -9,2 +9,3 @@ package describe

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -16,7 +17,6 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/errors"

"github.com/stackitcloud/stackit-cli/internal/pkg/services/service-enablement/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/service-enablement/utils"
skeUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/service-enablement/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/serviceenablement"
"github.com/spf13/cobra"
)

@@ -87,3 +87,3 @@

func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiGetServiceStatusRequest {
req := apiClient.GetServiceStatus(ctx, model.ProjectId, utils.SKEServiceId)
req := apiClient.GetServiceStatus(ctx, model.ProjectId, skeUtils.SKEServiceId)
return req

@@ -103,3 +103,3 @@ }

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(project, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(project, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -115,3 +115,3 @@ return fmt.Errorf("marshal SKE project details: %w", err)

table.AddSeparator()
table.AddRow("STATE", *project.State)
table.AddRow("STATE", utils.PtrString(project.State))
err := table.Display(p)

@@ -118,0 +118,0 @@ if err != nil {

@@ -17,2 +17,3 @@ package create

skeUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/ske/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

@@ -265,5 +266,5 @@ "github.com/spf13/cobra"

if respKubeconfig != nil {
details, err = yaml.MarshalWithOptions(respKubeconfig, yaml.IndentSequence(true))
details, err = yaml.MarshalWithOptions(respKubeconfig, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
} else if respLogin != nil {
details, err = yaml.MarshalWithOptions(respLogin, yaml.IndentSequence(true))
details, err = yaml.MarshalWithOptions(respLogin, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
}

@@ -279,3 +280,3 @@ if err != nil {

if respKubeconfig != nil {
expiration = fmt.Sprintf(", with expiration date %v (UTC)", *respKubeconfig.ExpirationTimestamp)
expiration = fmt.Sprintf(", with expiration date %v (UTC)", utils.ConvertTimePToDateTimeString(respKubeconfig.ExpirationTimestamp))
}

@@ -282,0 +283,0 @@ p.Outputf("Updated kubeconfig file for cluster %s in %q%s\n", model.ClusterName, kubeconfigPath, expiration)

@@ -11,2 +11,3 @@ package options

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"

@@ -19,4 +20,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/examples"

"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/stackitcloud/stackit-sdk-go/services/ske"

@@ -171,3 +171,3 @@ )

case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(options, yaml.IndentSequence(true))
details, err := yaml.MarshalWithOptions(options, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {

@@ -247,3 +247,7 @@ return fmt.Errorf("marshal SKE options: %w", err)

}
table.AddRow(*v.Version, *v.State, expirationDate, string(featureGate))
table.AddRow(
utils.PtrString(v.Version),
utils.PtrString(v.State),
expirationDate,
string(featureGate))
}

@@ -275,3 +279,9 @@ return table, nil

}
table.AddRow(*image.Name, *version.Version, *version.State, expirationDate, criNamesString)
table.AddRow(
utils.PtrString(image.Name),
utils.PtrString(version.Version),
utils.PtrString(version.State),
expirationDate,
criNamesString,
)
}

@@ -291,3 +301,7 @@ }

t := types[i]
table.AddRow(*t.Name, *t.Cpu, *t.Memory)
table.AddRow(
utils.PtrString(t.Name),
utils.PtrString(t.Cpu),
utils.PtrString(t.Memory),
)
}

@@ -305,5 +319,5 @@ return table

z := types[i]
table.AddRow(*z.Name)
table.AddRow(utils.PtrString(z.Name))
}
return table
}

@@ -34,4 +34,13 @@ package utils

GetImageResp *iaas.Image
GetAffinityGroupsFails bool
GetAffinityGroupResp *iaas.AffinityGroup
}
func (m *IaaSClientMocked) GetAffinityGroupExecute(_ context.Context, _, _ string) (*iaas.AffinityGroup, error) {
if m.GetAffinityGroupsFails {
return nil, fmt.Errorf("could not get affinity groups")
}
return m.GetAffinityGroupResp, nil
}
func (m *IaaSClientMocked) GetSecurityGroupRuleExecute(_ context.Context, _, _, _ string) (*iaas.SecurityGroupRule, error) {

@@ -719,1 +728,46 @@ if m.GetSecurityGroupRuleFails {

}
func TestGetAffinityGroupName(t *testing.T) {
tests := []struct {
name string
affinityResp *iaas.AffinityGroup
affinityErr bool
want string
wantErr bool
}{
{
name: "successful retrieval",
affinityResp: &iaas.AffinityGroup{Name: utils.Ptr("test-affinity")},
want: "test-affinity",
wantErr: false,
},
{
name: "error on retrieval",
affinityErr: true,
wantErr: true,
},
{
name: "nil affinity group name",
affinityErr: false,
affinityResp: &iaas.AffinityGroup{},
want: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := context.Background()
client := &IaaSClientMocked{
GetAffinityGroupsFails: tt.affinityErr,
GetAffinityGroupResp: tt.affinityResp,
}
got, err := GetAffinityGroupName(ctx, client, "", "")
if (err != nil) != tt.wantErr {
t.Errorf("GetAffinityGroupName() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("GetAffinityGroupName() = %v, want %v", got, tt.want)
}
})
}
}

@@ -21,2 +21,3 @@ package utils

GetImageExecute(ctx context.Context, projectId string, imageId string) (*iaas.Image, error)
GetAffinityGroupExecute(ctx context.Context, projectId string, affinityGroupId string) (*iaas.AffinityGroup, error)
}

@@ -133,1 +134,12 @@

}
func GetAffinityGroupName(ctx context.Context, apiClient IaaSClient, projectId, affinityGroupId string) (string, error) {
resp, err := apiClient.GetAffinityGroupExecute(ctx, projectId, affinityGroupId)
if err != nil {
return "", fmt.Errorf("get affinity group: %w", err)
}
if resp.Name == nil {
return "", nil
}
return *resp.Name, nil
}

@@ -23,2 +23,3 @@ package utils

testCredentialsId = "credentialsID" //nolint:gosec // linter false positive
testRegion = "eu01"
)

@@ -39,3 +40,3 @@

func (m *objectStorageClientMocked) GetServiceStatusExecute(_ context.Context, _ string) (*objectstorage.ProjectStatus, error) {
func (m *objectStorageClientMocked) GetServiceStatusExecute(_ context.Context, _, _ string) (*objectstorage.ProjectStatus, error) {
if m.getServiceStatusFails {

@@ -50,3 +51,3 @@ return nil, fmt.Errorf("could not get service status")

func (m *objectStorageClientMocked) ListCredentialsGroupsExecute(_ context.Context, _ string) (*objectstorage.ListCredentialsGroupsResponse, error) {
func (m *objectStorageClientMocked) ListCredentialsGroupsExecute(_ context.Context, _, _ string) (*objectstorage.ListCredentialsGroupsResponse, error) {
if m.listCredentialsGroupsFails {

@@ -58,3 +59,3 @@ return nil, fmt.Errorf("could not list credentials groups")

func (m *objectStorageClientMocked) ListAccessKeys(_ context.Context, _ string) objectstorage.ApiListAccessKeysRequest {
func (m *objectStorageClientMocked) ListAccessKeys(_ context.Context, _, _ string) objectstorage.ApiListAccessKeysRequest {
return m.listAccessKeysReq

@@ -96,3 +97,3 @@ }

output, err := ProjectEnabled(context.Background(), client, testProjectId)
output, err := ProjectEnabled(context.Background(), client, testProjectId, testRegion)

@@ -210,3 +211,3 @@ if tt.isValid && err != nil {

output, err := GetCredentialsGroupName(context.Background(), client, testProjectId, testCredentialsGroupId)
output, err := GetCredentialsGroupName(context.Background(), client, testProjectId, testCredentialsGroupId, testRegion)

@@ -350,3 +351,3 @@ if tt.isValid && err != nil {

output, err := GetCredentialsName(context.Background(), client, testProjectId, testCredentialsGroupId, testCredentialsId)
output, err := GetCredentialsName(context.Background(), client, testProjectId, testCredentialsGroupId, testCredentialsId, testRegion)

@@ -353,0 +354,0 @@ if tt.isValid && err != nil {

@@ -13,9 +13,9 @@ package utils

type ObjectStorageClient interface {
GetServiceStatusExecute(ctx context.Context, projectId string) (*objectstorage.ProjectStatus, error)
ListCredentialsGroupsExecute(ctx context.Context, projectId string) (*objectstorage.ListCredentialsGroupsResponse, error)
ListAccessKeys(ctx context.Context, projectId string) objectstorage.ApiListAccessKeysRequest
GetServiceStatusExecute(ctx context.Context, projectId, region string) (*objectstorage.ProjectStatus, error)
ListCredentialsGroupsExecute(ctx context.Context, projectId, region string) (*objectstorage.ListCredentialsGroupsResponse, error)
ListAccessKeys(ctx context.Context, projectId, region string) objectstorage.ApiListAccessKeysRequest
}
func ProjectEnabled(ctx context.Context, apiClient ObjectStorageClient, projectId string) (bool, error) {
_, err := apiClient.GetServiceStatusExecute(ctx, projectId)
func ProjectEnabled(ctx context.Context, apiClient ObjectStorageClient, projectId, region string) (bool, error) {
_, err := apiClient.GetServiceStatusExecute(ctx, projectId, region)
if err != nil {

@@ -34,4 +34,4 @@ oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped

func GetCredentialsGroupName(ctx context.Context, apiClient ObjectStorageClient, projectId, credentialsGroupId string) (string, error) {
resp, err := apiClient.ListCredentialsGroupsExecute(ctx, projectId)
func GetCredentialsGroupName(ctx context.Context, apiClient ObjectStorageClient, projectId, credentialsGroupId, region string) (string, error) {
resp, err := apiClient.ListCredentialsGroupsExecute(ctx, projectId, region)
if err != nil {

@@ -55,4 +55,4 @@ return "", fmt.Errorf("list Object Storage credentials groups: %w", err)

func GetCredentialsName(ctx context.Context, apiClient ObjectStorageClient, projectId, credentialsGroupId, keyId string) (string, error) {
req := apiClient.ListAccessKeys(ctx, projectId)
func GetCredentialsName(ctx context.Context, apiClient ObjectStorageClient, projectId, credentialsGroupId, keyId, region string) (string, error) {
req := apiClient.ListAccessKeys(ctx, projectId, region)
req = req.CredentialsGroup(credentialsGroupId)

@@ -59,0 +59,0 @@ resp, err := req.Execute()

@@ -27,1 +27,10 @@ package utils

}
// JoinStringPtr concatenates the strings of a string slice pointer, each separatore by the
// [sep] string.
func JoinStringPtr(vals *[]string, sep string) string {
if vals == nil || len(*vals) == 0 {
return ""
}
return strings.Join(*vals, sep)
}

@@ -10,2 +10,3 @@ package utils

"github.com/google/uuid"
"github.com/inhies/go-bytesize"
"github.com/spf13/cobra"

@@ -93,1 +94,18 @@ "github.com/spf13/viper"

}
// PtrStringDefault return the value of a pointer [v] as string. If the pointer is nil, it returns the [defaultValue].
func PtrStringDefault[T any](v *T, defaultValue string) string {
if v == nil {
return defaultValue
}
return fmt.Sprintf("%v", *v)
}
// PtrByteSizeDefault return the value of an in64 pointer to a string representation of bytesize. If the pointer is nil,
// it returns the [defaultValue].
func PtrByteSizeDefault(size *int64, defaultValue string) string {
if size == nil {
return defaultValue
}
return bytesize.New(float64(*size)).String()
}