provider/rcode0.go
func (p *RcodeZeroProvider) submitChanges(changes []*rc0.RRSetChange) error {

	if len(changes) == 0 {
		return nil
	}

	zones, err := p.Zones()
	if err != nil {
		return err
	}

	// separate into per-zone change sets to be passed to the API.
	changesByZone := rcodezeroChangesByZone(zones, changes)

	for zoneName, changes := range changesByZone {

		for _, change := range changes {

			logFields := log.Fields{
				"record":  change.Name,
				"content": change.Records[0].Content,
				"type":    change.Type,
				"action":  change.ChangeType,
				"zone":    zoneName,
			}

			log.WithFields(logFields).Info("Changing record.")

			if p.DryRun {
				continue
			}

			// to avoid accidentally adding extra dot if already present
			change.Name = strings.TrimSuffix(change.Name, ".") + "."

			switch change.ChangeType {
			case rc0.ChangeTypeADD:
				sr, err := p.Client.RRSet.Create(zoneName, []*rc0.RRSetChange{change})

				if err != nil {
					return err
				}

				if sr.HasError() {
					return fmt.Errorf("adding new RR resulted in an error: %v", sr.Message)
				}

			case rc0.ChangeTypeUPDATE:
				sr, err := p.Client.RRSet.Edit(zoneName, []*rc0.RRSetChange{change})

				if err != nil {
					return err
				}

				if sr.HasError() {
					return fmt.Errorf("updating existing RR resulted in an error: %v", sr.Message)
				}

			case rc0.ChangeTypeDELETE:
				sr, err := p.Client.RRSet.Delete(zoneName, []*rc0.RRSetChange{change})

				if err != nil {
					return err
				}

				if sr.HasError() {
					return fmt.Errorf("deleting existing RR resulted in an error: %v", sr.Message)
				}

			default:
				return fmt.Errorf("unsupported changeType submitted: %v", change.ChangeType)
			}
		}
	}
	return nil
}
func (p *RcodeZeroProvider) submitChanges(changes []*rc0.RRSetChange) error {

	if len(changes) == 0 {
		return nil
	}

	zones, err := p.Zones()
	if err != nil {
		return err
	}

	// separate into per-zone change sets to be passed to the API.
	changesByZone := rcodezeroChangesByZone(zones, changes)

	for zoneName, changes := range changesByZone {

		for _, change := range changes {

			logFields := log.Fields{
				"record":  change.Name,
				"content": change.Records[0].Content,
				"type":    change.Type,
				"action":  change.ChangeType,
				"zone":    zoneName,
			}

			log.WithFields(logFields).Info("Changing record.")

			if p.DryRun {
				continue
			}

			// to avoid accidentally adding extra dot if already present
			change.Name = strings.TrimSuffix(change.Name, ".") + "."

			switch change.ChangeType {
			case rc0.ChangeTypeADD:
				sr, err := p.Client.RRSet.Create(zoneName, []*rc0.RRSetChange{change})

				if err != nil {
					return err
				}

				if sr.HasError() {
					return fmt.Errorf("adding new RR resulted in an error: %v", sr.Message)
				}

			case rc0.ChangeTypeUPDATE:
				sr, err := p.Client.RRSet.Edit(zoneName, []*rc0.RRSetChange{change})

				if err != nil {
					return err
				}

				if sr.HasError() {
					return fmt.Errorf("updating existing RR resulted in an error: %v", sr.Message)
				}

			case rc0.ChangeTypeDELETE:
				sr, err := p.Client.RRSet.Delete(zoneName, []*rc0.RRSetChange{change})

				if err != nil {
					return err
				}

				if sr.HasError() {
					return fmt.Errorf("deleting existing RR resulted in an error: %v", sr.Message)
				}

			default:
				return fmt.Errorf("unsupported changeType submitted: %v", change.ChangeType)
			}
		}
	}
	return nil
}
// Helper function to submit changes.
//
// Changes are submitted by change type.