From 1f7889dbd3885e16599a4b3cee18abfa6014cb62 Mon Sep 17 00:00:00 2001 From: Steven Vernick <78868407+svernick@users.noreply.github.com> Date: Thu, 23 Dec 2021 15:16:37 -0500 Subject: [PATCH] AKAMAIEDGEDNS: fix staticcheck warnings/errors (#1346) * downcase TLSA * Akamai provider * Akamai provider * EdgeDNS provider * AkamaiEdgeDNS provider * AkamaiEdgeDNS provider * AkamaiEdgeDNS provider * AKAMAIEDGEDNS: fix staticcheck warnings/errors Co-authored-by: Tom Limoncelli --- docs/_includes/matrix.html | 41 +++++++++++++++++++ .../akamaiedgedns/akamaiEdgeDnsService.go | 38 ++++++++--------- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/docs/_includes/matrix.html b/docs/_includes/matrix.html index 20d03d67c..3677c2807 100644 --- a/docs/_includes/matrix.html +++ b/docs/_includes/matrix.html @@ -1380,6 +1380,47 @@ + + AKAMAICDN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + dual host diff --git a/providers/akamaiedgedns/akamaiEdgeDnsService.go b/providers/akamaiedgedns/akamaiEdgeDnsService.go index 76a3df8c8..a490abe55 100644 --- a/providers/akamaiedgedns/akamaiEdgeDnsService.go +++ b/providers/akamaiedgedns/akamaiEdgeDnsService.go @@ -56,22 +56,22 @@ func createZone(zonename string, contractID string, groupID string) error { err := dnsv2.ValidateZone(zone) if err != nil { - return fmt.Errorf("Invalid value provided for zone. Error: %s", err.Error()) + return fmt.Errorf("invalid value provided for zone. error: %s", err.Error()) } err = zone.Save(*queryArgs) if err != nil { - return fmt.Errorf("Zone create failed. Error: %s", err.Error()) + return fmt.Errorf("zone create failed. error: %s", err.Error()) } // Indirectly create NS and SOA records err = zone.SaveChangelist() if err != nil { - return fmt.Errorf("Zone initialization failed. SOA and NS records need to be created") + return fmt.Errorf("zone initialization failed. SOA and NS records need to be created") } err = zone.SubmitChangelist() if err != nil { - return fmt.Errorf("Zone create failed. Error: %s", err.Error()) + return fmt.Errorf("zone create failed. error: %s", err.Error()) } printer.Printf("Created zone: %s\n", zone.Zone) @@ -94,7 +94,7 @@ func listZones(contractID string) ([]string, error) { zoneListResp, err := dnsv2.ListZones(queryArgs) if err != nil { - return nil, fmt.Errorf("Zone List retrieval failed. Error: %s", err.Error()) + return nil, fmt.Errorf("zone list retrieval failed. error: %s", err.Error()) } edgeDNSZones := zoneListResp.Zones // what we have @@ -112,10 +112,10 @@ func isAutoDNSSecEnabled(zonename string) (bool, error) { zone, err := dnsv2.GetZone(zonename) if err != nil { if dnsv2.IsConfigDNSError(err) && err.(dnsv2.ConfigDNSError).NotFound() { - return false, fmt.Errorf("Zone %s does not exist. Error: %s", + return false, fmt.Errorf("zone %s does not exist. error: %s", zonename, err.Error()) } - return false, fmt.Errorf("Error retrieving information for zone %s. Error: %s", + return false, fmt.Errorf("error retrieving information for zone %s. error: %s", zonename, err.Error()) } return zone.SignAndServe, nil @@ -126,10 +126,10 @@ func autoDNSSecEnable(enable bool, zonename string) error { zone, err := dnsv2.GetZone(zonename) if err != nil { if dnsv2.IsConfigDNSError(err) && err.(dnsv2.ConfigDNSError).NotFound() { - return fmt.Errorf("Zone %s does not exist. Error: %s", + return fmt.Errorf("zone %s does not exist. error: %s", zonename, err.Error()) } - return fmt.Errorf("Error retrieving information for zone %s. Error: %s", + return fmt.Errorf("error retrieving information for zone %s. error: %s", zonename, err.Error()) } @@ -154,7 +154,7 @@ func autoDNSSecEnable(enable bool, zonename string) error { err = modifiedzone.Update(queryArgs) if err != nil { - return fmt.Errorf("Error updating zone %s. Error: %s", + return fmt.Errorf("error updating zone %s. error: %s", zonename, err.Error()) } @@ -167,17 +167,17 @@ func autoDNSSecEnable(enable bool, zonename string) error { func getAuthorities(contractID string) ([]string, error) { authorityResponse, err := dnsv2.GetAuthorities(contractID) if err != nil { - return nil, fmt.Errorf("getAuthorities - ContractID %s: Authorities retrieval failed. Error: %s", + return nil, fmt.Errorf("getAuthorities - contractid %s: authorities retrieval failed. Error: %s", contractID, err.Error()) } contracts := authorityResponse.Contracts if len(contracts) != 1 { - return nil, fmt.Errorf("getAuthorities - ContractID %s: Expected 1 element in array but got %d", + return nil, fmt.Errorf("getAuthorities - contractid %s: Expected 1 element in array but got %d", contractID, len(contracts)) } cid := contracts[0].ContractID if cid != contractID { - return nil, fmt.Errorf("getAuthorities - ContractID %s: Got authorities for wrong contractID (%s)", + return nil, fmt.Errorf("getAuthorities - contractID %s: got authorities for wrong contractID (%s)", contractID, cid) } authorities := contracts[0].Authorities @@ -187,7 +187,7 @@ func getAuthorities(contractID string) ([]string, error) { // rcToRs converts DNSControl RecordConfig records to an AkamaiEdgeDNS recordset. func rcToRs(records []*models.RecordConfig, zonename string) (*dnsv2.RecordBody, error) { if len(records) == 0 { - return nil, fmt.Errorf("No records to replace") + return nil, fmt.Errorf("no records to replace") } akaRecord := &dnsv2.RecordBody{ @@ -212,7 +212,7 @@ func createRecordset(records []*models.RecordConfig, zonename string) error { err = akaRecord.Save(zonename, true) if err != nil { - return fmt.Errorf("Recordset creation failed. Error: %s", err.Error()) + return fmt.Errorf("recordset creation failed. error: %s", err.Error()) } return nil } @@ -226,7 +226,7 @@ func replaceRecordset(records []*models.RecordConfig, zonename string) error { err = akaRecord.Update(zonename, true) if err != nil { - return fmt.Errorf("Recordset update failed. Error: %s", err.Error()) + return fmt.Errorf("recordset update failed. error: %s", err.Error()) } return nil } @@ -241,9 +241,9 @@ func deleteRecordset(records []*models.RecordConfig, zonename string) error { err = akaRecord.Delete(zonename, true) if err != nil { if dnsv2.IsConfigDNSError(err) && err.(dnsv2.ConfigDNSError).NotFound() { - return fmt.Errorf("Recordset not found") + return fmt.Errorf("recordset not found") } - return fmt.Errorf("Failed to delete recordset. Error: %s", err.Error()) + return fmt.Errorf("failed to delete recordset. error: %s", err.Error()) } return nil } @@ -268,7 +268,7 @@ func getRecords(zonename string) ([]*models.RecordConfig, error) { rsetResp, err := dnsv2.GetRecordsets(zonename, queryArgs) if err != nil { - return nil, fmt.Errorf("Recordset list retrieval failed. Error: %s", err.Error()) + return nil, fmt.Errorf("recordset list retrieval failed. error: %s", err.Error()) } akaRecordsets := rsetResp.Recordsets // what we have