(ctx context.Context, dnsName, recordType, recordValue string)
| 380 | } |
| 381 | |
| 382 | func (m *DNSManager) createRecord(ctx context.Context, dnsName, recordType, recordValue string) (zoneRecord, error) { |
| 383 | logger := m.logger() |
| 384 | |
| 385 | zone, err := FindZoneByFQDN(ctx, logger, dnsName, RecursiveNameservers(m.Resolvers)) |
| 386 | if err != nil { |
| 387 | return zoneRecord{}, fmt.Errorf("could not determine zone for domain %q: %v", dnsName, err) |
| 388 | } |
| 389 | |
| 390 | rr := libdns.RR{ |
| 391 | Type: recordType, |
| 392 | Name: libdns.RelativeName(dnsName+".", zone), |
| 393 | Data: recordValue, |
| 394 | TTL: m.TTL, |
| 395 | } |
| 396 | |
| 397 | logger.Debug("creating DNS record", |
| 398 | zap.String("dns_name", dnsName), |
| 399 | zap.String("zone", zone), |
| 400 | zap.String("record_name", rr.Name), |
| 401 | zap.String("record_type", rr.Type), |
| 402 | zap.String("record_data", rr.Data), |
| 403 | zap.Duration("record_ttl", rr.TTL)) |
| 404 | |
| 405 | results, err := m.DNSProvider.AppendRecords(ctx, zone, []libdns.Record{rr}) |
| 406 | if err != nil { |
| 407 | return zoneRecord{}, fmt.Errorf("adding temporary record for zone %q: %w", zone, err) |
| 408 | } |
| 409 | if len(results) != 1 { |
| 410 | return zoneRecord{}, fmt.Errorf("expected one record, got %d: %v", len(results), results) |
| 411 | } |
| 412 | |
| 413 | return zoneRecord{zone, results[0]}, nil |
| 414 | } |
| 415 | |
| 416 | // wait blocks until the TXT record created in Present() appears in |
| 417 | // authoritative lookups, i.e. until it has propagated, or until |
no test coverage detected