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
2 changes: 1 addition & 1 deletion docs/stackit_redis_instance_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ stackit redis instance create [flags]
--enable-monitoring Enable monitoring
--graphite string Graphite host
-h, --help Help for "stackit redis instance create"
--metrics-frequency int Metrics frequency
--metrics-frequency int32 Metrics frequency
--metrics-prefix string Metrics prefix
--monitoring-instance-id string Monitoring instance ID
-n, --name string Instance name
Expand Down
2 changes: 1 addition & 1 deletion docs/stackit_redis_instance_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ stackit redis instance update INSTANCE_ID [flags]
--enable-monitoring Enable monitoring
--graphite string Graphite host
-h, --help Help for "stackit redis instance update"
--metrics-frequency int Metrics frequency
--metrics-frequency int32 Metrics frequency
--metrics-prefix string Metrics prefix
--monitoring-instance-id string Monitoring instance ID
--plan-id string Plan ID
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0
github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0
github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6
github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0
github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0
github.com/subosito/gotenv v1.6.0 // indirect
golang.org/x/sys v0.43.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,8 @@ github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5 h1:H67e3KnHQ
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5/go.mod h1:xmAWk9eom8wznvLuLfm0F4xyeiBX8LaggXsKFmos+dw=
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0 h1:HRJwodJX4aOn/487zaqJIKw13yIj4T6dn7/kEHLxeTg=
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0/go.mod h1:TwfVVynB/+AKbccSOLk2qZpPL1tdK43BBAiACP6EtSg=
github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6 h1:CXM9cZ9WeTyJd+Aw/hnJnDsKRVAQi4qgtd0RJ3zoPwo=
github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6/go.mod h1:KJNceOHRefjku1oVBoHG7idCS/SeW42WJ+55bN3AxrQ=
github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0 h1:ckYMRXAGE2/vaxPeNGEuun9AGcFn/8xuu0ytfsiqfWU=
github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0/go.mod h1:yjej6QfYoYdRIyKXlmbVz8fZYxbuUdl+QBkvLDPgA4k=
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 h1:JPP6a0ME1tZXr4iB69d/LtJsCAr58ENBadFaK9f48/c=
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0/go.mod h1:NEz3f+GV5G++BE9/MmZCsXJyCih7jtg0pZuSyG2sLEs=
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3 h1:AiGNJmpQ/f9cglaIQQ4SyePbtCI3K1DQLNvqVN9jKSo=
Expand Down
27 changes: 12 additions & 15 deletions internal/cmd/redis/credentials/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-sdk-go/services/redis"
redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api"
)

const (
Expand Down Expand Up @@ -58,7 +58,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return err
}

instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId)
instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err)
instanceLabel = model.InstanceId
Expand Down Expand Up @@ -109,7 +109,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APIClient) redis.ApiCreateCredentialsRequest {
req := apiClient.CreateCredentials(ctx, model.ProjectId, model.InstanceId)
req := apiClient.DefaultAPI.CreateCredentials(ctx, model.ProjectId, model.Region, model.InstanceId)
return req
}

Expand All @@ -122,30 +122,27 @@ func outputResult(p *print.Printer, model inputModel, instanceLabel string, resp
}
if !model.ShowPassword {
if resp.Raw == nil {
resp.Raw = &redis.RawCredentials{}
resp.Raw = &redis.RawCredentials{Credentials: redis.Credentials{}}
}
if resp.Raw.Credentials == nil {
resp.Raw.Credentials = &redis.Credentials{}
}
resp.Raw.Credentials.Password = utils.Ptr("hidden")
resp.Raw.Credentials.Password = "hidden"
}

return p.OutputResult(model.OutputFormat, resp, func() error {
p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, utils.PtrString(resp.Id))
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
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 resp.HasRaw() {
if username := resp.Raw.Credentials.Username; 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("Password: %s\n", resp.Raw.Credentials.Password)
}
p.Outputf("Host: %s\n", utils.PtrString(resp.Raw.Credentials.Host))
p.Outputf("Host: %s\n", resp.Raw.Credentials.Host)
p.Outputf("Port: %s\n", utils.PtrString(resp.Raw.Credentials.Port))
}
p.Outputf("URI: %s\n", utils.PtrString(resp.Uri))
p.Outputf("URI: %s\n", resp.Uri)
return nil
})
}
15 changes: 9 additions & 6 deletions internal/cmd/redis/credentials/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-sdk-go/services/redis"
redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api"

"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/testparams"
Expand All @@ -19,14 +19,16 @@ var projectIdFlag = globalflags.ProjectIdFlag
type testCtxKey struct{}

var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &redis.APIClient{}
var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}}
var testProjectId = uuid.NewString()
var testInstanceId = uuid.NewString()
var testRegion = "eu01"

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
instanceIdFlag: testInstanceId,
projectIdFlag: testProjectId,
instanceIdFlag: testInstanceId,
globalflags.RegionFlag: testRegion,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -39,6 +41,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},
InstanceId: testInstanceId,
}
Expand All @@ -49,7 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *redis.ApiCreateCredentialsRequest)) redis.ApiCreateCredentialsRequest {
request := testClient.CreateCredentials(testCtx, testProjectId, testInstanceId)
request := testClient.DefaultAPI.CreateCredentials(testCtx, testProjectId, testRegion, testInstanceId)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -154,7 +157,7 @@ func TestBuildRequest(t *testing.T) {
request := buildRequest(testCtx, tt.model, testClient)

diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}),
cmpopts.EquateComparable(testCtx),
)
if diff != "" {
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/redis/credentials/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-sdk-go/services/redis"
redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api"
)

