Skip to content
Merged
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
8 changes: 8 additions & 0 deletions internal/cmd/opensearch/credentials/describe/describe.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ package describe
import (
"context"
"fmt"
"strings"

"github.com/stackitcloud/stackit-cli/internal/pkg/types"

Expand DownExpand Up@@ -121,6 +122,13 @@ func outputResult(p *print.Printer, outputFormat string, credentials *opensearch
table.AddRow("PASSWORD", utils.PtrString(credentials.Raw.Credentials.Password))
table.AddSeparator()
table.AddRow("URI", utils.PtrString(credentials.Raw.Credentials.Uri))
table.AddSeparator()
table.AddRow("HOST", utils.PtrString(credentials.Raw.Credentials.Host))
hosts := credentials.Raw.Credentials.Hosts
if hosts != nil && len(*hosts) > 0 {
table.AddSeparator()
table.AddRow("HOSTS", strings.Join(*hosts, "\n"))
}
}
err := table.Display(p)
if err != nil {
Expand Down
30 changes: 30 additions & 0 deletions internal/cmd/opensearch/credentials/describe/describe_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@ import (
"testing"

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

"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
Expand DownExpand Up@@ -220,6 +221,35 @@ func TestOutputResult(t *testing.T) {
},
wantErr: false,
},
{
name: "host and hosts",
args: args{
credentials: &opensearch.CredentialsResponse{
Raw: &opensearch.RawCredentials{
Credentials: &opensearch.Credentials{
Host: utils.Ptr("host"),
Hosts: utils.Ptr([]string{
"hosts-a",
"hosts-b",
}),
},
},
},
},
},
{
name: "raw credentials nil host & hosts",
args: args{
credentials: &opensearch.CredentialsResponse{
Raw: &opensearch.RawCredentials{
Credentials: &opensearch.Credentials{
Host: nil,
Hosts: nil,
},
},
},
},
},
}
p := print.NewPrinter()
p.Cmd = NewCmd(&types.CmdParams{Printer: p})
Expand Down
Loading