Skip to content

Commit 165d335

Browse files
committed
fix: compile errors
1 parent 297071d commit 165d335

File tree

23 files changed

+77
-67
lines changed

23 files changed

+77
-67
lines changed

docs/stackit_dns_record-set_create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ stackit dns record-set create [flags]
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
2727
--ttl int Time to live, if not provided defaults to the zone's default TTL
28-
--type string Record type, one of ["A" "AAAA" "SOA" "CNAME" "NS" "MX" "TXT" "SRV" "PTR" "ALIAS" "DNAME" "CAA"] (default "A")
28+
--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"] (default "A")
2929
--zone-id string Zone ID
3030
```
3131

docs/stackit_dns_zone_create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ stackit dns zone create [flags]
3636
--primary strings Primary name server for secondary zone
3737
--refresh-time int Refresh time
3838
--retry-time int Retry time
39-
--type string Zone type
39+
--type string Zone type, one of: ["primary" "secondary"]
4040
```
4141

4242
### Options inherited from parent commands

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ const (
3030
ttlFlag = "ttl"
3131
typeFlag = "type"
3232

33-
defaultType = "A"
34-
txtType = "TXT"
33+
defaultType = dns.CREATERECORDSETPAYLOADTYPE_A
34+
txtType = dns.CREATERECORDSETPAYLOADTYPE_TXT
3535
)
3636