const (
Expand Down Expand Up @@ -56,13 +56,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return err
}

instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId)
instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err)
instanceLabel = model.InstanceId
}

credentialsLabel, err := redisUtils.GetCredentialsUsername(ctx, apiClient, model.ProjectId, model.InstanceId, model.CredentialsId)
credentialsLabel, err := redisUtils.GetCredentialsUsername(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.CredentialsId, model.Region)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get credentials user name: %v", err)
credentialsLabel = model.CredentialsId
Expand Down Expand Up @@ -115,6 +115,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APIClient) redis.ApiDeleteCredentialsRequest {
req := apiClient.DeleteCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId)
req := apiClient.DefaultAPI.DeleteCredentials(ctx, model.ProjectId, model.Region, model.InstanceId, model.CredentialsId)
return req
}
15 changes: 9 additions & 6 deletions internal/cmd/redis/credentials/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-sdk-go/services/redis"
redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api"
)

var projectIdFlag = globalflags.ProjectIdFlag

type testCtxKey struct{}

var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &redis.APIClient{}
var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}}
var testProjectId = uuid.NewString()
var testInstanceId = uuid.NewString()
var testCredentialsId = uuid.NewString()
var testRegion = "eu01"

func fixtureArgValues(mods ...func(argValues []string)) []string {
argValues := []string{
Expand All @@ -35,8 +36,9 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
instanceIdFlag: testInstanceId,
projectIdFlag: testProjectId,
instanceIdFlag: testInstanceId,
globalflags.RegionFlag: testRegion,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -49,6 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},
InstanceId: testInstanceId,
CredentialsId: testCredentialsId,
Expand All @@ -60,7 +63,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *redis.ApiDeleteCredentialsRequest)) redis.ApiDeleteCredentialsRequest {
request := testClient.DeleteCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId)
request := testClient.DefaultAPI.DeleteCredentials(testCtx, testProjectId, testRegion, testInstanceId, testCredentialsId)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -187,7 +190,7 @@ func TestBuildRequest(t *testing.T) {
request := buildRequest(testCtx, tt.model, testClient)

diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}),
cmpopts.EquateComparable(testCtx),
)
if diff != "" {
Expand Down
14 changes: 7 additions & 7 deletions internal/cmd/redis/credentials/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-sdk-go/services/redis"
redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api"
)

const (
Expand Down Expand Up @@ -99,7 +99,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APIClient) redis.ApiGetCredentialsRequest {
req := apiClient.GetCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId)
req := apiClient.DefaultAPI.GetCredentials(ctx, model.ProjectId, model.Region, model.InstanceId, model.CredentialsId)
return req
}

Expand All @@ -110,15 +110,15 @@ func outputResult(p *print.Printer, outputFormat string, credentials *redis.Cred

return p.OutputResult(outputFormat, credentials, func() error {
table := tables.NewTable()
table.AddRow("ID", utils.PtrString(credentials.Id))
table.AddRow("ID", credentials.Id)
table.AddSeparator()
// The username field cannot be set by the user so we only display it if it's not returned empty
if credentials.HasRaw() && credentials.Raw.Credentials != nil {
if username := credentials.Raw.Credentials.Username; username != nil && *username != "" {
table.AddRow("USERNAME", *username)
if credentials.HasRaw() {
if username := credentials.Raw.Credentials.Username; username != "" {
table.AddRow("USERNAME", username)
table.AddSeparator()
}
table.AddRow("PASSWORD", utils.PtrString(credentials.Raw.Credentials.Password))
table.AddRow("PASSWORD", credentials.Raw.Credentials.Password)
table.AddSeparator()
table.AddRow("URI", utils.PtrString(credentials.Raw.Credentials.Uri))
}
Expand Down
15 changes: 9 additions & 6 deletions internal/cmd/redis/credentials/describe/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-sdk-go/services/redis"
redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api"

"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/testparams"
Expand All @@ -19,10 +19,11 @@ var projectIdFlag = globalflags.ProjectIdFlag
type testCtxKey struct{}

var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &redis.APIClient{}
var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}}
var testProjectId = uuid.NewString()
var testInstanceId = uuid.NewString()
var testCredentialsId = uuid.NewString()
var testRegion = "eu01"

func fixtureArgValues(mods ...func(argValues []string)) []string {
argValues := []string{
Expand All @@ -36,8 +37,9 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
instanceIdFlag: testInstanceId,
projectIdFlag: testProjectId,
instanceIdFlag: testInstanceId,
globalflags.RegionFlag: testRegion,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -50,6 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Verbosity: globalflags.VerbosityDefault,
Region: testRegion,
},
InstanceId: testInstanceId,
CredentialsId: testCredentialsId,
Expand All @@ -61,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *redis.ApiGetCredentialsRequest)) redis.ApiGetCredentialsRequest {
request := testClient.GetCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId)
request := testClient.DefaultAPI.GetCredentials(testCtx, testProjectId, testRegion, testInstanceId, testCredentialsId)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -188,7 +191,7 @@ func TestBuildRequest(t *testing.T) {
request := buildRequest(testCtx, tt.model, testClient)

diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}),
cmpopts.EquateComparable(testCtx),
)
if diff != "" {
Expand Down
Loading
Loading