chore: update linter
This commit is contained in:
parent
1034646ae2
commit
88a2020817
57 changed files with 139 additions and 218 deletions
|
@ -2,6 +2,7 @@ package acme
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -118,7 +119,7 @@ func (c *ChallengeTLSALPN) ListenConfiguration(conf dynamic.Configuration) {
|
|||
c.muChans.Lock()
|
||||
|
||||
for _, certificate := range conf.TLS.Certificates {
|
||||
if !containsACMETLS1(certificate.Stores) {
|
||||
if !slices.Contains(certificate.Stores, tlsalpn01.ACMETLS1Protocol) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -161,13 +162,3 @@ func createMessage(certs map[string]*Certificate) dynamic.Message {
|
|||
|
||||
return conf
|
||||
}
|
||||
|
||||
func containsACMETLS1(stores []string) bool {
|
||||
for _, store := range stores {
|
||||
if store == tlsalpn01.ACMETLS1Protocol {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -424,7 +424,7 @@ func (p *Provider) watchNewDomains(ctx context.Context) {
|
|||
|
||||
if len(route.TLS.Domains) > 0 {
|
||||
domains := deleteUnnecessaryDomains(ctxRouter, route.TLS.Domains)
|
||||
for i := 0; i < len(domains); i++ {
|
||||
for i := range len(domains) {
|
||||
domain := domains[i]
|
||||
safe.Go(func() {
|
||||
dom, cert, err := p.resolveCertificate(ctx, domain, traefiktls.DefaultTLSStoreName)
|
||||
|
@ -461,7 +461,7 @@ func (p *Provider) watchNewDomains(ctx context.Context) {
|
|||
|
||||
if len(route.TLS.Domains) > 0 {
|
||||
domains := deleteUnnecessaryDomains(ctxRouter, route.TLS.Domains)
|
||||
for i := 0; i < len(domains); i++ {
|
||||
for i := range len(domains) {
|
||||
domain := domains[i]
|
||||
safe.Go(func() {
|
||||
dom, cert, err := p.resolveCertificate(ctx, domain, traefiktls.DefaultTLSStoreName)
|
||||
|
|
|
@ -3,6 +3,7 @@ package constraints
|
|||
import (
|
||||
"errors"
|
||||
"regexp"
|
||||
"slices"
|
||||
|
||||
"github.com/vulcand/predicate"
|
||||
)
|
||||
|
@ -47,12 +48,7 @@ func MatchTags(tags []string, expr string) (bool, error) {
|
|||
|
||||
func tagFn(name string) constraintTagFunc {
|
||||
return func(tags []string) bool {
|
||||
for _, tag := range tags {
|
||||
if tag == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(tags, name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,13 +59,9 @@ func tagRegexFn(expr string) constraintTagFunc {
|
|||
return false
|
||||
}
|
||||
|
||||
for _, tag := range tags {
|
||||
if exp.MatchString(tag) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
return slices.ContainsFunc(tags, func(tag string) bool {
|
||||
return exp.MatchString(tag)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ func TestDefaultRule(t *testing.T) {
|
|||
err := p.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
for i := 0; i < len(test.items); i++ {
|
||||
for i := range len(test.items) {
|
||||
var err error
|
||||
test.items[i].ExtraConf, err = p.getExtraConf(test.items[i].Labels)
|
||||
require.NoError(t, err)
|
||||
|
@ -2956,7 +2956,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
err := p.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
for i := 0; i < len(test.items); i++ {
|
||||
for i := range len(test.items) {
|
||||
var err error
|
||||
test.items[i].ExtraConf, err = p.getExtraConf(test.items[i].Labels)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -361,7 +361,7 @@ func TestDefaultRule(t *testing.T) {
|
|||
err := p.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
for i := 0; i < len(test.containers); i++ {
|
||||
for i := range len(test.containers) {
|
||||
var err error
|
||||
test.containers[i].ExtraConf, err = p.getConfiguration(test.containers[i])
|
||||
require.NoError(t, err)
|
||||
|
@ -3257,7 +3257,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
err := p.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
for i := 0; i < len(test.containers); i++ {
|
||||
for i := range len(test.containers) {
|
||||
var err error
|
||||
test.containers[i].ExtraConf, err = p.getConfiguration(test.containers[i])
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -333,7 +333,7 @@ func TestDefaultRule(t *testing.T) {
|
|||
err := p.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
for i := 0; i < len(test.instances); i++ {
|
||||
for i := range len(test.instances) {
|
||||
var err error
|
||||
test.instances[i].ExtraConf, err = p.getConfiguration(test.instances[i])
|
||||
require.NoError(t, err)
|
||||
|
@ -2863,7 +2863,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
err := p.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
for i := 0; i < len(test.containers); i++ {
|
||||
for i := range len(test.containers) {
|
||||
var err error
|
||||
test.containers[i].ExtraConf, err = p.getConfiguration(test.containers[i])
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -397,7 +397,7 @@ func (p *Provider) listInstances(ctx context.Context, client *awsClient) ([]ecsI
|
|||
}
|
||||
|
||||
func (p *Provider) lookupMiInstances(ctx context.Context, client *awsClient, clusterName *string, ecsDatas map[string]*ecs.Task) (map[string]*ssm.InstanceInformation, error) {
|
||||
instanceIds := make(map[string]string)
|
||||
instanceIDs := make(map[string]string)
|
||||
miInstances := make(map[string]*ssm.InstanceInformation)
|
||||
|
||||
var containerInstancesArns []*string
|
||||
|
@ -419,7 +419,7 @@ func (p *Provider) lookupMiInstances(ctx context.Context, client *awsClient, clu
|
|||
}
|
||||
|
||||
for _, container := range resp.ContainerInstances {
|
||||
instanceIds[aws.StringValue(container.Ec2InstanceId)] = aws.StringValue(container.ContainerInstanceArn)
|
||||
instanceIDs[aws.StringValue(container.Ec2InstanceId)] = aws.StringValue(container.ContainerInstanceArn)
|
||||
|
||||
// Disallow EC2 Instance IDs
|
||||
// This prevents considering EC2 instances in ECS
|
||||
|
@ -447,7 +447,7 @@ func (p *Provider) lookupMiInstances(ctx context.Context, client *awsClient, clu
|
|||
if len(page.InstanceInformationList) > 0 {
|
||||
for _, i := range page.InstanceInformationList {
|
||||
if i.InstanceId != nil {
|
||||
miInstances[instanceIds[aws.StringValue(i.InstanceId)]] = i
|
||||
miInstances[instanceIDs[aws.StringValue(i.InstanceId)]] = i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ func (p *Provider) lookupMiInstances(ctx context.Context, client *awsClient, clu
|
|||
}
|
||||
|
||||
func (p *Provider) lookupEc2Instances(ctx context.Context, client *awsClient, clusterName *string, ecsDatas map[string]*ecs.Task) (map[string]*ec2.Instance, error) {
|
||||
instanceIds := make(map[string]string)
|
||||
instanceIDs := make(map[string]string)
|
||||
ec2Instances := make(map[string]*ec2.Instance)
|
||||
|
||||
var containerInstancesArns []*string
|
||||
|
@ -485,7 +485,7 @@ func (p *Provider) lookupEc2Instances(ctx context.Context, client *awsClient, cl
|
|||
}
|
||||
|
||||
for _, container := range resp.ContainerInstances {
|
||||
instanceIds[aws.StringValue(container.Ec2InstanceId)] = aws.StringValue(container.ContainerInstanceArn)
|
||||
instanceIDs[aws.StringValue(container.Ec2InstanceId)] = aws.StringValue(container.ContainerInstanceArn)
|
||||
// Disallow Instance IDs of the form mi-*
|
||||
// This prevents considering external instances in ECS Anywhere setups
|
||||
// and getting InvalidInstanceID.Malformed error when calling the describe-instances endpoint.
|
||||
|
@ -508,7 +508,7 @@ func (p *Provider) lookupEc2Instances(ctx context.Context, client *awsClient, cl
|
|||
for _, r := range page.Reservations {
|
||||
for _, i := range r.Instances {
|
||||
if i.InstanceId != nil {
|
||||
ec2Instances[instanceIds[aws.StringValue(i.InstanceId)]] = i
|
||||
ec2Instances[instanceIDs[aws.StringValue(i.InstanceId)]] = i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ func TestChunkIDs(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
var IDs []*string
|
||||
for v := 0; v < test.count; v++ {
|
||||
for range test.count {
|
||||
IDs = append(IDs, aws.String("a"))
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/traefik/traefik/v2/pkg/log"
|
||||
|
@ -452,12 +453,8 @@ func (c *clientWrapper) isWatchedNamespace(ns string) bool {
|
|||
if c.isNamespaceAll {
|
||||
return true
|
||||
}
|
||||
for _, watchedNamespace := range c.watchedNamespaces {
|
||||
if watchedNamespace == ns {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
return slices.Contains(c.watchedNamespaces, ns)
|
||||
}
|
||||
|
||||
// translateNotFoundError will translate a "not found" error to a boolean return
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/traefik/traefik/v2/pkg/log"
|
||||
|
@ -548,10 +549,6 @@ func (c *clientWrapper) isWatchedNamespace(ns string) bool {
|
|||
if c.isNamespaceAll {
|
||||
return true
|
||||
}
|
||||
for _, watchedNamespace := range c.watchedNamespaces {
|
||||
if watchedNamespace == ns {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
return slices.Contains(c.watchedNamespaces, ns)
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-version"
|
||||
|
@ -538,12 +539,8 @@ func (c *clientWrapper) isWatchedNamespace(ns string) bool {
|
|||
if c.isNamespaceAll {
|
||||
return true
|
||||
}
|
||||
for _, watchedNamespace := range c.watchedNamespaces {
|
||||
if watchedNamespace == ns {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
return slices.Contains(c.watchedNamespaces, ns)
|
||||
}
|
||||
|
||||
// IngressClass objects are supported since Kubernetes v1.18.
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"math"
|
||||
"net"
|
||||
"os"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -412,13 +413,9 @@ func (p *Provider) updateIngressStatus(ing *netv1.Ingress, k8sClient Client) err
|
|||
func (p *Provider) shouldProcessIngress(ingress *netv1.Ingress, ingressClasses []*netv1.IngressClass) bool {
|
||||
// configuration through the new kubernetes ingressClass
|
||||
if ingress.Spec.IngressClassName != nil {
|
||||
for _, ic := range ingressClasses {
|
||||
if *ingress.Spec.IngressClassName == ic.ObjectMeta.Name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
return slices.ContainsFunc(ingressClasses, func(ic *netv1.IngressClass) bool {
|
||||
return *ingress.Spec.IngressClassName == ic.ObjectMeta.Name
|
||||
})
|
||||
}
|
||||
|
||||
return p.IngressClass == ingress.Annotations[annotationKubernetesIngressClass] ||
|
||||
|
|
|
@ -1146,7 +1146,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
err := p.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
for i := 0; i < len(test.containers); i++ {
|
||||
for i := range len(test.containers) {
|
||||
var err error
|
||||
test.containers[i].ExtraConf, err = p.getConfiguration(test.containers[i])
|
||||
require.NoError(t, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue