Esempio n. 1
0
// assertEquivalent tests that l is equal to r, for the methods in ResourceRecordSet
func assertEquivalent(t *testing.T, l, r dnsprovider.ResourceRecordSet) {
	if l.Name() != r.Name() {
		t.Errorf("resource record sets not equal %v vs %v", l, r)
	}
	if l.Type() != r.Type() {
		t.Errorf("resource record sets not equal %v vs %v", l, r)
	}
	if l.Ttl() != r.Ttl() {
		t.Errorf("resource record sets not equal %v vs %v", l, r)
	}
	if !reflect.DeepEqual(l.Rrdatas(), r.Rrdatas()) {
		t.Errorf("resource record sets not equal %v vs %v", l, r)
	}
}
Esempio n. 2
0
// buildChange converts a dnsprovider.ResourceRecordSet to a route53.Change request
func buildChange(action string, rrs dnsprovider.ResourceRecordSet) *route53.Change {
	change := &route53.Change{
		Action: aws.String(action),
		ResourceRecordSet: &route53.ResourceRecordSet{
			Name: aws.String(rrs.Name()),
			Type: aws.String(string(rrs.Type())),
			TTL:  aws.Int64(rrs.Ttl()),
		},
	}

	for _, rrdata := range rrs.Rrdatas() {
		rr := &route53.ResourceRecord{
			Value: aws.String(rrdata),
		}
		change.ResourceRecordSet.ResourceRecords = append(change.ResourceRecordSet.ResourceRecords, rr)
	}
	return change
}
Esempio n. 3
0
func (rrsets ResourceRecordSets) Remove(rrset dnsprovider.ResourceRecordSet) error {
	input := getChangeResourceRecordSetsInput("DELETE", rrset.Name(), string(rrset.Type()), *rrset.(ResourceRecordSet).rrsets.zone.impl.Id, rrset.Rrdatas(), rrset.Ttl())
	_, err := rrsets.zone.zones.interface_.service.ChangeResourceRecordSets(input)
	if err != nil {
		// Cast err to awserr.Error to get the Code and
		// Message from an error.
		return err
	}
	return nil
}
Esempio n. 4
0
func (rrsets ResourceRecordSets) Add(rrset dnsprovider.ResourceRecordSet) (dnsprovider.ResourceRecordSet, error) {
	service := rrsets.zone.zones.interface_.service
	input := getChangeResourceRecordSetsInput("CREATE", rrset.Name(), string(rrset.Type()), *rrset.(ResourceRecordSet).rrsets.zone.impl.Id, rrset.Rrdatas(), rrset.Ttl())
	_, err := service.ChangeResourceRecordSets(input)
	if err != nil {
		// Cast err to awserr.Error to get the Code and
		// Message from an error.
		return nil, err
	}
	return ResourceRecordSet{input.ChangeBatch.Changes[0].ResourceRecordSet, &rrsets}, nil
}