From 670e3e2d8e4895dd115f8c2bb2f977f1e988606c Mon Sep 17 00:00:00 2001 From: Michele Giornetta Date: Tue, 5 Nov 2024 08:39:14 +0100 Subject: [PATCH] add support for NS records (#483) * add support for NS records --- cmd/domain/domain.go | 2 +- cmd/domain/domain_record_create.go | 14 +++++++++----- go.mod | 2 +- go.sum | 2 ++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/domain/domain.go b/cmd/domain/domain.go index 8c425a3e..ee7c5d0f 100644 --- a/cmd/domain/domain.go +++ b/cmd/domain/domain.go @@ -50,7 +50,7 @@ func init() { Flags for domain record create cmd */ domainRecordCreateCmd.Flags().StringVarP(&recordName, "name", "n", "", "the name of the record") - domainRecordCreateCmd.Flags().StringVarP(&recordType, "type", "e", "", "type of the record (A, CNAME, TXT, SRV, MX)") + domainRecordCreateCmd.Flags().StringVarP(&recordType, "type", "e", "", "type of the record (A, CNAME, TXT, SRV, MX, NS)") domainRecordCreateCmd.Flags().StringVarP(&recordValue, "value", "v", "", "the value of the record") domainRecordCreateCmd.Flags().IntVarP(&recordTTL, "ttl", "t", 600, "The TTL of the record") domainRecordCreateCmd.Flags().IntVarP(&recordPriority, "priority", "p", 0, "the priority of record only for SRV and MX record") diff --git a/cmd/domain/domain_record_create.go b/cmd/domain/domain_record_create.go index 12e963bb..59522dba 100644 --- a/cmd/domain/domain_record_create.go +++ b/cmd/domain/domain_record_create.go @@ -45,26 +45,30 @@ var domainRecordCreateCmd = &cobra.Command{ // Sanitace the record type recordType = strings.ReplaceAll(recordType, " ", "") - if recordType == "A" || recordType == "alias" { + if recordType == "A" || recordType == "a" || recordType == "alias" { newRecordConfig.Type = civogo.DNSRecordTypeA } - if recordType == "CNAME" || recordType == "canonical" { + if recordType == "CNAME" || recordType == "cname" || recordType == "canonical" { newRecordConfig.Type = civogo.DNSRecordTypeCName } - if recordType == "MX" || recordType == "mail" { + if recordType == "MX" || recordType == "mx" || recordType == "mail" { newRecordConfig.Type = civogo.DNSRecordTypeMX } - if recordType == "TXT" || recordType == "text" { + if recordType == "TXT" || recordType == "txt" || recordType == "text" { newRecordConfig.Type = civogo.DNSRecordTypeTXT } - if recordType == "SRV" || recordType == "service" { + if recordType == "SRV" || recordType == "srv" || recordType == "service" { newRecordConfig.Type = civogo.DNSRecordTypeSRV } + if recordType == "NS" || recordType == "ns" || recordType == "nameserver" { + newRecordConfig.Type = civogo.DNSRecordTypeNS + } + record, err := client.CreateDNSRecord(domain.ID, newRecordConfig) if err != nil { utility.Error("%s", err) diff --git a/go.mod b/go.mod index b0dc2162..e2b3d372 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect github.com/briandowns/spinner v1.11.1 github.com/c4milo/unpackit v0.0.0-20170704181138-4ed373e9ef1c // indirect - github.com/civo/civogo v0.3.84 + github.com/civo/civogo v0.3.85 github.com/dsnet/compress v0.0.1 // indirect github.com/fatih/color v1.13.0 // indirect github.com/google/go-github v17.0.0+incompatible // indirect diff --git a/go.sum b/go.sum index f4933630..34f3958f 100644 --- a/go.sum +++ b/go.sum @@ -56,6 +56,8 @@ github.com/c4milo/unpackit v0.0.0-20170704181138-4ed373e9ef1c/go.mod h1:Ie6SubJv github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/civo/civogo v0.3.84 h1:jf5IT7VJFPaReO6g8B0zqKhsYCIizaGo4PjDLY7Sl6Y= github.com/civo/civogo v0.3.84/go.mod h1:7UCYX+qeeJbrG55E1huv+0ySxcHTqq/26FcHLVelQJM= +github.com/civo/civogo v0.3.85 h1:rXRbDT9B60Ocp/IxAoAs90yAJog2la1MajQqgXETxd4= +github.com/civo/civogo v0.3.85/go.mod h1:7UCYX+qeeJbrG55E1huv+0ySxcHTqq/26FcHLVelQJM= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=