3737
type inputModel struct {
@@ -41,7 +41,7 @@ type inputModel struct {
4141
Name *string
4242
Records []string
4343
TTL *int64
44-
Type string
44+
Type dns.CreateRecordSetPayloadTypes
4545
}
4646

4747
func NewCmd(params *params.CmdParams) *cobra.Command {
@@ -109,14 +109,17 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
109109
}
110110

111111
func configureFlags(cmd *cobra.Command) {
112-
typeFlagOptions := []string{"A", "AAAA", "SOA", "CNAME", "NS", "MX", "TXT", "SRV", "PTR", "ALIAS", "DNAME", "CAA"}
112+
var typeFlagOptions []string
113+
for _, val := range dns.AllowedCreateRecordSetPayloadTypesEnumValues {
114+
typeFlagOptions = append(typeFlagOptions, string(val))
115+
}
113116

114117
cmd.Flags().Var(flags.UUIDFlag(), zoneIdFlag, "Zone ID")
115118
cmd.Flags().String(commentFlag, "", "User comment")
116119
cmd.Flags().String(nameFlag, "", "Name of the record, should be compliant with RFC1035, Section 2.3.4")
117120
cmd.Flags().Int64(ttlFlag, 0, "Time to live, if not provided defaults to the zone's default TTL")
118121
cmd.Flags().StringSlice(recordFlag, []string{}, "Records belonging to the record set")
119-
cmd.Flags().Var(flags.EnumFlag(false, defaultType, typeFlagOptions...), typeFlag, fmt.Sprintf("Record type, one of %q", typeFlagOptions))
122+
cmd.Flags().Var(flags.EnumFlag(false, string(defaultType), typeFlagOptions...), typeFlag, fmt.Sprintf("Record type, one of %q", typeFlagOptions))
120123

121124
err := flags.MarkFlagsRequired(cmd, zoneIdFlag, nameFlag, recordFlag)
122125
cobra.CheckErr(err)
@@ -128,14 +131,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
128131
return nil, &errors.ProjectIdError{}
129132
}
130133

134+
recordType := flags.FlagWithDefaultToStringValue(p, cmd, typeFlag)
135+
131136
model := inputModel{
132137
GlobalFlagModel: globalFlags,
133138
ZoneId: flags.FlagToStringValue(p, cmd, zoneIdFlag),
134139
Comment: flags.FlagToStringPointer(p, cmd, commentFlag),
135140
Name: flags.FlagToStringPointer(p, cmd, nameFlag),
136141
Records: flags.FlagToStringSliceValue(p, cmd, recordFlag),
137142
TTL: flags.FlagToInt64Pointer(p, cmd, ttlFlag),
138-
Type: flags.FlagWithDefaultToStringValue(p, cmd, typeFlag),
143+
Type: dns.CreateRecordSetPayloadTypes(recordType),
139144
}
140145

141146
if model.Type == txtType {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func fixtureRequest(mods ...func(request *dns.ApiCreateRecordSetRequest)) dns.Ap
7575
{Content: utils.Ptr("1.1.1.1")},
7676
},
7777
Ttl: utils.Ptr(int64(3600)),
78-
Type: utils.Ptr("SOA"),
78+
Type: dns.CREATERECORDSETPAYLOADTYPE_SOA.Ptr(),
7979
})
8080
for _, mod := range mods {
8181
mod(&request)
@@ -247,7 +247,7 @@ func TestParseInput(t *testing.T) {
247247
{
248248
description: "TXT record with > 255 characters",
249249
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
250-
flagValues[typeFlag] = txtType
250+
flagValues[typeFlag] = string(txtType)
251251
flagValues[recordFlag] = strings.Join(recordTxtOver255Char, "")
252252
}),
253253
isValid: true,

internal/cmd/dns/zone/create/create.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type inputModel struct {
4646
DefaultTTL *int64
4747
Primaries *[]string
4848
Acl *string
49-
Type *string
49+
Type *dns.CreateZonePayloadTypes
5050
RetryTime *int64
5151
RefreshTime *int64
5252
NegativeCache *int64
@@ -124,12 +124,17 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
124124
}
125125

126126
func configureFlags(cmd *cobra.Command) {
127+
var typeFlagOptions []string
128+
for _, val := range dns.AllowedCreateZonePayloadTypesEnumValues {
129+
typeFlagOptions = append(typeFlagOptions, string(val))
130+
}
131+
127132
cmd.Flags().String(nameFlag, "", "User given name of the zone")
128133
cmd.Flags().String(dnsNameFlag, "", "Fully qualified domain name of the DNS zone")
129134
cmd.Flags().Int64(defaultTTLFlag, 1000, "Default time to live")
130135
cmd.Flags().StringSlice(primaryFlag, []string{}, "Primary name server for secondary zone")
131136
cmd.Flags().String(aclFlag, "", "Access control list")
132-
cmd.Flags().String(typeFlag, "", "Zone type")
137+
cmd.Flags().Var(flags.EnumFlag(false, "", append(typeFlagOptions, "")...), typeFlag, fmt.Sprintf("Zone type, one of: %q", typeFlagOptions))
133138
cmd.Flags().Int64(retryTimeFlag, 0, "Retry time")
134139
cmd.Flags().Int64(refreshTimeFlag, 0, "Refresh time")
135140
cmd.Flags().Int64(negativeCacheFlag, 0, "Negative cache")
@@ -148,14 +153,19 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
148153
return nil, &errors.ProjectIdError{}
149154
}
150155

156+
var zoneType *dns.CreateZonePayloadTypes
157+
if zoneTypeString := flags.FlagToStringPointer(p, cmd, typeFlag); zoneTypeString != nil && *zoneTypeString != "" {
158+
zoneType = dns.CreateZonePayloadTypes(*zoneTypeString).Ptr()
159+
}
160+
151161
model := inputModel{
152162
GlobalFlagModel: globalFlags,
153163
Name: flags.FlagToStringPointer(p, cmd, nameFlag),
154164
DnsName: flags.FlagToStringPointer(p, cmd, dnsNameFlag),
155165
DefaultTTL: flags.FlagToInt64Pointer(p, cmd, defaultTTLFlag),
156166
Primaries: flags.FlagToStringSlicePointer(p, cmd, primaryFlag),
157167
Acl: flags.FlagToStringPointer(p, cmd, aclFlag),
158-
Type: flags.FlagToStringPointer(p, cmd, typeFlag),
168+
Type: zoneType,
159169
RetryTime: flags.FlagToInt64Pointer(p, cmd, retryTimeFlag),
160170
RefreshTime: flags.FlagToInt64Pointer(p, cmd, refreshTimeFlag),
161171
NegativeCache: flags.FlagToInt64Pointer(p, cmd, negativeCacheFlag),

internal/cmd/dns/zone/create/create_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st
2929
dnsNameFlag: "example.com",
3030
defaultTTLFlag: "3600",
3131
aclFlag: "0.0.0.0/0",
32-
typeFlag: "master",
32+
typeFlag: string(dns.CREATEZONEPAYLOADTYPE_PRIMARY),
3333
primaryFlag: "1.1.1.1",
3434
retryTimeFlag: "600",
3535
refreshTimeFlag: "3600",
@@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5656
DefaultTTL: utils.Ptr(int64(3600)),
5757
Primaries: utils.Ptr([]string{"1.1.1.1"}),
5858
Acl: utils.Ptr("0.0.0.0/0"),
59-
Type: utils.Ptr("master"),
59+
Type: dns.CREATEZONEPAYLOADTYPE_PRIMARY.Ptr(),
6060
RetryTime: utils.Ptr(int64(600)),
6161
RefreshTime: utils.Ptr(int64(3600)),
6262
NegativeCache: utils.Ptr(int64(60)),
@@ -79,7 +79,7 @@ func fixtureRequest(mods ...func(request *dns.ApiCreateZoneRequest)) dns.ApiCrea
7979
DefaultTTL: utils.Ptr(int64(3600)),
8080
Primaries: utils.Ptr([]string{"1.1.1.1"}),
8181
Acl: utils.Ptr("0.0.0.0/0"),
82-
Type: utils.Ptr("master"),
82+
Type: dns.CREATEZONEPAYLOADTYPE_PRIMARY.Ptr(),
8383
RetryTime: utils.Ptr(int64(600)),
8484
RefreshTime: utils.Ptr(int64(3600)),
8585
NegativeCache: utils.Ptr(int64(60)),
@@ -139,7 +139,6 @@ func TestParseInput(t *testing.T) {
139139
defaultTTLFlag: "0",
140140
aclFlag: "",
141141
typeFlag: "",
142-
primaryFlag: "",
143142
retryTimeFlag: "0",
144143
refreshTimeFlag: "0",
145144
negativeCacheFlag: "0",
@@ -157,9 +156,9 @@ func TestParseInput(t *testing.T) {
157156
Name: utils.Ptr(""),
158157
DnsName: utils.Ptr(""),
159158
DefaultTTL: utils.Ptr(int64(0)),
160-
Primaries: utils.Ptr([]string{}),
159+
Primaries: nil,
161160
Acl: utils.Ptr(""),
162-
Type: utils.Ptr(""),
161+
Type: nil,
163162
RetryTime: utils.Ptr(int64(0)),
164163
RefreshTime: utils.Ptr(int64(0)),
165164
NegativeCache: utils.Ptr(int64(0)),

internal/cmd/load-balancer/create/create_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var testPayload = &loadbalancer.CreateLoadBalancerPayload{
3636
{
3737
DisplayName: utils.Ptr(""),
3838
Port: utils.Ptr(int64(0)),
39-
Protocol: utils.Ptr(""),
39+
Protocol: loadbalancer.ListenerProtocol("").Ptr(),
4040
ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{
4141
{
4242
Name: utils.Ptr(""),
@@ -55,7 +55,7 @@ var testPayload = &loadbalancer.CreateLoadBalancerPayload{
5555
Networks: &[]loadbalancer.Network{
5656
{
5757
NetworkId: utils.Ptr(""),
58-
Role: utils.Ptr(""),
58+
Role: loadbalancer.NetworkRole("").Ptr(),
5959
},
6060
},
6161
Options: &loadbalancer.LoadBalancerOptions{

internal/cmd/load-balancer/generate-payload/generate_payload.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var (
3535
defaultPayloadListener = &loadbalancer.Listener{
3636
DisplayName: utils.Ptr(""),
3737
Port: utils.Ptr(int64(0)),
38-
Protocol: utils.Ptr(""),
38+
Protocol: loadbalancer.ListenerProtocol("").Ptr(),
3939
ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{
4040
{
4141
Name: utils.Ptr(""),
@@ -52,7 +52,7 @@ var (
5252

5353
defaultPayloadNetwork = &loadbalancer.Network{
5454
NetworkId: utils.Ptr(""),
55-
Role: utils.Ptr(""),
55+
Role: loadbalancer.NetworkRole("").Ptr(),
5656
}
5757

5858
defaultPayloadTargetPool = &loadbalancer.TargetPool{

internal/cmd/load-balancer/generate-payload/generate_payload_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func TestModifyListeners(t *testing.T) {
226226
{
227227
DisplayName: utils.Ptr(""),
228228
Port: utils.Ptr(int64(0)),
229-
Protocol: utils.Ptr(""),
229+
Protocol: loadbalancer.ListenerProtocol("").Ptr(),
230230
Name: utils.Ptr(""),
231231
ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{
232232
{
@@ -244,7 +244,7 @@ func TestModifyListeners(t *testing.T) {
244244
{
245245
DisplayName: utils.Ptr(""),
246246
Port: utils.Ptr(int64(0)),
247-
Protocol: utils.Ptr(""),
247+
Protocol: loadbalancer.ListenerProtocol("").Ptr(),
248248
Name: utils.Ptr(""),
249249
ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{
250250
{
@@ -265,7 +265,7 @@ func TestModifyListeners(t *testing.T) {
265265
{
266266
DisplayName: utils.Ptr(""),
267267
Port: utils.Ptr(int64(0)),
268-
Protocol: utils.Ptr(""),
268+
Protocol: loadbalancer.ListenerProtocol("").Ptr(),
269269
Name: nil,
270270
ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{
271271
{
@@ -283,7 +283,7 @@ func TestModifyListeners(t *testing.T) {
283283
{
284284
DisplayName: utils.Ptr(""),
285285
Port: utils.Ptr(int64(0)),
286-
Protocol: utils.Ptr(""),
286+
Protocol: loadbalancer.ListenerProtocol("").Ptr(),
287287
Name: nil,
288288
ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{
289289
{

internal/cmd/load-balancer/update/update_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var testPayload = loadbalancer.UpdateLoadBalancerPayload{
3333
{
3434
DisplayName: utils.Ptr(""),
3535
Port: utils.Ptr(int64(0)),
36-
Protocol: utils.Ptr(""),
36+
Protocol: loadbalancer.ListenerProtocol("").Ptr(),
3737
ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{
3838
{
3939
Name: utils.Ptr(""),
@@ -52,7 +52,7 @@ var testPayload = loadbalancer.UpdateLoadBalancerPayload{
5252
Networks: &[]loadbalancer.Network{
5353
{
5454
NetworkId: utils.Ptr(""),
55-
Role: utils.Ptr(""),
55+
Role: loadbalancer.NetworkRole("").Ptr(),
5656
},
5757
},
5858
Options: &loadbalancer.LoadBalancerOptions{

0 commit comments

Comments
 (0)