Skip to content

Commit

Permalink
feat: Showing a warning when AuthEmail is configured as it is depreca…
Browse files Browse the repository at this point in the history
…ted now
  • Loading branch information
boris1993 committed Sep 14, 2022
1 parent cbf67ec commit 64b5ce3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion internal/common/errormsg.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package constants contains all constants needed in this programme
// Package common contains all constants needed in this programme
package common

const MsgHeaderDNSRecordUpdateSuccessful = "Successfully updated the DNS record"
Expand Down Expand Up @@ -31,3 +31,5 @@ const ErrCloudFlareAPIAddressEmpty = "CloudFlare API endpoint address cannot be
const ErrAliyunAPIAddressEmpty = "Aliyun API endpoint address cannot be empty"
const ErrCloudFlareRecordConfigIncomplete = "Incomplete CloudFlare configuration found"
const ErrAliDNSRecordConfigIncomplete = "Incomplete Aliyun DNS configuration found"

const WarnAuthEmailDeprecated = "AuthEmail is deprecated. Please use dedicated API token if you are still using Global API Key."
8 changes: 5 additions & 3 deletions internal/helper/cloudflare/cloudflare_dns_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/boris1993/dnsupdater/internal/common"
"github.com/boris1993/dnsupdater/internal/conf"
log "github.com/sirupsen/logrus"
"io/ioutil"
"io"
"net/http"
)

Expand Down Expand Up @@ -135,7 +135,7 @@ func getCFDnsRecordIpAddress(cloudFlareRecord conf.CloudFlare) (string, string,
return "", "", err
}

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", "", err
}
Expand Down Expand Up @@ -234,7 +234,7 @@ func updateCFDNSRecord(id string, address string, cloudFlareRecord conf.CloudFla
}
}()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)

if err != nil {
return false, err
Expand All @@ -259,5 +259,7 @@ func composeRequestHeader(req *http.Request, cloudFlareRecord conf.CloudFlare) {

if cloudFlareRecord.AuthEmail != "" {
req.Header.Add("X-Auth-Email", cloudFlareRecord.AuthEmail)

log.Warn(common.WarnAuthEmailDeprecated)
}
}

0 comments on commit 64b5ce3

Please sign in to comment.