Exemplo n.º 1
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
}
Exemplo n.º 2
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
}
Exemplo n.º 3
0
// assertHasRecord tests that rrsets has a record equivalent to rrset
func assertHasRecord(t *testing.T, rrsets dnsprovider.ResourceRecordSets, rrset dnsprovider.ResourceRecordSet) {
	var found dnsprovider.ResourceRecordSet
	for _, r := range listRrsOrFail(t, rrsets) {
		if r.Name() != rrset.Name() || r.Type() != rrset.Type() {
			continue
		}

		if found != nil {
			t.Errorf("found duplicate resource record set: %q and %q", r, found)
		}
		found = r
	}
	if found == nil {
		t.Errorf("resource record set %v not found", rrset)
	} else {
		assertEquivalent(t, found, rrset)
	}
}
Exemplo n.º 4
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
}
Exemplo n.º 5
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)
	}
}