Skip to content

Commit

Permalink
add support for NS records (#483)
Browse files Browse the repository at this point in the history
* add support for NS records
  • Loading branch information
giornetta authored Nov 5, 2024
1 parent 7f2195b commit 670e3e2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
14 changes: 9 additions & 5 deletions cmd/domain/domain_record_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 670e3e2

Please sign in to comment.