diff --git a/internal/cmd/server/describe/describe.go b/internal/cmd/server/describe/describe.go index 85444e6ec..50a1065c8 100644 --- a/internal/cmd/server/describe/describe.go +++ b/internal/cmd/server/describe/describe.go @@ -18,6 +18,7 @@ import ( "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" ) @@ -118,7 +119,11 @@ func outputResult(p *print.Printer, outputFormat string, server *iaas.Server) er return nil case print.YAMLOutputFormat: - details, err := yaml.MarshalWithOptions(server, yaml.IndentSequence(true), yaml.UseJSONMarshaler()) + converted, err := sdkutils.ConvertByteArraysToBase64(server) + 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) } diff --git a/internal/cmd/server/list/list.go b/internal/cmd/server/list/list.go index 29eb51222..850f3d228 100644 --- a/internal/cmd/server/list/list.go +++ b/internal/cmd/server/list/list.go @@ -19,6 +19,7 @@ import ( "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" ) @@ -158,7 +159,17 @@ func outputResult(p *print.Printer, outputFormat string, servers []iaas.Server) 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) + 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) }