Skip to content

Commit 6de7f7d

Browse files
committed
Merge remote-tracking branch 'origin/main' into refac/NO-ISSUE-use-generic-enum-flags-for-string-backed-enums
2 parents 0a9b757 + ff16fb4 commit 6de7f7d

35 files changed

Lines changed: 384 additions & 357 deletions

docs/stackit_beta_intake_runner_delete.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ stackit beta intake runner delete RUNNER_ID [flags]
1515
```
1616
Delete an Intake Runner with ID "xxx"
1717
$ stackit beta intake runner delete xxx
18+
19+
Delete an Intake Runner with ID "xxx", along with all associated Intakes and Intake Users that would stop the removal of the Intake
20+
$ stackit beta intake runner delete xxx --force
1821
```
1922

2023
### Options
2124

2225
```
23-
-h, --help Help for "stackit beta intake runner delete"
26+
--force When true, also removes all associated Intakes and Intake Users that would stop the removal of the Intake
27+
-h, --help Help for "stackit beta intake runner delete"
2428
```
2529

2630
### Options inherited from parent commands

docs/stackit_dns_record-set_create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ stackit dns record-set create [flags]
2424
-h, --help Help for "stackit dns record-set create"
2525
--name string Name of the record, should be compliant with RFC1035, Section 2.3.4
2626
--record strings Records belonging to the record set
27-
--ttl int Time to live, if not provided defaults to the zone's default TTL
27+
--ttl int32 Time to live, if not provided defaults to the zone's default TTL
2828
--type string Record type, (one of: [A, AAAA, SOA, CNAME, NS, MX, TXT, SRV, PTR, ALIAS, DNAME, CAA, DNSKEY, DS, LOC, NAPTR, SSHFP, TLSA, URI, CERT, SVCB, TYPE, CSYNC, HINFO, HTTPS]) (default "A")
2929
--zone-id string Zone ID
3030
```

docs/stackit_dns_record-set_update.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ stackit dns record-set update RECORD_SET_ID [flags]
2424
-h, --help Help for "stackit dns record-set update"
2525
--name string Name of the record, should be compliant with RFC1035, Section 2.3.4
2626
--record strings Records belonging to the record set. If this flag is used, records already created that aren't set when running the command will be deleted
27-
--ttl int Time to live, if not provided defaults to the zone's default TTL
27+
--ttl int32 Time to live, if not provided defaults to the zone's default TTL
2828
--zone-id string Zone ID
2929
```
3030

docs/stackit_dns_zone_create.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ stackit dns zone create [flags]
2525
```
2626
--acl string Access control list
2727
--contact-email string Contact email for the zone
28-
--default-ttl int Default time to live (default 1000)
28+
--default-ttl int32 Default time to live (default 1000)
2929
--description string Description of the zone
3030
--dns-name string Fully qualified domain name of the DNS zone
31-
--expire-time int Expire time
31+
--expire-time int32 Expire time
3232
-h, --help Help for "stackit dns zone create"
3333
--is-reverse-zone Is reverse zone
3434
--name string User given name of the zone
35-
--negative-cache int Negative cache
35+
--negative-cache int32 Negative cache
3636
--primary strings Primary name server for secondary zone
37-
--refresh-time int Refresh time
38-
--retry-time int Retry time
39-
--type string Zone type, (one of: [primary, secondary, ])
37+
--refresh-time int32 Refresh time
38+
--retry-time int32 Retry time
39+
--type string Zone type, (one of: [primary, secondary])
4040
```
4141

4242
### Options inherited from parent commands

docs/stackit_dns_zone_update.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ stackit dns zone update ZONE_ID [flags]
2222
```
2323
--acl string Access control list
2424
--contact-email string Contact email for the zone
25-
--default-ttl int Default time to live (default 1000)
25+
--default-ttl int32 Default time to live (default 1000)
2626
--description string Description of the zone
27-
--expire-time int Expire time
27+
--expire-time int32 Expire time
2828
-h, --help Help for "stackit dns zone update"
2929
--name string User given name of the zone
30-
--negative-cache int Negative cache
30+
--negative-cache int32 Negative cache
3131
--primary strings Primary name server for secondary zone
32-
--refresh-time int Refresh time
33-
--retry-time int Retry time
32+
--refresh-time int32 Refresh time
33+
--retry-time int32 Retry time
3434
```
3535

