Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/cmd/server/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
sdkutils "github.com/stackitcloud/stackit-sdk-go/core/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
)

Expand Down Expand Up @@ -118,7 +119,11 @@

return nil
case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(server, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
converted, err := sdkutils.ConvertByteArraysToBase64(server)

Check failure on line 122 in internal/cmd/server/describe/describe.go

View workflow job for this annotation

GitHub Actions / CI

undefined: sdkutils.ConvertByteArraysToBase64
if err != nil {
return fmt.Errorf("convert server for YAML: %w", err)
}
details, err := yaml.MarshalWithOptions(converted, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {
return fmt.Errorf("marshal server: %w", err)
}
Expand Down
13 changes: 12 additions & 1 deletion internal/cmd/server/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

"github.com/goccy/go-yaml"
"github.com/spf13/cobra"
sdkutils "github.com/stackitcloud/stackit-sdk-go/core/utils"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
)

Expand Down Expand Up @@ -158,7 +159,17 @@

return nil
case print.YAMLOutputFormat:
details, err := yaml.MarshalWithOptions(servers, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
// Convert each server to map with base64 encoded byte arrays
convertedServers := make([]map[string]interface{}, len(servers))
for i, server := range servers {
converted, err := sdkutils.ConvertByteArraysToBase64(server)

Check failure on line 165 in internal/cmd/server/list/list.go

View workflow job for this annotation

GitHub Actions / CI

undefined: sdkutils.ConvertByteArraysToBase64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about JSON output? Isn't the adjustment also needed there?

if err != nil {
return fmt.Errorf("convert server for YAML: %w", err)
}
convertedServers[i] = converted
}

details, err := yaml.MarshalWithOptions(convertedServers, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
if err != nil {
return fmt.Errorf("marshal server: %w", err)
}
Expand Down
Loading