@@ -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
3737type 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
4747func NewCmd (params * params.CmdParams ) * cobra.Command {
@@ -109,14 +109,17 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
109109}
110110
111111func 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 {
0 commit comments