mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-05 17:16:59 +02:00
Add support for NS records in the Linode provider
This commit is contained in:
parent
d7cec324d9
commit
557174635a
@ -241,8 +241,13 @@ func (p *LinodeProvider) submitChanges(ctx context.Context, changes LinodeChange
|
||||
return nil
|
||||
}
|
||||
|
||||
func getWeight() *int {
|
||||
func getWeight(recordType linodego.DomainRecordType) *int {
|
||||
weight := 1
|
||||
|
||||
// NS records do not support having weight
|
||||
if recordType == linodego.RecordTypeNS {
|
||||
weight = 0
|
||||
}
|
||||
return &weight
|
||||
}
|
||||
|
||||
@ -331,7 +336,7 @@ func (p *LinodeProvider) ApplyChanges(ctx context.Context, changes *plan.Changes
|
||||
Target: target,
|
||||
Name: getStrippedRecordName(zone, ep),
|
||||
Type: recordType,
|
||||
Weight: getWeight(),
|
||||
Weight: getWeight(recordType),
|
||||
Port: getPort(),
|
||||
Priority: getPriority(),
|
||||
TTLSec: int(ep.RecordTTL),
|
||||
@ -395,7 +400,7 @@ func (p *LinodeProvider) ApplyChanges(ctx context.Context, changes *plan.Changes
|
||||
Target: target,
|
||||
Name: getStrippedRecordName(zone, ep),
|
||||
Type: recordType,
|
||||
Weight: getWeight(),
|
||||
Weight: getWeight(recordType),
|
||||
Port: getPort(),
|
||||
Priority: getPriority(),
|
||||
TTLSec: int(ep.RecordTTL),
|
||||
@ -419,7 +424,7 @@ func (p *LinodeProvider) ApplyChanges(ctx context.Context, changes *plan.Changes
|
||||
Target: target,
|
||||
Name: getStrippedRecordName(zone, ep),
|
||||
Type: recordType,
|
||||
Weight: getWeight(),
|
||||
Weight: getWeight(recordType),
|
||||
Port: getPort(),
|
||||
Priority: getPriority(),
|
||||
TTLSec: int(ep.RecordTTL),
|
||||
@ -515,6 +520,8 @@ func convertRecordType(recordType string) (linodego.DomainRecordType, error) {
|
||||
return linodego.RecordTypeTXT, nil
|
||||
case "SRV":
|
||||
return linodego.RecordTypeSRV, nil
|
||||
case "NS":
|
||||
return linodego.RecordTypeNS, nil
|
||||
default:
|
||||
return "", fmt.Errorf("invalid Record Type: %s", recordType)
|
||||
}
|
||||
|
@ -135,6 +135,10 @@ func TestLinodeConvertRecordType(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, linodego.RecordTypeSRV, record)
|
||||
|
||||
record, err = convertRecordType("NS")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, linodego.RecordTypeNS, record)
|
||||
|
||||
_, err = convertRecordType("INVALID")
|
||||
require.Error(t, err)
|
||||
}
|
||||
@ -333,7 +337,7 @@ func TestLinodeApplyChanges(t *testing.T) {
|
||||
11,
|
||||
linodego.DomainRecordUpdateOptions{
|
||||
Type: "A", Name: "", Target: "targetFoo",
|
||||
Priority: getPriority(), Weight: getWeight(), Port: getPort(), TTLSec: 300,
|
||||
Priority: getPriority(), Weight: getWeight(linodego.RecordTypeA), Port: getPort(), TTLSec: 300,
|
||||
},
|
||||
).Return(&linodego.DomainRecord{}, nil).Once()
|
||||
|
||||
@ -343,7 +347,7 @@ func TestLinodeApplyChanges(t *testing.T) {
|
||||
2,
|
||||
linodego.DomainRecordCreateOptions{
|
||||
Type: "A", Name: "create", Target: "targetBar",
|
||||
Priority: getPriority(), Weight: getWeight(), Port: getPort(), TTLSec: 0,
|
||||
Priority: getPriority(), Weight: getWeight(linodego.RecordTypeA), Port: getPort(), TTLSec: 0,
|
||||
},
|
||||
).Return(&linodego.DomainRecord{}, nil).Once()
|
||||
|
||||
@ -353,7 +357,7 @@ func TestLinodeApplyChanges(t *testing.T) {
|
||||
2,
|
||||
linodego.DomainRecordCreateOptions{
|
||||
Type: "A", Name: "", Target: "targetBar",
|
||||
Priority: getPriority(), Weight: getWeight(), Port: getPort(), TTLSec: 0,
|
||||
Priority: getPriority(), Weight: getWeight(linodego.RecordTypeA), Port: getPort(), TTLSec: 0,
|
||||
},
|
||||
).Return(&linodego.DomainRecord{}, nil).Once()
|
||||
|
||||
@ -423,7 +427,7 @@ func TestLinodeApplyChangesTargetAdded(t *testing.T) {
|
||||
11,
|
||||
linodego.DomainRecordUpdateOptions{
|
||||
Type: "A", Name: "", Target: "targetA",
|
||||
Priority: getPriority(), Weight: getWeight(), Port: getPort(),
|
||||
Priority: getPriority(), Weight: getWeight(linodego.RecordTypeA), Port: getPort(),
|
||||
},
|
||||
).Return(&linodego.DomainRecord{}, nil).Once()
|
||||
|
||||
@ -433,7 +437,7 @@ func TestLinodeApplyChangesTargetAdded(t *testing.T) {
|
||||
1,
|
||||
linodego.DomainRecordCreateOptions{
|
||||
Type: "A", Name: "", Target: "targetB",
|
||||
Priority: getPriority(), Weight: getWeight(), Port: getPort(),
|
||||
Priority: getPriority(), Weight: getWeight(linodego.RecordTypeA), Port: getPort(),
|
||||
},
|
||||
).Return(&linodego.DomainRecord{}, nil).Once()
|
||||
|
||||
@ -482,7 +486,7 @@ func TestLinodeApplyChangesTargetRemoved(t *testing.T) {
|
||||
12,
|
||||
linodego.DomainRecordUpdateOptions{
|
||||
Type: "A", Name: "", Target: "targetB",
|
||||
Priority: getPriority(), Weight: getWeight(), Port: getPort(),
|
||||
Priority: getPriority(), Weight: getWeight(linodego.RecordTypeA), Port: getPort(),
|
||||
},
|
||||
).Return(&linodego.DomainRecord{}, nil).Once()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user