3636
### Options inherited from parent commands

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/stackitcloud/stackit-sdk-go/services/alb v0.14.2
2020
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0
2121
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.16.0
22-
github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.6
22+
github.com/stackitcloud/stackit-sdk-go/services/dns v0.21.0
2323
github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3
2424
github.com/stackitcloud/stackit-sdk-go/services/git v0.14.0
2525
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.12.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,8 @@ github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0 h1:HxPgBu0
602602
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0/go.mod h1:uYI9pHAA2g84jJN25ejFUxa0/JtfpPZqMDkctQ1BzJk=
603603
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.16.0 h1:Wqxx0PDTL2F5gqI5jjznuJY0TdqECltjA0aa/rHY63U=
604604
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.16.0/go.mod h1:MHB1N3EQ9GuAduAQoNS+gb1MjrWJieszbpOso9TQv5s=
605-
github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.6 h1:GBRb49x5Nax/oQQaaf2F3kKwv8DQQOL0TQOC0C/v/Ew=
606-
github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.6/go.mod h1:IX9iL3MigDZUmzwswTJMfYvyi118KAHrFMfjJUy5NYk=
605+
github.com/stackitcloud/stackit-sdk-go/services/dns v0.21.0 h1:ZVkptfVCAqpaPWkE+WIopM9XdzqgbVcwmX5L1jZqqx8=
606+
github.com/stackitcloud/stackit-sdk-go/services/dns v0.21.0/go.mod h1:FiYSv3D9rzgEVzi8Mpq5oYZBosrasa5uUYqVdEIbM1U=
607607
github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3 h1:TxChb2qbO82JiQEBYClSSD5HZxqKeKJ6dIvkEUCJmbs=
608608
github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3/go.mod h1:KVWvQHb7CQLD9DzA4Np3WmakiCCsrHaCXvFEnOQ7nPk=
609609
github.com/stackitcloud/stackit-sdk-go/services/git v0.14.0 h1:VZBneGprCmHqckcSMPs3puBlK8rBpLMtYKmBktwdoVE=

internal/cmd/beta/intake/runner/delete/delete.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66

7+
"github.com/stackitcloud/stackit-cli/internal/pkg/flags"
78
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
89

910
"github.com/spf13/cobra"
@@ -21,13 +22,15 @@ import (
2122
)
2223

2324
const (
24-
runnerIdArg = "RUNNER_ID"
25+
runnerIdArg = "RUNNER_ID"
26+
forceDeleteFlag = "force"
2527
)
2628

2729
// inputModel struct holds all the input parameters for the command
2830
type inputModel struct {
2931
*globalflags.GlobalFlagModel
30-
RunnerId string
32+
RunnerId string
33+
ForceDelete bool
3134
}
3235

3336
// NewCmd creates a new cobra command for deleting an Intake Runner
@@ -41,6 +44,9 @@ func NewCmd(p *types.CmdParams) *cobra.Command {
4144
examples.NewExample(
4245
`Delete an Intake Runner with ID "xxx"`,
4346
`$ stackit beta intake runner delete xxx`),
47+
examples.NewExample(
48+
`Delete an Intake Runner with ID "xxx", along with all associated Intakes and Intake Users that would stop the removal of the Intake`,
49+
`$ stackit beta intake runner delete xxx --force`),
4450
),
4551
RunE: func(cmd *cobra.Command, args []string) error {
4652
ctx := context.Background()
@@ -56,6 +62,9 @@ func NewCmd(p *types.CmdParams) *cobra.Command {
5662
}
5763

5864
prompt := fmt.Sprintf("Are you sure you want to delete Intake Runner %q?", model.RunnerId)
65+
if model.ForceDelete {
66+
prompt = fmt.Sprintf("%s This will also remove all Intakes and Intake Users that would stop the removal of the Intake", prompt)
67+
}
5968
err = p.Printer.PromptForConfirmation(prompt)
6069
if err != nil {
6170
return err
@@ -87,9 +96,14 @@ func NewCmd(p *types.CmdParams) *cobra.Command {
8796
return nil
8897
},
8998
}
99+
configureFlags(cmd)
90100
return cmd
91101
}
92102

