Skip to content

Commit 9aa4856

Browse files
chore(logme,mariadb,opensearch,rabbitmq,redis): deprecate planName and version flags, remove planId validation
1 parent a9f0177 commit 9aa4856

16 files changed

Lines changed: 141 additions & 233 deletions

File tree

internal/cmd/logme/instance/create/create.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const (
3535
sgwAclFlag = "acl"
3636
syslogFlag = "syslog"
3737
planIdFlag = "plan-id"
38-
planNameFlag = "plan-name"
39-
versionFlag = "version"
38+
planNameFlag = "plan-name" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
39+
versionFlag = "version" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
4040
)
4141

4242
type inputModel struct {
@@ -62,9 +62,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6262
Long: "Creates a LogMe instance.",
6363
Args: args.NoArgs,
6464
Example: examples.Build(
65-
examples.NewExample(
66-
`Create a LogMe instance with name "my-instance" and specify plan by name and version`,
67-
"$ stackit logme instance create --name my-instance --plan-name stackit-logme2-1.2.50-replica --version 2"),
6865
examples.NewExample(
6966
`Create a LogMe instance with name "my-instance" and specify plan by ID`,
7067
"$ stackit logme instance create --name my-instance --plan-id xxx"),
@@ -145,6 +142,11 @@ func configureFlags(cmd *cobra.Command) {
145142

146143
err := flags.MarkFlagsRequired(cmd, instanceNameFlag)
147144
cobra.CheckErr(err)
145+
146+
err = cmd.Flags().MarkDeprecated(planNameFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
147+
cobra.CheckErr(err)
148+
err = cmd.Flags().MarkDeprecated(versionFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
149+
cobra.CheckErr(err)
148150
}
149151

150152
func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) {
@@ -191,15 +193,14 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient logme.Defaul
191193
req := apiClient.CreateInstance(ctx, model.ProjectId, model.Region)
192194

193195
var planId *string
194-
var err error
195-
196-
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute()
197-
if err != nil {
198-
return req, fmt.Errorf("get LogMe offerings: %w", err)
199-
}
200196

201197
if model.PlanId == nil {
202-
planId, err = logmeUtils.LoadPlanId(model.PlanName, model.Version, offerings)
198+
// Deprecated: resolving a plan by --plan-name/--version will be removed after 2027-02-28. Use --plan-id instead.
199+
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute()
200+
if err != nil {
201+
return req, fmt.Errorf("get LogMe offerings: %w", err)
202+
}
203+
planId, err = logmeUtils.LoadPlanId(model.PlanName, model.Version, offerings) //nolint:staticcheck // deprecated but still supported until 2027-02-28
203204
if err != nil {
204205
var dsaInvalidPlanError *cliErr.DSAInvalidPlanError
205206
if !errors.As(err, &dsaInvalidPlanError) {
@@ -208,10 +209,6 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient logme.Defaul
208209
return req, err
209210
}
210211
} else {
211-
err := logmeUtils.ValidatePlanId(*model.PlanId, offerings)
212-
if err != nil {
213-
return req, err
214-
}
215212
planId = model.PlanId
216213
}
217214

internal/cmd/logme/instance/update/update.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const (
3636
sgwAclFlag = "acl"
3737
syslogFlag = "syslog"
3838
planIdFlag = "plan-id"
39-
planNameFlag = "plan-name"
40-
versionFlag = "version"
39+
planNameFlag = "plan-name" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
40+
versionFlag = "version" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
4141
)
4242

4343
type inputModel struct {
@@ -146,6 +146,11 @@ func configureFlags(cmd *cobra.Command) {
146146
cmd.Flags().String(planNameFlag, "", "Plan name")
147147
cmd.Flags().String(versionFlag, "", "Instance LogMe version")
148148
cmd.Flags().StringP(instanceNameFlag, "n", "", "Instance name")
149+
150+
err := cmd.Flags().MarkDeprecated(planNameFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
151+
cobra.CheckErr(err)
152+
err = cmd.Flags().MarkDeprecated(versionFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
153+
cobra.CheckErr(err)
149154
}
150155

151156
func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) {
@@ -206,15 +211,14 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient logme.Defaul
206211
req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.Region, model.InstanceId)
207212

208213
var planId *string
209-
var err error
210-
211-
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute()
212-
if err != nil {
213-
return req, fmt.Errorf("get LogMe offerings: %w", err)
214-
}
215214

216215
if model.PlanId == nil && model.PlanName != "" && model.Version != "" {
217-
planId, err = logmeUtils.LoadPlanId(model.PlanName, model.Version, offerings)
216+
// Deprecated: resolving a plan by --plan-name/--version will be removed after 2027-02-28. Use --plan-id instead.
217+
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute()
218+
if err != nil {
219+
return req, fmt.Errorf("get LogMe offerings: %w", err)
220+
}
221+
planId, err = logmeUtils.LoadPlanId(model.PlanName, model.Version, offerings) //nolint:staticcheck // deprecated but still supported until 2027-02-28
218222
if err != nil {
219223
var dsaInvalidPlanError *cliErr.DSAInvalidPlanError
220224
if !errors.As(err, &dsaInvalidPlanError) {
@@ -224,12 +228,6 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient logme.Defaul
224228
}
225229
} else {
226230
// planId is not required for update operation
227-
if model.PlanId != nil {
228-
err := logmeUtils.ValidatePlanId(*model.PlanId, offerings)
229-
if err != nil {
230-
return req, err
231-
}
232-
}
233231
planId = model.PlanId
234232
}
235233

internal/cmd/mariadb/instance/create/create.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const (
3535
sgwAclFlag = "acl"
3636
syslogFlag = "syslog"
3737
planIdFlag = "plan-id"
38-
planNameFlag = "plan-name"
39-
versionFlag = "version"
38+
planNameFlag = "plan-name" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
39+
versionFlag = "version" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
4040
)
4141

4242
type inputModel struct {
@@ -62,9 +62,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6262
Long: "Creates a MariaDB instance.",
6363
Args: args.NoArgs,
6464
Example: examples.Build(
65-
examples.NewExample(
66-
`Create a MariaDB instance with name "my-instance" and specify plan by name and version`,
67-
"$ stackit mariadb instance create --name my-instance --plan-name stackit-mariadb-1.2.10-replica --version 10.6"),
6865
examples.NewExample(
6966
`Create a MariaDB instance with name "my-instance" and specify plan by ID`,
7067
"$ stackit mariadb instance create --name my-instance --plan-id xxx"),
@@ -144,6 +141,11 @@ func configureFlags(cmd *cobra.Command) {
144141

145142
err := flags.MarkFlagsRequired(cmd, instanceNameFlag)
146143
cobra.CheckErr(err)
144+
145+
err = cmd.Flags().MarkDeprecated(planNameFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
146+
cobra.CheckErr(err)
147+
err = cmd.Flags().MarkDeprecated(versionFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
148+
cobra.CheckErr(err)
147149
}
148150

149151
func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) {
@@ -190,15 +192,14 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient mariadb.Defa
190192
req := apiClient.CreateInstance(ctx, model.ProjectId, model.Region)
191193

192194
var planId *string
193-
var err error
194-
195-
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute()
196-
if err != nil {
197-
return req, fmt.Errorf("get MariaDB offerings: %w", err)
198-
}
199195

200196
if model.PlanId == nil {
201-
planId, err = mariadbUtils.LoadPlanId(model.PlanName, model.Version, offerings)
197+
// Deprecated: resolving a plan by --plan-name/--version will be removed after 2027-02-28. Use --plan-id instead.
198+
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute()
199+
if err != nil {
200+
return req, fmt.Errorf("get MariaDB offerings: %w", err)
201+
}
202+
planId, err = mariadbUtils.LoadPlanId(model.PlanName, model.Version, offerings) //nolint:staticcheck // deprecated but still supported until 2027-02-28
202203
if err != nil {
203204
var dsaInvalidPlanError *cliErr.DSAInvalidPlanError
204205
if !errors.As(err, &dsaInvalidPlanError) {
@@ -207,10 +208,6 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient mariadb.Defa
207208
return req, err
208209
}
209210
} else {
210-
err := mariadbUtils.ValidatePlanId(*model.PlanId, offerings)
211-
if err != nil {
212-
return req, err
213-
}
214211
planId = model.PlanId
215212
}
216213
var sgwAcl *string

internal/cmd/mariadb/instance/update/update.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const (
3535
sgwAclFlag = "acl"
3636
syslogFlag = "syslog"
3737
planIdFlag = "plan-id"
38-
planNameFlag = "plan-name"
39-
versionFlag = "version"
38+
planNameFlag = "plan-name" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
39+
versionFlag = "version" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
4040
)
4141

4242
type inputModel struct {
@@ -143,6 +143,11 @@ func configureFlags(cmd *cobra.Command) {
143143
cmd.Flags().Var(flags.UUIDFlag(), planIdFlag, "Plan ID")
144144
cmd.Flags().String(planNameFlag, "", "Plan name")
145145
cmd.Flags().String(versionFlag, "", "Instance MariaDB version")
146+
147+
err := cmd.Flags().MarkDeprecated(planNameFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
148+
cobra.CheckErr(err)
149+
err = cmd.Flags().MarkDeprecated(versionFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
150+
cobra.CheckErr(err)
146151
}
147152

148153
func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) {
@@ -201,15 +206,14 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient mariadb.Defa
201206
req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.Region, model.InstanceId)
202207

203208
var planId *string
204-
var err error
205-
206-
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute()
207-
if err != nil {
208-
return req, fmt.Errorf("get MariaDB offerings: %w", err)
209-
}
210209

211210
if model.PlanId == nil && model.PlanName != "" && model.Version != "" {
212-
planId, err = mariadbUtils.LoadPlanId(model.PlanName, model.Version, offerings)
211+
// Deprecated: resolving a plan by --plan-name/--version will be removed after 2027-02-28. Use --plan-id instead.
212+
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute()
213+
if err != nil {
214+
return req, fmt.Errorf("get MariaDB offerings: %w", err)
215+
}
216+
planId, err = mariadbUtils.LoadPlanId(model.PlanName, model.Version, offerings) //nolint:staticcheck // deprecated but still supported until 2027-02-28
213217
if err != nil {
214218
var dsaInvalidPlanError *cliErr.DSAInvalidPlanError
215219
if !errors.As(err, &dsaInvalidPlanError) {
@@ -219,12 +223,6 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient mariadb.Defa
219223
}
220224
} else {
221225
// planId is not required for update operation
222-
if model.PlanId != nil {
223-
err := mariadbUtils.ValidatePlanId(*model.PlanId, offerings)
224-
if err != nil {
225-
return req, err
226-
}
227-
}
228226
planId = model.PlanId
229227
}
230228

internal/cmd/opensearch/instance/create/create.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const (
3535
sgwAclFlag = "acl"
3636
syslogFlag = "syslog"
3737
planIdFlag = "plan-id"
38-
planNameFlag = "plan-name"
39-
versionFlag = "version"
38+
planNameFlag = "plan-name" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
39+
versionFlag = "version" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
4040
)
4141

4242
var flagPlugins = flags.StringEnumSliceFlag("plugin", opensearch.AllowedInstanceParametersPluginsInnerEnumValues, "Plugins")
@@ -65,9 +65,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6565
Long: "Creates an OpenSearch instance.",
6666
Args: args.NoArgs,
6767
Example: examples.Build(
68-
examples.NewExample(
69-
`Create an OpenSearch instance with name "my-instance" and specify plan by name and version`,
70-
"$ stackit opensearch instance create --name my-instance --plan-name stackit-opensearch-1.2.10-replica --version 2"),
7168
examples.NewExample(
7269
`Create an OpenSearch instance with name "my-instance" and specify plan by ID`,
7370
"$ stackit opensearch instance create --name my-instance --plan-id xxx"),
@@ -148,6 +145,11 @@ func configureFlags(cmd *cobra.Command) {
148145

149146
err := flags.MarkFlagsRequired(cmd, instanceNameFlag)
150147
cobra.CheckErr(err)
148+
149+
err = cmd.Flags().MarkDeprecated(planNameFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
150+
cobra.CheckErr(err)
151+
err = cmd.Flags().MarkDeprecated(versionFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
152+
cobra.CheckErr(err)
151153
}
152154

153155
func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) {
@@ -193,22 +195,22 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
193195

194196
type openSearchClient interface {
195197
CreateInstance(ctx context.Context, projectId, region string) opensearch.ApiCreateInstanceRequest
198+
// Deprecated: resolving a plan by --plan-name/--version will be removed after 2027-02-28. Use --plan-id instead.
196199
ListOfferings(ctx context.Context, projectId, region string) opensearch.ApiListOfferingsRequest
197200
}
198201

199202
func buildRequest(ctx context.Context, model *inputModel, apiClient openSearchClient) (opensearch.ApiCreateInstanceRequest, error) {
200203
req := apiClient.CreateInstance(ctx, model.ProjectId, model.Region)
201204

202205
var planId string
203-
var err error
204-
205-
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute()
206-
if err != nil {
207-
return req, fmt.Errorf("get OpenSearch offerings: %w", err)
208-
}
209206

210207
if model.PlanId == "" {
211-
planId, err = opensearchUtils.LoadPlanId(model.PlanName, model.Version, offerings)
208+
// Deprecated: resolving a plan by --plan-name/--version will be removed after 2027-02-28. Use --plan-id instead.
209+
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute() //nolint:staticcheck // deprecated but still supported until 2027-02-28
210+
if err != nil {
211+
return req, fmt.Errorf("get OpenSearch offerings: %w", err)
212+
}
213+
planId, err = opensearchUtils.LoadPlanId(model.PlanName, model.Version, offerings) //nolint:staticcheck // deprecated but still supported until 2027-02-28
212214
if err != nil {
213215
var dsaInvalidPlanError *cliErr.DSAInvalidPlanError
214216
if !errors.As(err, &dsaInvalidPlanError) {
@@ -217,10 +219,6 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient openSearchCl
217219
return req, err
218220
}
219221
} else {
220-
err := opensearchUtils.ValidatePlanId(model.PlanId, offerings)
221-
if err != nil {
222-
return req, err
223-
}
224222
planId = model.PlanId
225223
}
226224

internal/cmd/opensearch/instance/update/update.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const (
3636
sgwAclFlag = "acl"
3737
syslogFlag = "syslog"
3838
planIdFlag = "plan-id"
39-
planNameFlag = "plan-name"
40-
versionFlag = "version"
39+
planNameFlag = "plan-name" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
40+
versionFlag = "version" // Deprecated: Will be removed after 2027-02-28. Use --plan-id instead.
4141
)
4242

4343
var flagPlugins = flags.StringEnumSliceFlag(
@@ -152,6 +152,11 @@ func configureFlags(cmd *cobra.Command) {
152152
cmd.Flags().Var(flags.UUIDFlag(), planIdFlag, "Plan ID")
153153
cmd.Flags().String(planNameFlag, "", "Plan name")
154154
cmd.Flags().String(versionFlag, "", "Instance OpenSearch version")
155+
156+
err := cmd.Flags().MarkDeprecated(planNameFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
157+
cobra.CheckErr(err)
158+
err = cmd.Flags().MarkDeprecated(versionFlag, "Will be removed after 2027-02-28. Use the --plan-id flag instead.")
159+
cobra.CheckErr(err)
155160
}
156161

157162
func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) {
@@ -210,22 +215,22 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
210215

211216
type openSearchClient interface {
212217
PartialUpdateInstance(ctx context.Context, projectId, region, instanceId string) opensearch.ApiPartialUpdateInstanceRequest
218+
// Deprecated: resolving a plan by --plan-name/--version will be removed after 2027-02-28. Use --plan-id instead.
213219
ListOfferings(ctx context.Context, projectId, region string) opensearch.ApiListOfferingsRequest
214220
}
215221

216222
func buildRequest(ctx context.Context, model *inputModel, apiClient openSearchClient) (opensearch.ApiPartialUpdateInstanceRequest, error) {
217223
req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.Region, model.InstanceId)
218224

219225
var planId *string
220-
var err error
221-
222-
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute()
223-
if err != nil {
224-
return req, fmt.Errorf("get OpenSearch offerings: %w", err)
225-
}
226226

227227
if model.PlanId == nil && model.PlanName != "" && model.Version != "" {
228-
foundPlanId, err := opensearchUtils.LoadPlanId(model.PlanName, model.Version, offerings)
228+
// Deprecated: resolving a plan by --plan-name/--version will be removed after 2027-02-28. Use --plan-id instead.
229+
offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute() //nolint:staticcheck // deprecated but still supported until 2027-02-28
230+
if err != nil {
231+
return req, fmt.Errorf("get OpenSearch offerings: %w", err)
232+
}
233+
foundPlanId, err := opensearchUtils.LoadPlanId(model.PlanName, model.Version, offerings) //nolint:staticcheck // deprecated but still supported until 2027-02-28
229234
if err != nil {
230235
var dsaInvalidPlanError *cliErr.DSAInvalidPlanError
231236
if !errors.As(err, &dsaInvalidPlanError) {
@@ -236,10 +241,6 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient openSearchCl
236241
planId = &foundPlanId
237242
} else if model.PlanId != nil {
238243
// planId is not required for update operation
239-
err := opensearchUtils.ValidatePlanId(*model.PlanId, offerings)
240-
if err != nil {
241-
return req, err
242-
}
243244
planId = model.PlanId
244245
}
245246

0 commit comments

Comments
 (0)