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

Function deleteRecord

commands.go:696–729  ·  view source on GitHub ↗
(ctx context.Context, name string, match string, rtype string, wait bool, identifier string)

Source from the content-addressed store, hash-verified

694}
695
696func deleteRecord(ctx context.Context, name string, match string, rtype string, wait bool, identifier string) {
697 zone := lookupZone(ctx, name)
698 rrsets, err := ListAllRecordSets(ctx, r53, *zone.Id)
699 fatalIfErr(err)
700
701 match = qualifyName(match, *zone.Name)
702 changes := []route53types.Change{}
703 for _, rrset := range rrsets {
704 if *rrset.Name == match && rrset.Type == route53types.RRType(rtype) && (identifier == "" || (rrset.SetIdentifier != nil && *rrset.SetIdentifier == identifier)) {
705 change := route53types.Change{
706 Action: route53types.ChangeActionDelete,
707 ResourceRecordSet: rrset,
708 }
709 changes = append(changes, change)
710 }
711 }
712
713 if len(changes) > 0 {
714 req2 := route53.ChangeResourceRecordSetsInput{
715 HostedZoneId: zone.Id,
716 ChangeBatch: &route53types.ChangeBatch{
717 Changes: changes,
718 },
719 }
720 resp, err := r53.ChangeResourceRecordSets(ctx, &req2)
721 fatalIfErr(err)
722 fmt.Printf("%d record sets deleted\n", len(changes))
723 if wait {
724 waitForChange(ctx, resp.ChangeInfo)
725 }
726 } else {
727 fmt.Println("Warning: no records matched - nothing deleted")
728 }
729}
730
731func purgeRecords(ctx context.Context, name string, wait bool) {
732 zone := lookupZone(ctx, name)

Callers 1

MainFunction · 0.85

Calls 5

lookupZoneFunction · 0.85
ListAllRecordSetsFunction · 0.85
qualifyNameFunction · 0.85
waitForChangeFunction · 0.85
fatalIfErrFunction · 0.70

Tested by

no test coverage detected