mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 17:46:57 +02:00
fix: infoblox provider has switched to string pointer
This commit is contained in:
parent
93e23d8e87
commit
5f6df47056
@ -215,28 +215,28 @@ func (p *ProviderConfig) Records(ctx context.Context) (endpoints []*endpoint.End
|
|||||||
// Check if endpoint already exists and add to existing endpoint if it does
|
// Check if endpoint already exists and add to existing endpoint if it does
|
||||||
foundExisting := false
|
foundExisting := false
|
||||||
for _, ep := range endpoints {
|
for _, ep := range endpoints {
|
||||||
if ep.DNSName == res.Name && ep.RecordType == endpoint.RecordTypeA {
|
if ep.DNSName == *res.Name && ep.RecordType == endpoint.RecordTypeA {
|
||||||
foundExisting = true
|
foundExisting = true
|
||||||
duplicateTarget := false
|
duplicateTarget := false
|
||||||
|
|
||||||
for _, t := range ep.Targets {
|
for _, t := range ep.Targets {
|
||||||
if t == res.Ipv4Addr {
|
if t == *res.Ipv4Addr {
|
||||||
duplicateTarget = true
|
duplicateTarget = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if duplicateTarget {
|
if duplicateTarget {
|
||||||
logrus.Debugf("A duplicate target '%s' found for existing A record '%s'", res.Ipv4Addr, ep.DNSName)
|
logrus.Debugf("A duplicate target '%s' found for existing A record '%s'", *res.Ipv4Addr, ep.DNSName)
|
||||||
} else {
|
} else {
|
||||||
logrus.Debugf("Adding target '%s' to existing A record '%s'", res.Ipv4Addr, res.Name)
|
logrus.Debugf("Adding target '%s' to existing A record '%s'", *res.Ipv4Addr, *res.Name)
|
||||||
ep.Targets = append(ep.Targets, res.Ipv4Addr)
|
ep.Targets = append(ep.Targets, *res.Ipv4Addr)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !foundExisting {
|
if !foundExisting {
|
||||||
newEndpoint := endpoint.NewEndpoint(res.Name, endpoint.RecordTypeA, res.Ipv4Addr)
|
newEndpoint := endpoint.NewEndpoint(*res.Name, endpoint.RecordTypeA, *res.Ipv4Addr)
|
||||||
if p.createPTR {
|
if p.createPTR {
|
||||||
newEndpoint.WithProviderSpecific(providerSpecificInfobloxPtrRecord, "true")
|
newEndpoint.WithProviderSpecific(providerSpecificInfobloxPtrRecord, "true")
|
||||||
}
|
}
|
||||||
@ -257,11 +257,11 @@ func (p *ProviderConfig) Records(ctx context.Context) (endpoints []*endpoint.End
|
|||||||
}
|
}
|
||||||
for _, res := range resH {
|
for _, res := range resH {
|
||||||
for _, ip := range res.Ipv4Addrs {
|
for _, ip := range res.Ipv4Addrs {
|
||||||
logrus.Debugf("Record='%s' A(H):'%s'", res.Name, ip.Ipv4Addr)
|
logrus.Debugf("Record='%s' A(H):'%s'", *res.Name, *ip.Ipv4Addr)
|
||||||
|
|
||||||
// host record is an abstraction in infoblox that combines A and PTR records
|
// host record is an abstraction in infoblox that combines A and PTR records
|
||||||
// for any host record we already should have a PTR record in infoblox, so mark it as created
|
// for any host record we already should have a PTR record in infoblox, so mark it as created
|
||||||
newEndpoint := endpoint.NewEndpoint(res.Name, endpoint.RecordTypeA, ip.Ipv4Addr)
|
newEndpoint := endpoint.NewEndpoint(*res.Name, endpoint.RecordTypeA, *ip.Ipv4Addr)
|
||||||
if p.createPTR {
|
if p.createPTR {
|
||||||
newEndpoint.WithProviderSpecific(providerSpecificInfobloxPtrRecord, "true")
|
newEndpoint.WithProviderSpecific(providerSpecificInfobloxPtrRecord, "true")
|
||||||
}
|
}
|
||||||
@ -276,8 +276,8 @@ func (p *ProviderConfig) Records(ctx context.Context) (endpoints []*endpoint.End
|
|||||||
return nil, fmt.Errorf("could not fetch CNAME records from zone '%s': %w", zone.Fqdn, err)
|
return nil, fmt.Errorf("could not fetch CNAME records from zone '%s': %w", zone.Fqdn, err)
|
||||||
}
|
}
|
||||||
for _, res := range resC {
|
for _, res := range resC {
|
||||||
logrus.Debugf("Record='%s' CNAME:'%s'", res.Name, res.Canonical)
|
logrus.Debugf("Record='%s' CNAME:'%s'", *res.Name, *res.Canonical)
|
||||||
endpoints = append(endpoints, endpoint.NewEndpoint(res.Name, endpoint.RecordTypeCNAME, res.Canonical))
|
endpoints = append(endpoints, endpoint.NewEndpoint(*res.Name, endpoint.RecordTypeCNAME, *res.Canonical))
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.createPTR {
|
if p.createPTR {
|
||||||
@ -293,7 +293,7 @@ func (p *ProviderConfig) Records(ctx context.Context) (endpoints []*endpoint.End
|
|||||||
return nil, fmt.Errorf("could not fetch PTR records from zone '%s': %w", zone.Fqdn, err)
|
return nil, fmt.Errorf("could not fetch PTR records from zone '%s': %w", zone.Fqdn, err)
|
||||||
}
|
}
|
||||||
for _, res := range resP {
|
for _, res := range resP {
|
||||||
endpoints = append(endpoints, endpoint.NewEndpoint(res.PtrdName, endpoint.RecordTypePTR, res.Ipv4Addr))
|
endpoints = append(endpoints, endpoint.NewEndpoint(*res.PtrdName, endpoint.RecordTypePTR, *res.Ipv4Addr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,36 +307,37 @@ func (p *ProviderConfig) Records(ctx context.Context) (endpoints []*endpoint.End
|
|||||||
for _, res := range resT {
|
for _, res := range resT {
|
||||||
// The Infoblox API strips enclosing double quotes from TXT records lacking whitespace.
|
// The Infoblox API strips enclosing double quotes from TXT records lacking whitespace.
|
||||||
// Unhandled, the missing double quotes would break the extractOwnerID method of the registry package.
|
// Unhandled, the missing double quotes would break the extractOwnerID method of the registry package.
|
||||||
if _, err := strconv.Unquote(res.Text); err != nil {
|
if _, err := strconv.Unquote(*res.Text); err != nil {
|
||||||
res.Text = strconv.Quote(res.Text)
|
quoted := strconv.Quote(*res.Text)
|
||||||
|
res.Text = "ed
|
||||||
}
|
}
|
||||||
|
|
||||||
foundExisting := false
|
foundExisting := false
|
||||||
|
|
||||||
for _, ep := range endpoints {
|
for _, ep := range endpoints {
|
||||||
if ep.DNSName == res.Name && ep.RecordType == endpoint.RecordTypeTXT {
|
if ep.DNSName == *res.Name && ep.RecordType == endpoint.RecordTypeTXT {
|
||||||
foundExisting = true
|
foundExisting = true
|
||||||
duplicateTarget := false
|
duplicateTarget := false
|
||||||
|
|
||||||
for _, t := range ep.Targets {
|
for _, t := range ep.Targets {
|
||||||
if t == res.Text {
|
if t == *res.Text {
|
||||||
duplicateTarget = true
|
duplicateTarget = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if duplicateTarget {
|
if duplicateTarget {
|
||||||
logrus.Debugf("A duplicate target '%s' found for existing TXT record '%s'", res.Text, ep.DNSName)
|
logrus.Debugf("A duplicate target '%s' found for existing TXT record '%s'", *res.Text, ep.DNSName)
|
||||||
} else {
|
} else {
|
||||||
logrus.Debugf("Adding target '%s' to existing TXT record '%s'", res.Text, res.Name)
|
logrus.Debugf("Adding target '%s' to existing TXT record '%s'", *res.Text, *res.Name)
|
||||||
ep.Targets = append(ep.Targets, res.Text)
|
ep.Targets = append(ep.Targets, *res.Text)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !foundExisting {
|
if !foundExisting {
|
||||||
logrus.Debugf("Record='%s' TXT:'%s'", res.Name, res.Text)
|
logrus.Debugf("Record='%s' TXT:'%s'", *res.Name, *res.Text)
|
||||||
newEndpoint := endpoint.NewEndpoint(res.Name, endpoint.RecordTypeTXT, res.Text)
|
newEndpoint := endpoint.NewEndpoint(*res.Name, endpoint.RecordTypeTXT, *res.Text)
|
||||||
endpoints = append(endpoints, newEndpoint)
|
endpoints = append(endpoints, newEndpoint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -532,11 +533,11 @@ func (p *ProviderConfig) recordSet(ep *endpoint.Endpoint, getObject bool, target
|
|||||||
case endpoint.RecordTypeA:
|
case endpoint.RecordTypeA:
|
||||||
var res []ibclient.RecordA
|
var res []ibclient.RecordA
|
||||||
obj := ibclient.NewEmptyRecordA()
|
obj := ibclient.NewEmptyRecordA()
|
||||||
obj.Name = ep.DNSName
|
obj.Name = &ep.DNSName
|
||||||
obj.Ipv4Addr = ep.Targets[targetIndex]
|
obj.Ipv4Addr = &ep.Targets[targetIndex]
|
||||||
obj.View = p.view
|
obj.View = p.view
|
||||||
if getObject {
|
if getObject {
|
||||||
queryParams := ibclient.NewQueryParams(false, map[string]string{"name": obj.Name})
|
queryParams := ibclient.NewQueryParams(false, map[string]string{"name": *obj.Name})
|
||||||
err = p.client.GetObject(obj, "", queryParams, &res)
|
err = p.client.GetObject(obj, "", queryParams, &res)
|
||||||
if err != nil && !isNotFoundError(err) {
|
if err != nil && !isNotFoundError(err) {
|
||||||
return
|
return
|
||||||
@ -549,11 +550,11 @@ func (p *ProviderConfig) recordSet(ep *endpoint.Endpoint, getObject bool, target
|
|||||||
case endpoint.RecordTypePTR:
|
case endpoint.RecordTypePTR:
|
||||||
var res []ibclient.RecordPTR
|
var res []ibclient.RecordPTR
|
||||||
obj := ibclient.NewEmptyRecordPTR()
|
obj := ibclient.NewEmptyRecordPTR()
|
||||||
obj.PtrdName = ep.DNSName
|
obj.PtrdName = &ep.DNSName
|
||||||
obj.Ipv4Addr = ep.Targets[targetIndex]
|
obj.Ipv4Addr = &ep.Targets[targetIndex]
|
||||||
obj.View = p.view
|
obj.View = p.view
|
||||||
if getObject {
|
if getObject {
|
||||||
queryParams := ibclient.NewQueryParams(false, map[string]string{"name": obj.PtrdName})
|
queryParams := ibclient.NewQueryParams(false, map[string]string{"name": *obj.PtrdName})
|
||||||
err = p.client.GetObject(obj, "", queryParams, &res)
|
err = p.client.GetObject(obj, "", queryParams, &res)
|
||||||
if err != nil && !isNotFoundError(err) {
|
if err != nil && !isNotFoundError(err) {
|
||||||
return
|
return
|
||||||
@ -566,11 +567,11 @@ func (p *ProviderConfig) recordSet(ep *endpoint.Endpoint, getObject bool, target
|
|||||||
case endpoint.RecordTypeCNAME:
|
case endpoint.RecordTypeCNAME:
|
||||||
var res []ibclient.RecordCNAME
|
var res []ibclient.RecordCNAME
|
||||||
obj := ibclient.NewEmptyRecordCNAME()
|
obj := ibclient.NewEmptyRecordCNAME()
|
||||||
obj.Name = ep.DNSName
|
obj.Name = &ep.DNSName
|
||||||
obj.Canonical = ep.Targets[0]
|
obj.Canonical = &ep.Targets[0]
|
||||||
obj.View = p.view
|
obj.View = &p.view
|
||||||
if getObject {
|
if getObject {
|
||||||
queryParams := ibclient.NewQueryParams(false, map[string]string{"name": obj.Name})
|
queryParams := ibclient.NewQueryParams(false, map[string]string{"name": *obj.Name})
|
||||||
err = p.client.GetObject(obj, "", queryParams, &res)
|
err = p.client.GetObject(obj, "", queryParams, &res)
|
||||||
if err != nil && !isNotFoundError(err) {
|
if err != nil && !isNotFoundError(err) {
|
||||||
return
|
return
|
||||||
@ -588,11 +589,11 @@ func (p *ProviderConfig) recordSet(ep *endpoint.Endpoint, getObject bool, target
|
|||||||
ep.Targets = endpoint.Targets{target}
|
ep.Targets = endpoint.Targets{target}
|
||||||
}
|
}
|
||||||
obj := ibclient.NewEmptyRecordTXT()
|
obj := ibclient.NewEmptyRecordTXT()
|
||||||
obj.Name = ep.DNSName
|
obj.Name = &ep.DNSName
|
||||||
obj.Text = ep.Targets[0]
|
obj.Text = &ep.Targets[0]
|
||||||
obj.View = p.view
|
obj.View = &p.view
|
||||||
if getObject {
|
if getObject {
|
||||||
queryParams := ibclient.NewQueryParams(false, map[string]string{"name": obj.Name})
|
queryParams := ibclient.NewQueryParams(false, map[string]string{"name": *obj.Name})
|
||||||
err = p.client.GetObject(obj, "", queryParams, &res)
|
err = p.client.GetObject(obj, "", queryParams, &res)
|
||||||
if err != nil && !isNotFoundError(err) {
|
if err != nil && !isNotFoundError(err) {
|
||||||
return
|
return
|
||||||
@ -679,36 +680,36 @@ func (p *ProviderConfig) deleteRecords(deleted infobloxChangeMap) {
|
|||||||
case endpoint.RecordTypeA:
|
case endpoint.RecordTypeA:
|
||||||
for _, record := range *recordSet.res.(*[]ibclient.RecordA) {
|
for _, record := range *recordSet.res.(*[]ibclient.RecordA) {
|
||||||
if p.dryRun {
|
if p.dryRun {
|
||||||
logrus.Infof("Would delete %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "A", record.Name, record.Ipv4Addr, record.Zone)
|
logrus.Infof("Would delete %s record named '%p' to '%p' for Infoblox DNS zone '%s'.", "A", record.Name, record.Ipv4Addr, record.Zone)
|
||||||
} else {
|
} else {
|
||||||
logrus.Infof("Deleting %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "A", record.Name, record.Ipv4Addr, record.Zone)
|
logrus.Infof("Deleting %s record named '%p' to '%p' for Infoblox DNS zone '%s'.", "A", record.Name, record.Ipv4Addr, record.Zone)
|
||||||
_, err = p.client.DeleteObject(record.Ref)
|
_, err = p.client.DeleteObject(record.Ref)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case endpoint.RecordTypePTR:
|
case endpoint.RecordTypePTR:
|
||||||
for _, record := range *recordSet.res.(*[]ibclient.RecordPTR) {
|
for _, record := range *recordSet.res.(*[]ibclient.RecordPTR) {
|
||||||
if p.dryRun {
|
if p.dryRun {
|
||||||
logrus.Infof("Would delete %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "PTR", record.PtrdName, record.Ipv4Addr, record.Zone)
|
logrus.Infof("Would delete %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "PTR", *record.PtrdName, *record.Ipv4Addr, record.Zone)
|
||||||
} else {
|
} else {
|
||||||
logrus.Infof("Deleting %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "PTR", record.PtrdName, record.Ipv4Addr, record.Zone)
|
logrus.Infof("Deleting %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "PTR", *record.PtrdName, *record.Ipv4Addr, record.Zone)
|
||||||
_, err = p.client.DeleteObject(record.Ref)
|
_, err = p.client.DeleteObject(record.Ref)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case endpoint.RecordTypeCNAME:
|
case endpoint.RecordTypeCNAME:
|
||||||
for _, record := range *recordSet.res.(*[]ibclient.RecordCNAME) {
|
for _, record := range *recordSet.res.(*[]ibclient.RecordCNAME) {
|
||||||
if p.dryRun {
|
if p.dryRun {
|
||||||
logrus.Infof("Would delete %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "CNAME", record.Name, record.Canonical, record.Zone)
|
logrus.Infof("Would delete %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "CNAME", *record.Name, *record.Canonical, record.Zone)
|
||||||
} else {
|
} else {
|
||||||
logrus.Infof("Deleting %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "CNAME", record.Name, record.Canonical, record.Zone)
|
logrus.Infof("Deleting %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "CNAME", *record.Name, *record.Canonical, record.Zone)
|
||||||
_, err = p.client.DeleteObject(record.Ref)
|
_, err = p.client.DeleteObject(record.Ref)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case endpoint.RecordTypeTXT:
|
case endpoint.RecordTypeTXT:
|
||||||
for _, record := range *recordSet.res.(*[]ibclient.RecordTXT) {
|
for _, record := range *recordSet.res.(*[]ibclient.RecordTXT) {
|
||||||
if p.dryRun {
|
if p.dryRun {
|
||||||
logrus.Infof("Would delete %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "TXT", record.Name, record.Text, record.Zone)
|
logrus.Infof("Would delete %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "TXT", *record.Name, *record.Text, record.Zone)
|
||||||
} else {
|
} else {
|
||||||
logrus.Infof("Deleting %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "TXT", record.Name, record.Text, record.Zone)
|
logrus.Infof("Deleting %s record named '%s' to '%s' for Infoblox DNS zone '%s'.", "TXT", *record.Name, *record.Text, record.Zone)
|
||||||
_, err = p.client.DeleteObject(record.Ref)
|
_, err = p.client.DeleteObject(record.Ref)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,63 +113,63 @@ func (client *mockIBConnector) CreateObject(obj ibclient.IBObject) (ref string,
|
|||||||
client.createdEndpoints = append(
|
client.createdEndpoints = append(
|
||||||
client.createdEndpoints,
|
client.createdEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
obj.(*ibclient.RecordA).Name,
|
*obj.(*ibclient.RecordA).Name,
|
||||||
endpoint.RecordTypeA,
|
endpoint.RecordTypeA,
|
||||||
obj.(*ibclient.RecordA).Ipv4Addr,
|
*obj.(*ibclient.RecordA).Ipv4Addr,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
ref = fmt.Sprintf("%s/%s:%s/default", obj.ObjectType(), base64.StdEncoding.EncodeToString([]byte(obj.(*ibclient.RecordA).Name)), obj.(*ibclient.RecordA).Name)
|
ref = fmt.Sprintf("%s/%s:%s/default", obj.ObjectType(), base64.StdEncoding.EncodeToString([]byte(*obj.(*ibclient.RecordA).Name)), *obj.(*ibclient.RecordA).Name)
|
||||||
obj.(*ibclient.RecordA).Ref = ref
|
obj.(*ibclient.RecordA).Ref = ref
|
||||||
case "record:cname":
|
case "record:cname":
|
||||||
client.createdEndpoints = append(
|
client.createdEndpoints = append(
|
||||||
client.createdEndpoints,
|
client.createdEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
obj.(*ibclient.RecordCNAME).Name,
|
*obj.(*ibclient.RecordCNAME).Name,
|
||||||
endpoint.RecordTypeCNAME,
|
endpoint.RecordTypeCNAME,
|
||||||
obj.(*ibclient.RecordCNAME).Canonical,
|
*obj.(*ibclient.RecordCNAME).Canonical,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
ref = fmt.Sprintf("%s/%s:%s/default", obj.ObjectType(), base64.StdEncoding.EncodeToString([]byte(obj.(*ibclient.RecordCNAME).Name)), obj.(*ibclient.RecordCNAME).Name)
|
ref = fmt.Sprintf("%s/%s:%s/default", obj.ObjectType(), base64.StdEncoding.EncodeToString([]byte(*obj.(*ibclient.RecordCNAME).Name)), *obj.(*ibclient.RecordCNAME).Name)
|
||||||
obj.(*ibclient.RecordCNAME).Ref = ref
|
obj.(*ibclient.RecordCNAME).Ref = ref
|
||||||
case "record:host":
|
case "record:host":
|
||||||
for _, i := range obj.(*ibclient.HostRecord).Ipv4Addrs {
|
for _, i := range obj.(*ibclient.HostRecord).Ipv4Addrs {
|
||||||
client.createdEndpoints = append(
|
client.createdEndpoints = append(
|
||||||
client.createdEndpoints,
|
client.createdEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
obj.(*ibclient.HostRecord).Name,
|
*obj.(*ibclient.HostRecord).Name,
|
||||||
endpoint.RecordTypeA,
|
endpoint.RecordTypeA,
|
||||||
i.Ipv4Addr,
|
*i.Ipv4Addr,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ref = fmt.Sprintf("%s/%s:%s/default", obj.ObjectType(), base64.StdEncoding.EncodeToString([]byte(obj.(*ibclient.HostRecord).Name)), obj.(*ibclient.HostRecord).Name)
|
ref = fmt.Sprintf("%s/%s:%s/default", obj.ObjectType(), base64.StdEncoding.EncodeToString([]byte(*obj.(*ibclient.HostRecord).Name)), *obj.(*ibclient.HostRecord).Name)
|
||||||
obj.(*ibclient.HostRecord).Ref = ref
|
obj.(*ibclient.HostRecord).Ref = ref
|
||||||
case "record:txt":
|
case "record:txt":
|
||||||
client.createdEndpoints = append(
|
client.createdEndpoints = append(
|
||||||
client.createdEndpoints,
|
client.createdEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
obj.(*ibclient.RecordTXT).Name,
|
*obj.(*ibclient.RecordTXT).Name,
|
||||||
endpoint.RecordTypeTXT,
|
endpoint.RecordTypeTXT,
|
||||||
obj.(*ibclient.RecordTXT).Text,
|
*obj.(*ibclient.RecordTXT).Text,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
obj.(*ibclient.RecordTXT).Ref = ref
|
obj.(*ibclient.RecordTXT).Ref = ref
|
||||||
ref = fmt.Sprintf("%s/%s:%s/default", obj.ObjectType(), base64.StdEncoding.EncodeToString([]byte(obj.(*ibclient.RecordTXT).Name)), obj.(*ibclient.RecordTXT).Name)
|
ref = fmt.Sprintf("%s/%s:%s/default", obj.ObjectType(), base64.StdEncoding.EncodeToString([]byte(*obj.(*ibclient.RecordTXT).Name)), *obj.(*ibclient.RecordTXT).Name)
|
||||||
case "record:ptr":
|
case "record:ptr":
|
||||||
client.createdEndpoints = append(
|
client.createdEndpoints = append(
|
||||||
client.createdEndpoints,
|
client.createdEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
obj.(*ibclient.RecordPTR).PtrdName,
|
*obj.(*ibclient.RecordPTR).PtrdName,
|
||||||
endpoint.RecordTypePTR,
|
endpoint.RecordTypePTR,
|
||||||
obj.(*ibclient.RecordPTR).Ipv4Addr,
|
*obj.(*ibclient.RecordPTR).Ipv4Addr,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
obj.(*ibclient.RecordPTR).Ref = ref
|
obj.(*ibclient.RecordPTR).Ref = ref
|
||||||
reverseAddr, err := dns.ReverseAddr(obj.(*ibclient.RecordPTR).Ipv4Addr)
|
reverseAddr, err := dns.ReverseAddr(*obj.(*ibclient.RecordPTR).Ipv4Addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ref, fmt.Errorf("unable to create reverse addr from %s", obj.(*ibclient.RecordPTR).Ipv4Addr)
|
return ref, fmt.Errorf("unable to create reverse addr from %s", *obj.(*ibclient.RecordPTR).Ipv4Addr)
|
||||||
}
|
}
|
||||||
ref = fmt.Sprintf("%s/%s:%s/default", obj.ObjectType(), base64.StdEncoding.EncodeToString([]byte(obj.(*ibclient.RecordPTR).PtrdName)), reverseAddr)
|
ref = fmt.Sprintf("%s/%s:%s/default", obj.ObjectType(), base64.StdEncoding.EncodeToString([]byte(*obj.(*ibclient.RecordPTR).PtrdName)), reverseAddr)
|
||||||
}
|
}
|
||||||
*client.mockInfobloxObjects = append(
|
*client.mockInfobloxObjects = append(
|
||||||
*client.mockInfobloxObjects,
|
*client.mockInfobloxObjects,
|
||||||
@ -200,8 +200,8 @@ func (client *mockIBConnector) GetObject(obj ibclient.IBObject, ref string, quer
|
|||||||
ref != object.(*ibclient.RecordA).Ref {
|
ref != object.(*ibclient.RecordA).Ref {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if obj.(*ibclient.RecordA).Name != "" &&
|
if obj.(*ibclient.RecordA).Name != nil &&
|
||||||
obj.(*ibclient.RecordA).Name != object.(*ibclient.RecordA).Name {
|
*obj.(*ibclient.RecordA).Name != *object.(*ibclient.RecordA).Name {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
result = append(result, *object.(*ibclient.RecordA))
|
result = append(result, *object.(*ibclient.RecordA))
|
||||||
@ -216,8 +216,8 @@ func (client *mockIBConnector) GetObject(obj ibclient.IBObject, ref string, quer
|
|||||||
ref != object.(*ibclient.RecordCNAME).Ref {
|
ref != object.(*ibclient.RecordCNAME).Ref {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if obj.(*ibclient.RecordCNAME).Name != "" &&
|
if obj.(*ibclient.RecordCNAME).Name != nil &&
|
||||||
obj.(*ibclient.RecordCNAME).Name != object.(*ibclient.RecordCNAME).Name {
|
*obj.(*ibclient.RecordCNAME).Name != *object.(*ibclient.RecordCNAME).Name {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
result = append(result, *object.(*ibclient.RecordCNAME))
|
result = append(result, *object.(*ibclient.RecordCNAME))
|
||||||
@ -232,8 +232,8 @@ func (client *mockIBConnector) GetObject(obj ibclient.IBObject, ref string, quer
|
|||||||
ref != object.(*ibclient.HostRecord).Ref {
|
ref != object.(*ibclient.HostRecord).Ref {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if obj.(*ibclient.HostRecord).Name != "" &&
|
if obj.(*ibclient.HostRecord).Name != nil &&
|
||||||
obj.(*ibclient.HostRecord).Name != object.(*ibclient.HostRecord).Name {
|
*obj.(*ibclient.HostRecord).Name != *object.(*ibclient.HostRecord).Name {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
result = append(result, *object.(*ibclient.HostRecord))
|
result = append(result, *object.(*ibclient.HostRecord))
|
||||||
@ -248,8 +248,8 @@ func (client *mockIBConnector) GetObject(obj ibclient.IBObject, ref string, quer
|
|||||||
ref != object.(*ibclient.RecordTXT).Ref {
|
ref != object.(*ibclient.RecordTXT).Ref {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if obj.(*ibclient.RecordTXT).Name != "" &&
|
if obj.(*ibclient.RecordTXT).Name != nil &&
|
||||||
obj.(*ibclient.RecordTXT).Name != object.(*ibclient.RecordTXT).Name {
|
*obj.(*ibclient.RecordTXT).Name != *object.(*ibclient.RecordTXT).Name {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
result = append(result, *object.(*ibclient.RecordTXT))
|
result = append(result, *object.(*ibclient.RecordTXT))
|
||||||
@ -264,8 +264,8 @@ func (client *mockIBConnector) GetObject(obj ibclient.IBObject, ref string, quer
|
|||||||
ref != object.(*ibclient.RecordPTR).Ref {
|
ref != object.(*ibclient.RecordPTR).Ref {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if obj.(*ibclient.RecordPTR).PtrdName != "" &&
|
if obj.(*ibclient.RecordPTR).PtrdName != nil &&
|
||||||
obj.(*ibclient.RecordPTR).PtrdName != object.(*ibclient.RecordPTR).PtrdName {
|
*obj.(*ibclient.RecordPTR).PtrdName != *object.(*ibclient.RecordPTR).PtrdName {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
result = append(result, *object.(*ibclient.RecordPTR))
|
result = append(result, *object.(*ibclient.RecordPTR))
|
||||||
@ -286,13 +286,13 @@ func (client *mockIBConnector) DeleteObject(ref string) (refRes string, err erro
|
|||||||
case "record:a":
|
case "record:a":
|
||||||
var records []ibclient.RecordA
|
var records []ibclient.RecordA
|
||||||
obj := ibclient.NewEmptyRecordA()
|
obj := ibclient.NewEmptyRecordA()
|
||||||
obj.Name = result[2]
|
obj.Name = &result[2]
|
||||||
client.GetObject(obj, ref, nil, &records)
|
client.GetObject(obj, ref, nil, &records)
|
||||||
for _, record := range records {
|
for _, record := range records {
|
||||||
client.deletedEndpoints = append(
|
client.deletedEndpoints = append(
|
||||||
client.deletedEndpoints,
|
client.deletedEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
record.Name,
|
*record.Name,
|
||||||
endpoint.RecordTypeA,
|
endpoint.RecordTypeA,
|
||||||
"",
|
"",
|
||||||
),
|
),
|
||||||
@ -301,13 +301,13 @@ func (client *mockIBConnector) DeleteObject(ref string) (refRes string, err erro
|
|||||||
case "record:cname":
|
case "record:cname":
|
||||||
var records []ibclient.RecordCNAME
|
var records []ibclient.RecordCNAME
|
||||||
obj := ibclient.NewEmptyRecordCNAME()
|
obj := ibclient.NewEmptyRecordCNAME()
|
||||||
obj.Name = result[2]
|
obj.Name = &result[2]
|
||||||
client.GetObject(obj, ref, nil, &records)
|
client.GetObject(obj, ref, nil, &records)
|
||||||
for _, record := range records {
|
for _, record := range records {
|
||||||
client.deletedEndpoints = append(
|
client.deletedEndpoints = append(
|
||||||
client.deletedEndpoints,
|
client.deletedEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
record.Name,
|
*record.Name,
|
||||||
endpoint.RecordTypeCNAME,
|
endpoint.RecordTypeCNAME,
|
||||||
"",
|
"",
|
||||||
),
|
),
|
||||||
@ -316,13 +316,13 @@ func (client *mockIBConnector) DeleteObject(ref string) (refRes string, err erro
|
|||||||
case "record:host":
|
case "record:host":
|
||||||
var records []ibclient.HostRecord
|
var records []ibclient.HostRecord
|
||||||
obj := ibclient.NewEmptyHostRecord()
|
obj := ibclient.NewEmptyHostRecord()
|
||||||
obj.Name = result[2]
|
obj.Name = &result[2]
|
||||||
client.GetObject(obj, ref, nil, &records)
|
client.GetObject(obj, ref, nil, &records)
|
||||||
for _, record := range records {
|
for _, record := range records {
|
||||||
client.deletedEndpoints = append(
|
client.deletedEndpoints = append(
|
||||||
client.deletedEndpoints,
|
client.deletedEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
record.Name,
|
*record.Name,
|
||||||
endpoint.RecordTypeA,
|
endpoint.RecordTypeA,
|
||||||
"",
|
"",
|
||||||
),
|
),
|
||||||
@ -331,13 +331,13 @@ func (client *mockIBConnector) DeleteObject(ref string) (refRes string, err erro
|
|||||||
case "record:txt":
|
case "record:txt":
|
||||||
var records []ibclient.RecordTXT
|
var records []ibclient.RecordTXT
|
||||||
obj := ibclient.NewEmptyRecordTXT()
|
obj := ibclient.NewEmptyRecordTXT()
|
||||||
obj.Name = result[2]
|
obj.Name = &result[2]
|
||||||
client.GetObject(obj, ref, nil, &records)
|
client.GetObject(obj, ref, nil, &records)
|
||||||
for _, record := range records {
|
for _, record := range records {
|
||||||
client.deletedEndpoints = append(
|
client.deletedEndpoints = append(
|
||||||
client.deletedEndpoints,
|
client.deletedEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
record.Name,
|
*record.Name,
|
||||||
endpoint.RecordTypeTXT,
|
endpoint.RecordTypeTXT,
|
||||||
"",
|
"",
|
||||||
),
|
),
|
||||||
@ -346,13 +346,13 @@ func (client *mockIBConnector) DeleteObject(ref string) (refRes string, err erro
|
|||||||
case "record:ptr":
|
case "record:ptr":
|
||||||
var records []ibclient.RecordPTR
|
var records []ibclient.RecordPTR
|
||||||
obj := ibclient.NewEmptyRecordPTR()
|
obj := ibclient.NewEmptyRecordPTR()
|
||||||
obj.Name = result[2]
|
obj.Name = &result[2]
|
||||||
client.GetObject(obj, ref, nil, &records)
|
client.GetObject(obj, ref, nil, &records)
|
||||||
for _, record := range records {
|
for _, record := range records {
|
||||||
client.deletedEndpoints = append(
|
client.deletedEndpoints = append(
|
||||||
client.deletedEndpoints,
|
client.deletedEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
record.PtrdName,
|
*record.PtrdName,
|
||||||
endpoint.RecordTypePTR,
|
endpoint.RecordTypePTR,
|
||||||
"",
|
"",
|
||||||
),
|
),
|
||||||
@ -368,8 +368,8 @@ func (client *mockIBConnector) UpdateObject(obj ibclient.IBObject, ref string) (
|
|||||||
client.updatedEndpoints = append(
|
client.updatedEndpoints = append(
|
||||||
client.updatedEndpoints,
|
client.updatedEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
obj.(*ibclient.RecordA).Name,
|
*obj.(*ibclient.RecordA).Name,
|
||||||
obj.(*ibclient.RecordA).Ipv4Addr,
|
*obj.(*ibclient.RecordA).Ipv4Addr,
|
||||||
endpoint.RecordTypeA,
|
endpoint.RecordTypeA,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -377,8 +377,8 @@ func (client *mockIBConnector) UpdateObject(obj ibclient.IBObject, ref string) (
|
|||||||
client.updatedEndpoints = append(
|
client.updatedEndpoints = append(
|
||||||
client.updatedEndpoints,
|
client.updatedEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
obj.(*ibclient.RecordCNAME).Name,
|
*obj.(*ibclient.RecordCNAME).Name,
|
||||||
obj.(*ibclient.RecordCNAME).Canonical,
|
*obj.(*ibclient.RecordCNAME).Canonical,
|
||||||
endpoint.RecordTypeCNAME,
|
endpoint.RecordTypeCNAME,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -387,8 +387,8 @@ func (client *mockIBConnector) UpdateObject(obj ibclient.IBObject, ref string) (
|
|||||||
client.updatedEndpoints = append(
|
client.updatedEndpoints = append(
|
||||||
client.updatedEndpoints,
|
client.updatedEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
obj.(*ibclient.HostRecord).Name,
|
*obj.(*ibclient.HostRecord).Name,
|
||||||
i.Ipv4Addr,
|
*i.Ipv4Addr,
|
||||||
endpoint.RecordTypeA,
|
endpoint.RecordTypeA,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -397,8 +397,8 @@ func (client *mockIBConnector) UpdateObject(obj ibclient.IBObject, ref string) (
|
|||||||
client.updatedEndpoints = append(
|
client.updatedEndpoints = append(
|
||||||
client.updatedEndpoints,
|
client.updatedEndpoints,
|
||||||
endpoint.NewEndpoint(
|
endpoint.NewEndpoint(
|
||||||
obj.(*ibclient.RecordTXT).Name,
|
*obj.(*ibclient.RecordTXT).Name,
|
||||||
obj.(*ibclient.RecordTXT).Text,
|
*obj.(*ibclient.RecordTXT).Text,
|
||||||
endpoint.RecordTypeTXT,
|
endpoint.RecordTypeTXT,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -417,37 +417,37 @@ func createMockInfobloxObject(name, recordType, value string) ibclient.IBObject
|
|||||||
switch recordType {
|
switch recordType {
|
||||||
case endpoint.RecordTypeA:
|
case endpoint.RecordTypeA:
|
||||||
obj := ibclient.NewEmptyRecordA()
|
obj := ibclient.NewEmptyRecordA()
|
||||||
obj.Name = name
|
obj.Name = &name
|
||||||
obj.Ref = ref
|
obj.Ref = ref
|
||||||
obj.Ipv4Addr = value
|
obj.Ipv4Addr = &value
|
||||||
return obj
|
return obj
|
||||||
case endpoint.RecordTypeCNAME:
|
case endpoint.RecordTypeCNAME:
|
||||||
obj := ibclient.NewEmptyRecordCNAME()
|
obj := ibclient.NewEmptyRecordCNAME()
|
||||||
obj.Name = name
|
obj.Name = &name
|
||||||
obj.Ref = ref
|
obj.Ref = ref
|
||||||
obj.Canonical = value
|
obj.Canonical = &value
|
||||||
return obj
|
return obj
|
||||||
case endpoint.RecordTypeTXT:
|
case endpoint.RecordTypeTXT:
|
||||||
obj := ibclient.NewEmptyRecordTXT()
|
obj := ibclient.NewEmptyRecordTXT()
|
||||||
obj.Name = name
|
obj.Name = &name
|
||||||
obj.Ref = ref
|
obj.Ref = ref
|
||||||
obj.Text = value
|
obj.Text = &value
|
||||||
return obj
|
return obj
|
||||||
case "HOST":
|
case "HOST":
|
||||||
obj := ibclient.NewEmptyHostRecord()
|
obj := ibclient.NewEmptyHostRecord()
|
||||||
obj.Name = name
|
obj.Name = &name
|
||||||
obj.Ref = ref
|
obj.Ref = ref
|
||||||
obj.Ipv4Addrs = []ibclient.HostRecordIpv4Addr{
|
obj.Ipv4Addrs = []ibclient.HostRecordIpv4Addr{
|
||||||
{
|
{
|
||||||
Ipv4Addr: value,
|
Ipv4Addr: &value,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return obj
|
return obj
|
||||||
case endpoint.RecordTypePTR:
|
case endpoint.RecordTypePTR:
|
||||||
obj := ibclient.NewEmptyRecordPTR()
|
obj := ibclient.NewEmptyRecordPTR()
|
||||||
obj.PtrdName = name
|
obj.PtrdName = &name
|
||||||
obj.Ref = ref
|
obj.Ref = ref
|
||||||
obj.Ipv4Addr = value
|
obj.Ipv4Addr = &value
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user