103+
func configureFlags(cmd *cobra.Command) {
104+
cmd.Flags().Bool(forceDeleteFlag, false, "When true, also removes all associated Intakes and Intake Users that would stop the removal of the Intake")
105+
}
106+
93107
// parseInput parses the command arguments and flags into a standardized model
94108
func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) {
95109
runnerId := inputArgs[0]
@@ -102,6 +116,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
102116
model := inputModel{
103117
GlobalFlagModel: globalFlags,
104118
RunnerId: runnerId,
119+
ForceDelete: flags.FlagToBoolValue(p, cmd, forceDeleteFlag),
105120
}
106121

107122
p.DebugInputModel(model)
@@ -111,5 +126,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
111126
// buildRequest creates the API request to delete an Intake Runner
112127
func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiDeleteIntakeRunnerRequest {
113128
req := apiClient.DefaultAPI.DeleteIntakeRunner(ctx, model.ProjectId, model.Region, model.RunnerId)
129+
if model.ForceDelete {
130+
return req.Force(true)
131+
}
114132
return req
115133
}

internal/cmd/beta/intake/runner/delete/delete_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ func TestParseInput(t *testing.T) {
9494
isValid: true,
9595
expectedModel: fixtureInputModel(),
9696
},
97+
{
98+
description: "with force",
99+
argValues: fixtureArgValues(),
100+
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
101+
flagValues[forceDeleteFlag] = "true"
102+
}),
103+
isValid: true,
104+
expectedModel: fixtureInputModel(func(model *inputModel) {
105+
model.ForceDelete = true
106+
}),
107+
},
97108
{
98109
description: "no arg values",
99110
argValues: []string{},
@@ -140,6 +151,13 @@ func TestBuildRequest(t *testing.T) {
140151
model: fixtureInputModel(),
141152
expectedRequest: fixtureRequest(),
142153
},
154+
{
155+
description: "with force",
156+
model: fixtureInputModel(func(model *inputModel) {
157+
model.ForceDelete = true
158+
}),
159+
expectedRequest: fixtureRequest().Force(true),
160+
},
143161
}
144162

