mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
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 <tlimoncelli@stackoverflow.com>
This commit is contained in:
@@ -1380,6 +1380,47 @@
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="row-header" style="text-decoration: underline;" data-toggle="tooltip" data-container="body" data-placement="top" title="Provider supports adding AKAMAICDN records">AKAMAICDN</th>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td class="success">
|
||||
<i class="fa fa-check text-success" aria-hidden="true"></i>
|
||||
</td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
<td><i class="fa fa-minus dim"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="row-header" style="text-decoration: underline;" data-toggle="tooltip" data-container="body" data-placement="top" title="This provider is recommended for use in 'dual hosting' scenarios. Usually this means the provider allows full control over the apex NS records">dual host</th>
|
||||
<td class="danger" data-toggle="tooltip" data-container="body" data-placement="top" title="This driver does not manage NS records, so should not be used for dual-host scenarios">
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user