func (p *LinodeProvider) submitChanges(changes LinodeChanges) error {
	for _, change := range changes.Creates {
		logFields := log.Fields{
			"record":   change.Options.Name,
			"type":     change.Options.Type,
			"action":   "Create",
			"zoneName": change.Domain.Domain,
			"zoneID":   change.Domain.ID,
		}

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

		if p.DryRun {
			log.WithFields(logFields).Info("Would create record.")
		} else {
			if _, err := p.Client.CreateDomainRecord(context.TODO(), change.Domain.ID, change.Options); err != nil {
				log.WithFields(logFields).Errorf(
					"Failed to Create record: %v",
					err,
				)
			}
		}
	}

	for _, change := range changes.Deletes {
		logFields := log.Fields{
			"record":   change.DomainRecord.Name,
			"type":     change.DomainRecord.Type,
			"action":   "Delete",
			"zoneName": change.Domain.Domain,
			"zoneID":   change.Domain.ID,
		}

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

		if p.DryRun {
			log.WithFields(logFields).Info("Would delete record.")
		} else {
			if err := p.Client.DeleteDomainRecord(context.TODO(), change.Domain.ID, change.DomainRecord.ID); err != nil {
				log.WithFields(logFields).Errorf(
					"Failed to Delete record: %v",
					err,
				)
			}
		}
	}

	for _, change := range changes.Updates {
		logFields := log.Fields{
			"record":   change.Options.Name,
			"type":     change.Options.Type,
			"action":   "Update",
			"zoneName": change.Domain.Domain,
			"zoneID":   change.Domain.ID,
		}

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

		if p.DryRun {
			log.WithFields(logFields).Info("Would update record.")
		} else {
			if _, err := p.Client.UpdateDomainRecord(context.TODO(), change.Domain.ID, change.DomainRecord.ID, change.Options); err != nil {
				log.WithFields(logFields).Errorf(
					"Failed to Update record: %v",
					err,
				)
			}
		}
	}

	return nil
}
func (p *LinodeProvider) submitChanges(changes LinodeChanges) error {
	for _, change := range changes.Creates {
		logFields := log.Fields{
			"record":   change.Options.Name,
			"type":     change.Options.Type,
			"action":   "Create",
			"zoneName": change.Domain.Domain,
			"zoneID":   change.Domain.ID,
		}

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

		if p.DryRun {
			log.WithFields(logFields).Info("Would create record.")
		} else {
			if _, err := p.Client.CreateDomainRecord(context.TODO(), change.Domain.ID, change.Options); err != nil {
				log.WithFields(logFields).Errorf(
					"Failed to Create record: %v",
					err,
				)
			}
		}
	}

	for _, change := range changes.Deletes {
		logFields := log.Fields{
			"record":   change.DomainRecord.Name,
			"type":     change.DomainRecord.Type,
			"action":   "Delete",
			"zoneName": change.Domain.Domain,
			"zoneID":   change.Domain.ID,
		}

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

		if p.DryRun {
			log.WithFields(logFields).Info("Would delete record.")
		} else {
			if err := p.Client.DeleteDomainRecord(context.TODO(), change.Domain.ID, change.DomainRecord.ID); err != nil {
				log.WithFields(logFields).Errorf(
					"Failed to Delete record: %v",
					err,
				)
			}
		}
	}

	for _, change := range changes.Updates {
		logFields := log.Fields{
			"record":   change.Options.Name,
			"type":     change.Options.Type,
			"action":   "Update",
			"zoneName": change.Domain.Domain,
			"zoneID":   change.Domain.ID,
		}

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

		if p.DryRun {
			log.WithFields(logFields).Info("Would update record.")
		} else {
			if _, err := p.Client.UpdateDomainRecord(context.TODO(), change.Domain.ID, change.DomainRecord.ID, change.Options); err != nil {
				log.WithFields(logFields).Errorf(
					"Failed to Update record: %v",
					err,
				)
			}
		}
	}

	return nil
}
func ( p * LinodeProvider ) submitChanges ( changes LinodeChanges ) error { for _ , change := range changes . Creates { logFields := log . Fields { " " : change . Options . Name , " " : change . Options . Type , " " : " " , " " : change . Domain . Domain , " " : change . Domain . ID , } log . WithFields ( logFields ) . Info ( " " ) if p . DryRun { log . WithFields ( logFields ) . Info ( " " ) } else { if _ , err := p . Client . CreateDomainRecord ( context . TODO ( ) , change . Domain . ID , change . Options ) ; err != nil { log . WithFields ( logFields ) . Errorf ( " " , err , ) } } } for _ , change := range changes . Deletes { logFields := log . Fields { " " : change . DomainRecord . Name , " " : change . DomainRecord . Type , " " : " " , " " : change . Domain . Domain , " " : change . Domain . ID , } log . WithFields ( logFields ) . Info ( " " ) if p . DryRun { log . WithFields ( logFields ) . Info ( " " ) } else { if err := p . Client . DeleteDomainRecord ( context . TODO ( ) , change . Domain . ID , change . DomainRecord . ID ) ; err != nil { log . WithFields ( logFields ) . Errorf ( " " , err , ) } } } for _ , change := range changes . Updates { logFields := log . Fields { " " : change . Options . Name , " " : change . Options . Type , " " : " " , " " : change . Domain . Domain , " " : change . Domain . ID , } log . WithFields ( logFields ) . Info ( " " ) if p . DryRun { log . WithFields ( logFields ) . Info ( " " ) } else { if _ , err := p . Client . UpdateDomainRecord ( context . TODO ( ) , change . Domain . ID , change . DomainRecord . ID , change . Options ) ; err != nil { log . WithFields ( logFields ) . Errorf ( " " , err , ) } } } return nil }
// submitChanges takes a zone and a collection of Changes and sends them as a single transaction.
submitChanges takes a zone and a collection of Changes and sends them as a single transaction .