chore: update linter
This commit is contained in:
parent
12e50e20e6
commit
553ef94047
46 changed files with 129 additions and 105 deletions
|
@ -30,6 +30,8 @@ import (
|
|||
"github.com/traefik/traefik/v2/pkg/version"
|
||||
)
|
||||
|
||||
const resolverSuffix = ".acme"
|
||||
|
||||
// ocspMustStaple enables OCSP stapling as from https://github.com/go-acme/lego/issues/270.
|
||||
var ocspMustStaple = false
|
||||
|
||||
|
@ -131,7 +133,7 @@ func (p *Provider) ListenConfiguration(config dynamic.Configuration) {
|
|||
|
||||
// Init for compatibility reason the BaseProvider implements an empty Init.
|
||||
func (p *Provider) Init() error {
|
||||
ctx := log.With(context.Background(), log.Str(log.ProviderName, p.ResolverName+".acme"))
|
||||
ctx := log.With(context.Background(), log.Str(log.ProviderName, p.ResolverName+resolverSuffix))
|
||||
logger := log.FromContext(ctx)
|
||||
|
||||
if len(p.Configuration.Storage) == 0 {
|
||||
|
@ -195,7 +197,7 @@ func (p *Provider) ThrottleDuration() time.Duration {
|
|||
// using the given Configuration channel.
|
||||
func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.Pool) error {
|
||||
ctx := log.With(context.Background(),
|
||||
log.Str(log.ProviderName, p.ResolverName+".acme"),
|
||||
log.Str(log.ProviderName, p.ResolverName+resolverSuffix),
|
||||
log.Str("ACME CA", p.Configuration.CAServer))
|
||||
|
||||
p.pool = pool
|
||||
|
@ -236,7 +238,7 @@ func (p *Provider) getClient() (*lego.Client, error) {
|
|||
p.clientMutex.Lock()
|
||||
defer p.clientMutex.Unlock()
|
||||
|
||||
ctx := log.With(context.Background(), log.Str(log.ProviderName, p.ResolverName+".acme"))
|
||||
ctx := log.With(context.Background(), log.Str(log.ProviderName, p.ResolverName+resolverSuffix))
|
||||
logger := log.FromContext(ctx)
|
||||
|
||||
if p.client != nil {
|
||||
|
@ -406,7 +408,7 @@ func (p *Provider) resolveDomains(ctx context.Context, domains []string, tlsStor
|
|||
}
|
||||
|
||||
func (p *Provider) watchNewDomains(ctx context.Context) {
|
||||
ctx = log.With(ctx, log.Str(log.ProviderName, p.ResolverName+".acme"))
|
||||
ctx = log.With(ctx, log.Str(log.ProviderName, p.ResolverName+resolverSuffix))
|
||||
p.pool.GoCtx(func(ctxPool context.Context) {
|
||||
for {
|
||||
select {
|
||||
|
@ -765,7 +767,7 @@ func deleteUnnecessaryDomains(ctx context.Context, domains []types.Domain) []typ
|
|||
|
||||
func (p *Provider) buildMessage() dynamic.Message {
|
||||
conf := dynamic.Message{
|
||||
ProviderName: p.ResolverName + ".acme",
|
||||
ProviderName: p.ResolverName + resolverSuffix,
|
||||
Configuration: &dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
|
|
|
@ -580,7 +580,7 @@ func TestInitAccount(t *testing.T) {
|
|||
acmeProvider := Provider{account: test.account, Configuration: &Configuration{Email: test.email, KeyType: test.keyType}}
|
||||
|
||||
actualAccount, err := acmeProvider.initAccount(context.Background())
|
||||
assert.Nil(t, err, "Init account in error")
|
||||
assert.NoError(t, err, "Init account in error")
|
||||
assert.Equal(t, test.expectedAccount.Email, actualAccount.Email, "unexpected email account")
|
||||
assert.Equal(t, test.expectedAccount.KeyType, actualAccount.KeyType, "unexpected keyType account")
|
||||
})
|
||||
|
|
|
@ -8,8 +8,8 @@ type StoredData struct {
|
|||
|
||||
// Store is a generic interface that represents a storage.
|
||||
type Store interface {
|
||||
GetAccount(string) (*Account, error)
|
||||
SaveAccount(string, *Account) error
|
||||
GetCertificates(string) ([]*CertAndStore, error)
|
||||
SaveCertificates(string, []*CertAndStore) error
|
||||
GetAccount(resolverName string) (*Account, error)
|
||||
SaveAccount(resolverName string, account *Account) error
|
||||
GetCertificates(resolverName string) ([]*CertAndStore, error)
|
||||
SaveCertificates(resolverName string, certificates []*CertAndStore) error
|
||||
}
|
||||
|
|
|
@ -145,10 +145,10 @@ func TestProvideWithWatch(t *testing.T) {
|
|||
require.NotNil(t, conf.Configuration.HTTP)
|
||||
numServices := len(conf.Configuration.HTTP.Services) + len(conf.Configuration.TCP.Services) + len(conf.Configuration.UDP.Services)
|
||||
numRouters := len(conf.Configuration.HTTP.Routers) + len(conf.Configuration.TCP.Routers) + len(conf.Configuration.UDP.Routers)
|
||||
assert.Equal(t, numServices, 0)
|
||||
assert.Equal(t, numRouters, 0)
|
||||
assert.Equal(t, 0, numServices)
|
||||
assert.Equal(t, 0, numRouters)
|
||||
require.NotNil(t, conf.Configuration.TLS)
|
||||
assert.Len(t, conf.Configuration.TLS.Certificates, 0)
|
||||
assert.Empty(t, conf.Configuration.TLS.Certificates)
|
||||
case <-timeout:
|
||||
t.Errorf("timeout while waiting for config")
|
||||
}
|
||||
|
|
|
@ -251,5 +251,5 @@ func TestProvider_ProvideConfigurationOnlyOnceIfUnchanged(t *testing.T) {
|
|||
|
||||
time.Sleep(time.Second)
|
||||
|
||||
assert.Equal(t, 1, len(configurationChan))
|
||||
assert.Len(t, configurationChan, 1)
|
||||
}
|
||||
|
|
|
@ -6551,7 +6551,7 @@ func TestCreateBasicAuthCredentials(t *testing.T) {
|
|||
username = components[0]
|
||||
hashedPassword = components[1]
|
||||
|
||||
assert.Equal(t, username, "test2")
|
||||
assert.Equal(t, hashedPassword, "$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0")
|
||||
assert.Equal(t, "test2", username)
|
||||
assert.Equal(t, "$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0", hashedPassword)
|
||||
assert.True(t, auth.CheckSecret("test2", hashedPassword))
|
||||
}
|
||||
|
|
|
@ -5204,7 +5204,7 @@ func Test_getAllowedRoutes(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
require.Len(t, conditions, 0)
|
||||
require.Empty(t, conditions)
|
||||
assert.Equal(t, test.wantKinds, got)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ type marshaler interface {
|
|||
}
|
||||
|
||||
type unmarshaler interface {
|
||||
Unmarshal([]byte) error
|
||||
Unmarshal(data []byte) error
|
||||
}
|
||||
|
||||
type LoadBalancerIngress interface {
|
||||
|
|
|
@ -319,7 +319,7 @@ func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Cl
|
|||
portString := pa.Backend.Service.Port.Name
|
||||
|
||||
if len(pa.Backend.Service.Port.Name) == 0 {
|
||||
portString = fmt.Sprint(pa.Backend.Service.Port.Number)
|
||||
portString = strconv.Itoa(int(pa.Backend.Service.Port.Number))
|
||||
}
|
||||
|
||||
serviceName := provider.Normalize(ingress.Namespace + "-" + pa.Backend.Service.Name + "-" + portString)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue