Skip to content

Commit 211fd43

Browse files
committed
remove associated resource id from update command
1 parent e445d3c commit 211fd43

File tree

3 files changed

+12
-40
lines changed

3 files changed

+12
-40
lines changed

docs/stackit_beta_public-ip_update.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@ stackit beta public-ip update [flags]
1616
Update public IP with ID "xxx"
1717
$ stackit beta public-ip update xxx
1818
19-
Update public IP with ID "xxx" with new associated resource ID "yyy"
20-
$ stackit beta public-ip update xxx --associated-resource-id yyy
21-
2219
Update public IP with ID "xxx" with new labels
2320
$ stackit beta public-ip update xxx --labels key=value,foo=bar
2421
```
2522

2623
### Options
2724

2825
```
29-
--associated-resource-id string Associates the public IP with a network interface or virtual IP (ID)
30-
-h, --help Help for "stackit beta public-ip update"
31-
--labels stringToString Labels are key-value string pairs which can be attached to a public IP. E.g. '--labels key1=value1,key2=value2,...' (default [])
26+
-h, --help Help for "stackit beta public-ip update"
27+
--labels stringToString Labels are key-value string pairs which can be attached to a public IP. E.g. '--labels key1=value1,key2=value2,...' (default [])
3228
```
3329

3430
### Options inherited from parent commands

internal/cmd/beta/public-ip/update/update.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ import (
2323
const (
2424
publicIpIdArg = "PUBLIC_IP_ID"
2525

26-
associatedResourceIdFlag = "associated-resource-id"
27-
labelFlag = "labels"
26+
labelFlag = "labels"
2827
)
2928

3029
type inputModel struct {
3130
*globalflags.GlobalFlagModel
32-
PublicIpId string
33-
AssociatedResourceId *string
34-
Labels *map[string]string
31+
PublicIpId string
32+
Labels *map[string]string
3533
}
3634

3735
func NewCmd(p *print.Printer) *cobra.Command {
@@ -45,10 +43,6 @@ func NewCmd(p *print.Printer) *cobra.Command {
4543
`Update public IP with ID "xxx"`,
4644
`$ stackit beta public-ip update xxx`,
4745
),
48-
examples.NewExample(
49-
`Update public IP with ID "xxx" with new associated resource ID "yyy"`,
50-
`$ stackit beta public-ip update xxx --associated-resource-id yyy`,
51-
),
5246
examples.NewExample(
5347
`Update public IP with ID "xxx" with new labels`,
5448
`$ stackit beta public-ip update xxx --labels key=value,foo=bar`,
@@ -96,7 +90,6 @@ func NewCmd(p *print.Printer) *cobra.Command {
9690
}
9791

9892
func configureFlags(cmd *cobra.Command) {
99-
cmd.Flags().Var(flags.UUIDFlag(), associatedResourceIdFlag, "Associates the public IP with a network interface or virtual IP (ID)")
10093
cmd.Flags().StringToString(labelFlag, nil, "Labels are key-value string pairs which can be attached to a public IP. E.g. '--labels key1=value1,key2=value2,...'")
10194
}
10295

@@ -109,10 +102,9 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
109102
}
110103

111104
model := inputModel{
112-
GlobalFlagModel: globalFlags,
113-
PublicIpId: publicIpId,
114-
AssociatedResourceId: flags.FlagToStringPointer(p, cmd, associatedResourceIdFlag),
115-
Labels: flags.FlagToStringToStringPointer(p, cmd, labelFlag),
105+
GlobalFlagModel: globalFlags,
106+
PublicIpId: publicIpId,
107+
Labels: flags.FlagToStringToStringPointer(p, cmd, labelFlag),
116108
}
117109

118110
if p.IsVerbosityDebug() {
@@ -140,8 +132,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
140132
}
141133

142134
payload := iaas.UpdatePublicIPPayload{
143-
NetworkInterface: iaas.NewNullableString(model.AssociatedResourceId),
144-
Labels: labelsMap,
135+
Labels: labelsMap,
145136
}
146137

147138
return req.UpdatePublicIPPayload(payload)

internal/cmd/beta/public-ip/update/update_test.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2222
var testClient = &iaas.APIClient{}
2323

2424
var testProjectId = uuid.NewString()
25-
var testAssociatedResourceId = uuid.NewString()
2625
var testPublicIpId = uuid.NewString()
2726

2827
func fixtureArgValues(mods ...func(argValues []string)) []string {
@@ -37,9 +36,8 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {
3736

3837
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3938
flagValues := map[string]string{
40-
projectIdFlag: testProjectId,
41-
associatedResourceIdFlag: testAssociatedResourceId,
42-
labelFlag: "key=value",
39+
projectIdFlag: testProjectId,
40+
labelFlag: "key=value",
4341
}
4442
for _, mod := range mods {
4543
mod(flagValues)
@@ -53,8 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5351
ProjectId: testProjectId,
5452
Verbosity: globalflags.VerbosityDefault,
5553
},
56-
PublicIpId: testPublicIpId,
57-
AssociatedResourceId: utils.Ptr(testAssociatedResourceId),
54+
PublicIpId: testPublicIpId,
5855
Labels: utils.Ptr(map[string]string{
5956
"key": "value",
6057
}),
@@ -76,7 +73,6 @@ func fixtureRequest(mods ...func(request *iaas.ApiUpdatePublicIPRequest)) iaas.A
7673

7774
func fixturePayload(mods ...func(payload *iaas.UpdatePublicIPPayload)) iaas.UpdatePublicIPPayload {
7875
payload := iaas.UpdatePublicIPPayload{
79-
NetworkInterface: iaas.NewNullableString(utils.Ptr(testAssociatedResourceId)),
8076
Labels: utils.Ptr(map[string]interface{}{
8177
"key": "value",
8278
}),
@@ -144,17 +140,6 @@ func TestParseInput(t *testing.T) {
144140
flagValues: fixtureFlagValues(),
145141
isValid: false,
146142
},
147-
{
148-
description: "use associated resource id",
149-
argValues: fixtureArgValues(),
150-
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
151-
flagValues[associatedResourceIdFlag] = testAssociatedResourceId
152-
}),
153-
isValid: true,
154-
expectedModel: fixtureInputModel(func(model *inputModel) {
155-
model.AssociatedResourceId = utils.Ptr(testAssociatedResourceId)
156-
}),
157-
},
158143
{
159144
description: "use labels",
160145
argValues: fixtureArgValues(),

0 commit comments

Comments
 (0)