145163
for _, tt := range tests {

internal/cmd/dns/record-set/create/create.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/stackitcloud/stackit-sdk-go/services/dns/wait"
7+
"github.com/stackitcloud/stackit-sdk-go/services/dns/v1api/wait"
88

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

1111
"github.com/spf13/cobra"
12-
"github.com/stackitcloud/stackit-sdk-go/services/dns"
12+
dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api"
1313

1414
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
1515
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -20,7 +20,6 @@ import (
2020
"github.com/stackitcloud/stackit-cli/internal/pkg/services/dns/client"
2121
dnsUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/dns/utils"
2222
"github.com/stackitcloud/stackit-cli/internal/pkg/spinner"
23-
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
2423
)
2524

2625
const (
@@ -36,7 +35,7 @@ const (
3635

3736
var typeFlag = flags.StringEnumFlag(
3837
"type",
39-
dns.AllowedCreateRecordSetPayloadTypesEnumValues,
38+
dns.AllowedCreateRecordSetPayloadTypeEnumValues,
4039
"Record type,",
4140
flags.StringEnumDefaultValue(defaultType),
4241
)
@@ -47,8 +46,8 @@ type inputModel struct {
4746
Comment *string
4847
Name *string
4948
Records []string
50-
TTL *int64
51-
Type dns.CreateRecordSetPayloadTypes
49+
TTL *int32
50+
Type dns.CreateRecordSetPayloadType
5251
}
5352

5453
func NewCmd(params *types.CmdParams) *cobra.Command {
@@ -75,7 +74,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7574
return err
7675
}
7776

78-
zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient, model.ProjectId, model.ZoneId)
77+
zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId)
7978
if err != nil {
8079
params.Printer.Debug(print.ErrorLevel, "get zone name: %v", err)
8180
zoneLabel = model.ZoneId
@@ -93,12 +92,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
9392
if err != nil {
9493
return fmt.Errorf("create DNS record set: %w", err)
9594
}
96-
recordSetId := *resp.Rrset.Id
95+
recordSetId := resp.Rrset.Id
9796

9897
// Wait for async operation, if async mode not enabled
9998
if !model.Async {
10099
err := spinner.Run(params.Printer, "Creating record set", func() error {
101-
_, err = wait.CreateRecordSetWaitHandler(ctx, apiClient, model.ProjectId, model.ZoneId, recordSetId).WaitWithContext(ctx)
100+
_, err = wait.CreateRecordSetWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId, recordSetId).WaitWithContext(ctx)
102101
return err
103102
})
104103
if err != nil {
@@ -117,7 +116,7 @@ func configureFlags(cmd *cobra.Command) {
117116
cmd.Flags().Var(flags.UUIDFlag(), zoneIdFlag, "Zone ID")
118117
cmd.Flags().String(commentFlag, "", "User comment")
119118
cmd.Flags().String(nameFlag, "", "Name of the record, should be compliant with RFC1035, Section 2.3.4")
120-
cmd.Flags().Int64(ttlFlag, 0, "Time to live, if not provided defaults to the zone's default TTL")
119+
cmd.Flags().Int32(ttlFlag, 0, "Time to live, if not provided defaults to the zone's default TTL")
121120
cmd.Flags().StringSlice(recordFlag, []string{}, "Records belonging to the record set")
122121
typeFlag.Register(cmd.Flags())
123122

@@ -137,7 +136,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
137136
Comment: flags.FlagToStringPointer(p, cmd, commentFlag),
138137
Name: flags.FlagToStringPointer(p, cmd, nameFlag),
139138
Records: flags.FlagToStringSliceValue(p, cmd, recordFlag),
140-
TTL: flags.FlagToInt64Pointer(p, cmd, ttlFlag),
139+
TTL: flags.FlagToInt32Pointer(p, cmd, ttlFlag),
141140
Type: typeFlag.Get(),
142141
}
143142

@@ -162,16 +161,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
162161
func buildRequest(ctx context.Context, model *inputModel, apiClient *dns.APIClient) dns.ApiCreateRecordSetRequest {
163162
records := make([]dns.RecordPayload, 0)
164163
for _, r := range model.Records {
165-
records = append(records, dns.RecordPayload{Content: utils.Ptr(r)})
164+
records = append(records, dns.RecordPayload{Content: r})
166165
}
167166

168-
req := apiClient.CreateRecordSet(ctx, model.ProjectId, model.ZoneId)
167+
req := apiClient.DefaultAPI.CreateRecordSet(ctx, model.ProjectId, model.ZoneId)
169168
req = req.CreateRecordSetPayload(dns.CreateRecordSetPayload{
170169
Comment: model.Comment,
171-
Name: model.Name,
172-
Records: &records,
170+
Name: *model.Name,
171+
Records: records,
173172
Ttl: model.TTL,
174-
Type: &model.Type,
173+
Type: model.Type,
175174
})
176175
return req
177176
}
@@ -185,7 +184,7 @@ func outputResult(p *print.Printer, model *inputModel, zoneLabel string, resp *d
185184
if model.Async {
186185
operationState = "Triggered creation of"
187186
}
188-
p.Outputf("%s record set for zone %s. Record set ID: %s\n", operationState, zoneLabel, utils.PtrString(resp.Rrset.Id))
187+
p.Outputf("%s record set for zone %s. Record set ID: %s\n", operationState, zoneLabel, resp.Rrset.Id)
189188
return nil
190189
})
191190
}

0 commit comments

Comments
 (0)