mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 17:46:57 +02:00
CI linting fixes (#3205)
* ci linting fixes Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * remove staticcheck Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * disable naming rule Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * disable stylecheck too Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * linter errors fixes Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * re-add staticcheck Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * fixes various linting issues Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * fix imports Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * fix tlsconfig Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * fix alibabacloud Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * ioutil fixes Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * remove all references to ioutil Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * ignore linting for azure deprecated sdk Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com>
This commit is contained in:
parent
bbd007eed5
commit
31e6bb8578
@ -7,6 +7,12 @@ linters-settings:
|
|||||||
suggest-new: true
|
suggest-new: true
|
||||||
misspell:
|
misspell:
|
||||||
locale: US
|
locale: US
|
||||||
|
revive:
|
||||||
|
confusing-naming: false
|
||||||
|
ignore-generated-header: true
|
||||||
|
rules:
|
||||||
|
- name: confusing-naming
|
||||||
|
disabled: true
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
# please, do not use `enable-all`: it's deprecated and will be removed soon.
|
# please, do not use `enable-all`: it's deprecated and will be removed soon.
|
||||||
@ -25,6 +31,10 @@ linters:
|
|||||||
- typecheck
|
- typecheck
|
||||||
- unconvert
|
- unconvert
|
||||||
- whitespace
|
- whitespace
|
||||||
|
- revive
|
||||||
|
- unused
|
||||||
|
- gosimple
|
||||||
|
- staticcheck
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
# Excluding configuration per-path, per-linter, per-text and per-source
|
# Excluding configuration per-path, per-linter, per-text and per-source
|
||||||
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
package testutils
|
package testutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
config.FastPoll = true
|
config.FastPoll = true
|
||||||
if os.Getenv("DEBUG") == "" {
|
if os.Getenv("DEBUG") == "" {
|
||||||
logrus.SetOutput(ioutil.Discard)
|
logrus.SetOutput(io.Discard)
|
||||||
log.SetOutput(ioutil.Discard)
|
log.SetOutput(io.Discard)
|
||||||
} else {
|
} else {
|
||||||
if level, err := logrus.ParseLevel(os.Getenv("DEBUG")); err == nil {
|
if level, err := logrus.ParseLevel(os.Getenv("DEBUG")); err == nil {
|
||||||
logrus.SetLevel(level)
|
logrus.SetLevel(level)
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -77,7 +76,7 @@ func loadRoots(caPath string) (*x509.CertPool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
roots := x509.NewCertPool()
|
roots := x509.NewCertPool()
|
||||||
pem, err := ioutil.ReadFile(caPath)
|
pem, err := os.ReadFile(caPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error reading %s: %s", caPath, err)
|
return nil, fmt.Errorf("error reading %s: %s", caPath, err)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package alibabacloud
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -99,7 +99,7 @@ type alibabaCloudConfig struct {
|
|||||||
func NewAlibabaCloudProvider(configFile string, domainFilter endpoint.DomainFilter, zoneIDFileter provider.ZoneIDFilter, zoneType string, dryRun bool) (*AlibabaCloudProvider, error) {
|
func NewAlibabaCloudProvider(configFile string, domainFilter endpoint.DomainFilter, zoneIDFileter provider.ZoneIDFilter, zoneType string, dryRun bool) (*AlibabaCloudProvider, error) {
|
||||||
cfg := alibabaCloudConfig{}
|
cfg := alibabaCloudConfig{}
|
||||||
if configFile != "" {
|
if configFile != "" {
|
||||||
contents, err := ioutil.ReadFile(configFile)
|
contents, err := os.ReadFile(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read Alibaba Cloud config file '%s': %v", configFile, err)
|
return nil, fmt.Errorf("failed to read Alibaba Cloud config file '%s': %v", configFile, err)
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// nolint:staticcheck
|
||||||
package azure
|
package azure
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// nolint:staticcheck
|
||||||
package azure
|
package azure
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -18,7 +18,7 @@ package azure
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Azure/go-autorest/autorest/adal"
|
"github.com/Azure/go-autorest/autorest/adal"
|
||||||
@ -42,7 +42,7 @@ type config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getConfig(configFile, resourceGroup, userAssignedIdentityClientID string) (*config, error) {
|
func getConfig(configFile, resourceGroup, userAssignedIdentityClientID string) (*config, error) {
|
||||||
contents, err := ioutil.ReadFile(configFile)
|
contents, err := os.ReadFile(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read Azure config file '%s': %v", configFile, err)
|
return nil, fmt.Errorf("failed to read Azure config file '%s': %v", configFile, err)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package azure
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
@ -27,7 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGetAzureEnvironmentConfig(t *testing.T) {
|
func TestGetAzureEnvironmentConfig(t *testing.T) {
|
||||||
tmp, err := ioutil.TempFile("", "azureconf")
|
tmp, err := os.CreateTemp("", "azureconf")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("couldn't write temp file %v", err)
|
t.Errorf("couldn't write temp file %v", err)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@ -181,7 +180,7 @@ func GetBluecatGatewayToken(cfg BluecatConfig) (string, http.Cookie, error) {
|
|||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
responseBody, err := ioutil.ReadAll(response.Body)
|
responseBody, err := io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", http.Cookie{}, errors.Wrap(err, "failed to read login response from bluecat gateway")
|
return "", http.Cookie{}, errors.Wrap(err, "failed to read login response from bluecat gateway")
|
||||||
}
|
}
|
||||||
@ -504,7 +503,7 @@ func (c GatewayClientConfig) ServerFullDeploy() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if response.StatusCode != http.StatusCreated {
|
if response.StatusCode != http.StatusCreated {
|
||||||
responseBody, err := ioutil.ReadAll(response.Body)
|
responseBody, err := io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to read full deploy response body")
|
return errors.Wrap(err, "failed to read full deploy response body")
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
@ -100,7 +100,7 @@ func TestBluecatSplitProperties(t *testing.T) {
|
|||||||
func TestCreateTXTRecord(t *testing.T) {
|
func TestCreateTXTRecord(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
req := BluecatCreateTXTRecordRequest{}
|
req := BluecatCreateTXTRecordRequest{}
|
||||||
requestBodyBytes, _ := ioutil.ReadAll(r.Body)
|
requestBodyBytes, _ := io.ReadAll(r.Body)
|
||||||
err := json.Unmarshal(requestBodyBytes, &req)
|
err := json.Unmarshal(requestBodyBytes, &req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to unmarshal body for server full deploy")
|
t.Fatalf("failed to unmarshal body for server full deploy")
|
||||||
@ -196,7 +196,7 @@ func TestDeleteTXTRecord(t *testing.T) {
|
|||||||
func TestServerFullDeploy(t *testing.T) {
|
func TestServerFullDeploy(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
req := BluecatServerFullDeployRequest{}
|
req := BluecatServerFullDeployRequest{}
|
||||||
requestBodyBytes, _ := ioutil.ReadAll(r.Body)
|
requestBodyBytes, _ := io.ReadAll(r.Body)
|
||||||
err := json.Unmarshal(requestBodyBytes, &req)
|
err := json.Unmarshal(requestBodyBytes, &req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to unmarshal body for server full deploy")
|
t.Fatalf("failed to unmarshal body for server full deploy")
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
@ -191,7 +190,7 @@ func loadRoots(caPath string) (*x509.CertPool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
roots := x509.NewCertPool()
|
roots := x509.NewCertPool()
|
||||||
pem, err := ioutil.ReadFile(caPath)
|
pem, err := os.ReadFile(caPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error reading %s: %s", caPath, err)
|
return nil, fmt.Errorf("error reading %s: %s", caPath, err)
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
@ -174,7 +173,7 @@ func TestNewDesignateProvider(t *testing.T) {
|
|||||||
Type: "CERTIFICATE",
|
Type: "CERTIFICATE",
|
||||||
Bytes: ts.Certificate().Raw,
|
Bytes: ts.Certificate().Raw,
|
||||||
}
|
}
|
||||||
tmpfile, err := ioutil.TempFile("", "os-test.crt")
|
tmpfile, err := os.CreateTemp("", "os-test.crt")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ func (c *Client) CallAPIWithContext(ctx context.Context, method, path string, re
|
|||||||
func (c *Client) UnmarshalResponse(response *http.Response, resType interface{}) error {
|
func (c *Client) UnmarshalResponse(response *http.Response, resType interface{}) error {
|
||||||
// Read all the response body
|
// Read all the response body
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
body, err := ioutil.ReadAll(response.Body)
|
body, err := io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package ibmcloud
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -201,7 +201,7 @@ type ibmcloudChange struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getConfig(configFile string) (*ibmcloudConfig, error) {
|
func getConfig(configFile string) (*ibmcloudConfig, error) {
|
||||||
contents, err := ioutil.ReadFile(configFile)
|
contents, err := os.ReadFile(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read IBM Cloud config file '%s': %v", configFile, err)
|
return nil, fmt.Errorf("failed to read IBM Cloud config file '%s': %v", configFile, err)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ package oci
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/oracle/oci-go-sdk/common"
|
"github.com/oracle/oci-go-sdk/common"
|
||||||
@ -72,7 +72,7 @@ type ociDNSClient interface {
|
|||||||
// LoadOCIConfig reads and parses the OCI ExternalDNS config file at the given
|
// LoadOCIConfig reads and parses the OCI ExternalDNS config file at the given
|
||||||
// path.
|
// path.
|
||||||
func LoadOCIConfig(path string) (*OCIConfig, error) {
|
func LoadOCIConfig(path string) (*OCIConfig, error) {
|
||||||
contents, err := ioutil.ReadFile(path)
|
contents, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "reading OCI config file %q", path)
|
return nil, errors.Wrapf(err, "reading OCI config file %q", path)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/cookiejar"
|
"net/http/cookiejar"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -114,7 +113,7 @@ func (p *piholeClient) listRecords(ctx context.Context, rtype string) ([]*endpoi
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer body.Close()
|
defer body.Close()
|
||||||
raw, err := ioutil.ReadAll(body)
|
raw, err := io.ReadAll(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -207,11 +206,11 @@ func (p *piholeClient) apply(ctx context.Context, action string, ep *endpoint.En
|
|||||||
}
|
}
|
||||||
|
|
||||||
if p.cfg.DryRun {
|
if p.cfg.DryRun {
|
||||||
log.Infof("DRY RUN: %s %s IN %s -> %s", strings.Title(action), ep.DNSName, ep.RecordType, ep.Targets[0])
|
log.Infof("DRY RUN: %s %s IN %s -> %s", action, ep.DNSName, ep.RecordType, ep.Targets[0])
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("%s %s IN %s -> %s", strings.Title(action), ep.DNSName, ep.RecordType, ep.Targets[0])
|
log.Infof("%s %s IN %s -> %s", action, ep.DNSName, ep.RecordType, ep.Targets[0])
|
||||||
|
|
||||||
form := p.newDNSActionForm(action, ep)
|
form := p.newDNSActionForm(action, ep)
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, strings.NewReader(form.Encode()))
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, strings.NewReader(form.Encode()))
|
||||||
@ -226,7 +225,7 @@ func (p *piholeClient) apply(ctx context.Context, action string, ep *endpoint.En
|
|||||||
}
|
}
|
||||||
defer body.Close()
|
defer body.Close()
|
||||||
|
|
||||||
raw, err := ioutil.ReadAll(body)
|
raw, err := io.ReadAll(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
package provider
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
log.SetOutput(ioutil.Discard)
|
log.SetOutput(io.Discard)
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -309,7 +308,7 @@ func newEtcdv3Client() (RDNSClient, error) {
|
|||||||
|
|
||||||
if ca != "" {
|
if ca != "" {
|
||||||
roots := x509.NewCertPool()
|
roots := x509.NewCertPool()
|
||||||
pem, err := ioutil.ReadFile(ca)
|
pem, err := os.ReadFile(ca)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error reading %s: %s", ca, err)
|
return nil, fmt.Errorf("error reading %s: %s", ca, err)
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ func (api *defaultTencentAPIService) CreatePrivateZoneRecord(request *privatedns
|
|||||||
client := api.ClientSetService.PrivateDnsCli(apiAction.Name)
|
client := api.ClientSetService.PrivateDnsCli(apiAction.Name)
|
||||||
if response, err = client.CreatePrivateZoneRecord(request); err != nil {
|
if response, err = client.CreatePrivateZoneRecord(request); err != nil {
|
||||||
requestJson := JsonWrapper(request)
|
requestJson := JsonWrapper(request)
|
||||||
if retry := dealWithError(apiAction, requestJson, err); retry == false || times == api.RetryDefault {
|
if retry := dealWithError(apiAction, requestJson, err); retry || times == api.RetryDefault {
|
||||||
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ func (api *defaultTencentAPIService) DeletePrivateZoneRecord(request *privatedns
|
|||||||
client := api.ClientSetService.PrivateDnsCli(apiAction.Name)
|
client := api.ClientSetService.PrivateDnsCli(apiAction.Name)
|
||||||
if response, err = client.DeletePrivateZoneRecord(request); err != nil {
|
if response, err = client.DeletePrivateZoneRecord(request); err != nil {
|
||||||
requestJson := JsonWrapper(request)
|
requestJson := JsonWrapper(request)
|
||||||
if retry := dealWithError(apiAction, requestJson, err); retry == false || times == api.RetryDefault {
|
if retry := dealWithError(apiAction, requestJson, err); retry || times == api.RetryDefault {
|
||||||
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ func (api *defaultTencentAPIService) ModifyPrivateZoneRecord(request *privatedns
|
|||||||
client := api.ClientSetService.PrivateDnsCli(apiAction.Name)
|
client := api.ClientSetService.PrivateDnsCli(apiAction.Name)
|
||||||
if response, err = client.ModifyPrivateZoneRecord(request); err != nil {
|
if response, err = client.ModifyPrivateZoneRecord(request); err != nil {
|
||||||
requestJson := JsonWrapper(request)
|
requestJson := JsonWrapper(request)
|
||||||
if retry := dealWithError(apiAction, requestJson, err); retry == false || times == api.RetryDefault {
|
if retry := dealWithError(apiAction, requestJson, err); retry || times == api.RetryDefault {
|
||||||
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ func (api *defaultTencentAPIService) DescribePrivateZoneList(request *privatedns
|
|||||||
client := api.ClientSetService.PrivateDnsCli(apiAction.Name)
|
client := api.ClientSetService.PrivateDnsCli(apiAction.Name)
|
||||||
if response, err = client.DescribePrivateZoneList(request); err != nil {
|
if response, err = client.DescribePrivateZoneList(request); err != nil {
|
||||||
requestJson := JsonWrapper(request)
|
requestJson := JsonWrapper(request)
|
||||||
if retry := dealWithError(apiAction, requestJson, err); retry == false || times == api.RetryDefault {
|
if retry := dealWithError(apiAction, requestJson, err); retry || times == api.RetryDefault {
|
||||||
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ func (api *defaultTencentAPIService) DescribePrivateZoneRecordList(request *priv
|
|||||||
client := api.ClientSetService.PrivateDnsCli(apiAction.Name)
|
client := api.ClientSetService.PrivateDnsCli(apiAction.Name)
|
||||||
if response, err = client.DescribePrivateZoneRecordList(request); err != nil {
|
if response, err = client.DescribePrivateZoneRecordList(request); err != nil {
|
||||||
requestJson := JsonWrapper(request)
|
requestJson := JsonWrapper(request)
|
||||||
if retry := dealWithError(apiAction, requestJson, err); retry == false || times == api.RetryDefault {
|
if retry := dealWithError(apiAction, requestJson, err); retry || times == api.RetryDefault {
|
||||||
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ func (api *defaultTencentAPIService) DescribeDomainList(request *dnspod.Describe
|
|||||||
client := api.ClientSetService.DnsPodCli(apiAction.Name)
|
client := api.ClientSetService.DnsPodCli(apiAction.Name)
|
||||||
if response, err = client.DescribeDomainList(request); err != nil {
|
if response, err = client.DescribeDomainList(request); err != nil {
|
||||||
requestJson := JsonWrapper(request)
|
requestJson := JsonWrapper(request)
|
||||||
if retry := dealWithError(apiAction, requestJson, err); retry == false || times == api.RetryDefault {
|
if retry := dealWithError(apiAction, requestJson, err); retry || times == api.RetryDefault {
|
||||||
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ func (api *defaultTencentAPIService) DescribeRecordList(request *dnspod.Describe
|
|||||||
client := api.ClientSetService.DnsPodCli(apiAction.Name)
|
client := api.ClientSetService.DnsPodCli(apiAction.Name)
|
||||||
if response, err = client.DescribeRecordList(request); err != nil {
|
if response, err = client.DescribeRecordList(request); err != nil {
|
||||||
requestJson := JsonWrapper(request)
|
requestJson := JsonWrapper(request)
|
||||||
if retry := dealWithError(apiAction, requestJson, err); retry == false || times == api.RetryDefault {
|
if retry := dealWithError(apiAction, requestJson, err); retry || times == api.RetryDefault {
|
||||||
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ func (api *defaultTencentAPIService) CreateRecord(request *dnspod.CreateRecordRe
|
|||||||
client := api.ClientSetService.DnsPodCli(apiAction.Name)
|
client := api.ClientSetService.DnsPodCli(apiAction.Name)
|
||||||
if response, err = client.CreateRecord(request); err != nil {
|
if response, err = client.CreateRecord(request); err != nil {
|
||||||
requestJson := JsonWrapper(request)
|
requestJson := JsonWrapper(request)
|
||||||
if retry := dealWithError(apiAction, requestJson, err); retry == false || times == api.RetryDefault {
|
if retry := dealWithError(apiAction, requestJson, err); retry || times == api.RetryDefault {
|
||||||
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ func (api *defaultTencentAPIService) DeleteRecord(request *dnspod.DeleteRecordRe
|
|||||||
client := api.ClientSetService.DnsPodCli(apiAction.Name)
|
client := api.ClientSetService.DnsPodCli(apiAction.Name)
|
||||||
if response, err = client.DeleteRecord(request); err != nil {
|
if response, err = client.DeleteRecord(request); err != nil {
|
||||||
requestJson := JsonWrapper(request)
|
requestJson := JsonWrapper(request)
|
||||||
if retry := dealWithError(apiAction, requestJson, err); retry == false || times == api.RetryDefault {
|
if retry := dealWithError(apiAction, requestJson, err); retry || times == api.RetryDefault {
|
||||||
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ func (api *defaultTencentAPIService) ModifyRecord(request *dnspod.ModifyRecordRe
|
|||||||
client := api.ClientSetService.DnsPodCli(apiAction.Name)
|
client := api.ClientSetService.DnsPodCli(apiAction.Name)
|
||||||
if response, err = client.ModifyRecord(request); err != nil {
|
if response, err = client.ModifyRecord(request); err != nil {
|
||||||
requestJson := JsonWrapper(request)
|
requestJson := JsonWrapper(request)
|
||||||
if retry := dealWithError(apiAction, requestJson, err); retry == false || times == api.RetryDefault {
|
if retry := dealWithError(apiAction, requestJson, err); retry || times == api.RetryDefault {
|
||||||
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
APIErrorRecord(apiAction, requestJson, JsonWrapper(response), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,6 @@ func NewTencentCloudProvider(domainFilter endpoint.DomainFilter, zoneIDFilter pr
|
|||||||
|
|
||||||
type TencentCloudProvider struct {
|
type TencentCloudProvider struct {
|
||||||
provider.BaseProvider
|
provider.BaseProvider
|
||||||
logger *log.Logger
|
|
||||||
apiService cloudapi.TencentAPIService
|
apiService cloudapi.TencentAPIService
|
||||||
domainFilter endpoint.DomainFilter
|
domainFilter endpoint.DomainFilter
|
||||||
zoneIDFilter provider.ZoneIDFilter // Private Zone only
|
zoneIDFilter provider.ZoneIDFilter // Private Zone only
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -54,7 +53,7 @@ func defaultHeader() http.Header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func objBody(codec runtime.Encoder, obj runtime.Object) io.ReadCloser {
|
func objBody(codec runtime.Encoder, obj runtime.Object) io.ReadCloser {
|
||||||
return ioutil.NopCloser(bytes.NewReader([]byte(runtime.EncodeOrDie(codec, obj))))
|
return io.NopCloser(bytes.NewReader([]byte(runtime.EncodeOrDie(codec, obj))))
|
||||||
}
|
}
|
||||||
|
|
||||||
func fakeRESTClient(endpoints []*endpoint.Endpoint, apiVersion, kind, namespace, name string, annotations map[string]string, labels map[string]string, t *testing.T) rest.Interface {
|
func fakeRESTClient(endpoints []*endpoint.Endpoint, apiVersion, kind, namespace, name string, annotations map[string]string, labels map[string]string, t *testing.T) rest.Interface {
|
||||||
|
@ -23,10 +23,10 @@ import (
|
|||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -116,7 +116,7 @@ func newRouteGroupClient(token, tokenPath string, timeout time.Duration) *routeG
|
|||||||
cli.updateToken()
|
cli.updateToken()
|
||||||
|
|
||||||
// cluster internal use custom CA to reach TLS endpoint
|
// cluster internal use custom CA to reach TLS endpoint
|
||||||
rootCA, err := ioutil.ReadFile(rootCAFile)
|
rootCA, err := os.ReadFile(rootCAFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli
|
return cli
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ func (cli *routeGroupClient) updateToken() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
token, err := ioutil.ReadFile(cli.tokenFile)
|
token, err := os.ReadFile(cli.tokenFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to read token from file (%s): %v", cli.tokenFile, err)
|
log.Errorf("Failed to read token from file (%s): %v", cli.tokenFile, err)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user