MCPcopy Create free account
hub / github.com/barnybug/cli53 / lookupZone

Function lookupZone

util.go:313–353  ·  view source on GitHub ↗
(ctx context.Context, nameOrId string)

Source from the content-addressed store, hash-verified

311}
312
313func lookupZone(ctx context.Context, nameOrId string) *route53types.HostedZone {
314 if isZoneId(nameOrId) {
315 // lookup by id
316 id := nameOrId
317 if !strings.HasPrefix(nameOrId, "/hostedzone/") {
318 id = "/hostedzone/" + id
319 }
320 req := route53.GetHostedZoneInput{
321 Id: aws.String(id),
322 }
323 resp, err := r53.GetHostedZone(ctx, &req)
324 var notFound *route53types.NoSuchHostedZone
325 if errors.As(err, &notFound) {
326 errorAndExit(fmt.Sprintf("Zone '%s' not found", nameOrId))
327 }
328 fatalIfErr(err)
329 return resp.HostedZone
330 } else {
331 // lookup by name
332 matches := []route53types.HostedZone{}
333 req := route53.ListHostedZonesByNameInput{
334 DNSName: aws.String(nameOrId),
335 }
336 resp, err := r53.ListHostedZonesByName(ctx, &req)
337 fatalIfErr(err)
338 for _, zone := range resp.HostedZones {
339 if zoneName(*zone.Name) == zoneName(nameOrId) {
340 matches = append(matches, zone)
341 }
342 }
343 switch len(matches) {
344 case 0:
345 errorAndExit(fmt.Sprintf("Zone '%s' not found", nameOrId))
346 case 1:
347 return &matches[0]
348 default:
349 errorAndExit("Multiple zones match - you will need to use Zone ID to uniquely identify the zone")
350 }
351 }
352 return nil
353}
354
355func waitForChange(ctx context.Context, change *route53types.ChangeInfo) {
356 fmt.Printf("Waiting for sync")

Callers 7

deleteZoneFunction · 0.85
importBindFunction · 0.85
exportBindFunction · 0.85
createRecordsFunction · 0.85
deleteRecordFunction · 0.85
purgeRecordsFunction · 0.85
instancesFunction · 0.85

Calls 5

isZoneIdFunction · 0.85
errorAndExitFunction · 0.85
zoneNameFunction · 0.85
fatalIfErrFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected