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