diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml
index e240960d82..bff0e6044f 100644
--- a/.github/workflows/validate.yaml
+++ b/.github/workflows/validate.yaml
@@ -6,7 +6,7 @@ on:
- '*'
env:
- GOLANGCI_LINT_VERSION: v2.13.2
+ GOLANGCI_LINT_VERSION: v2.14.0
MISSPELL_VERSION: v0.7.0
permissions:
diff --git a/.go-version b/.go-version
index 24cffb85f8..b0c101e630 100644
--- a/.go-version
+++ b/.go-version
@@ -1 +1 @@
-1.26
+1.27
diff --git a/cmd/configuration.go b/cmd/configuration.go
index 49a69507d7..04e375d637 100644
--- a/cmd/configuration.go
+++ b/cmd/configuration.go
@@ -18,21 +18,19 @@ type TraefikCmdConfiguration struct {
// NewTraefikConfiguration creates a TraefikCmdConfiguration with default values.
func NewTraefikConfiguration() *TraefikCmdConfiguration {
return &TraefikCmdConfiguration{
- Configuration: static.Configuration{
- Global: &static.Global{
- CheckNewVersion: true,
- },
- EntryPoints: make(static.EntryPoints),
- Providers: &static.Providers{
- ProvidersThrottleDuration: ptypes.Duration(2 * time.Second),
- },
- ServersTransport: &static.ServersTransport{
- MaxIdleConnsPerHost: 200,
- },
- TCPServersTransport: &static.TCPServersTransport{
- DialTimeout: ptypes.Duration(30 * time.Second),
- DialKeepAlive: ptypes.Duration(15 * time.Second),
- },
+ Global: &static.Global{
+ CheckNewVersion: true,
+ },
+ EntryPoints: make(static.EntryPoints),
+ Providers: &static.Providers{
+ ProvidersThrottleDuration: ptypes.Duration(2 * time.Second),
+ },
+ ServersTransport: &static.ServersTransport{
+ MaxIdleConnsPerHost: 200,
+ },
+ TCPServersTransport: &static.TCPServersTransport{
+ DialTimeout: ptypes.Duration(30 * time.Second),
+ DialKeepAlive: ptypes.Duration(15 * time.Second),
},
ConfigFile: "",
}
diff --git a/docs/content/migrate/v3.md b/docs/content/migrate/v3.md
index 5dfeea83c9..6d74a9338a 100644
--- a/docs/content/migrate/v3.md
+++ b/docs/content/migrate/v3.md
@@ -9,6 +9,37 @@ This guide provides detailed migration steps for upgrading between different Tra
---
+## v3.7.17
+
+Starting with `v3.7.17`, Traefik is built with Go 1.27.
+
+### GODEBUG TLS Settings
+
+Go 1.27 removed the `tlsrsakex`, `tls10server` and `tls3des` `GODEBUG` settings.
+Setting them in the `GODEBUG` environment variable has no effect anymore.
+
+For the incoming connections, the RSA key exchange and 3DES cipher suites, as well as TLS 1.0 and 1.1,
+can still be enabled with the `cipherSuites` and `minVersion` fields of the [TLS options](../reference/routing-configuration/http/tls/tls-options.md),
+referenced in the TLS configuration of a [router](../reference/routing-configuration/http/routing/router.md) or of an [entrypoint](../reference/install-configuration/entrypoints.md#opt-http-tls-options).
+
+For the connections to the backends, they can still be enabled with the `cipherSuites` and `minVersion` fields of the [ServersTransport](../reference/routing-configuration/http/load-balancing/serverstransport.md#opt-cipherSuites).
+
+Please check out the [go documentation](https://go.dev/doc/go1.27#cryptotlspkgcryptotls) for more details.
+
+### Maximum Number of Request Header Values
+
+Go 1.27 limits the number of header values a request can carry to 500.
+
+A request exceeding this limit is rejected with a `431 Request Header Fields Too Large` response,
+for HTTP/1 and HTTP/2.
+This limit can be changed with the new [`maxHeaderValueCount`](../reference/install-configuration/entrypoints.md#opt-http-maxHeaderValueCount) entry point option.
+
+As the rejection happens before the routing, the rejected requests are not reported in the access logs.
+
+Please check out the [go documentation](https://go.dev/doc/go1.27#nethttppkgnethttp) for more details.
+
+---
+
## v3.7.16
### Kubernetes CRD and Ingress-NGINX Providers: Secret references in middlewares
diff --git a/docs/content/reference/install-configuration/configuration-options.md b/docs/content/reference/install-configuration/configuration-options.md
index 0ab974acdc..6c555f7cb9 100644
--- a/docs/content/reference/install-configuration/configuration-options.md
+++ b/docs/content/reference/install-configuration/configuration-options.md
@@ -101,6 +101,7 @@ THIS FILE MUST NOT BE EDITED BY HAND
| entrypoints._name_.http.encodedcharacters.allowencodedslash | Defines whether requests with encoded slash characters in the path are allowed. | true |
| entrypoints._name_.http.encodequerysemicolons | Defines whether request query semicolons should be URLEncoded. | false |
| | Maximum size of request headers in bytes. | 1048576 |
+| | Maximum number of request header values. | 500 |
| entrypoints._name_.http.middlewares | Default middlewares for the routers linked to the entry point. | |
| entrypoints._name_.http.redirections.entrypoint.permanent | Applies a permanent redirection. | true |
| entrypoints._name_.http.redirections.entrypoint.priority | Priority of the generated router. | 9223372036854775806 |
diff --git a/docs/content/reference/install-configuration/entrypoints.md b/docs/content/reference/install-configuration/entrypoints.md
index 092d3a2fc5..65bed104bf 100644
--- a/docs/content/reference/install-configuration/entrypoints.md
+++ b/docs/content/reference/install-configuration/entrypoints.md
@@ -108,6 +108,7 @@ additionalArguments:
| | Defines the strategy to handle the requests carrying a header whose name aliases another header name (keep, delete, and reject).
More information [here](#aliasheadersstrategy). | keep | No |
| `http.sanitizePath` | Defines whether to enable the request path sanitization.
More information [here](#sanitizepath). | true | No |
| | Set the maximum size of request headers in bytes. | 1048576 | No |
+| | Set the maximum number of request header values Traefik reads for each request. A request exceeding this limit is rejected with a `431 Request Header Fields Too Large` status.
Comma-separated values in a single header line count as one value, while values sent on multiple header lines count once per line.
This option applies to HTTP/1 and HTTP/2 only; it has no effect on HTTP/3 requests. | 500 | No |
| `http.middlewares` | Set the list of middlewares that are prepended by default to the list of middlewares of each router associated to the named entry point.
More information [here](#httpmiddlewares). | - | No |
| `http.tls` | Enable TLS on every router attached to the `entryPoint`.
If no certificate are set, a default self-signed certificate is generated by Traefik.
We recommend to not use self signed certificates in production. | - | No |
| `http.tls.options` | Apply TLS options on every router attached to the `entryPoint`.
These options apply only while the router does not define its own `tls` section.
Defining a router `tls` section (even empty, or with any field such as `certResolver`) replaces the entrypoint TLS configuration for that router (no merge).
More information in the [dedicated section](../../reference/routing-configuration/http/tls/tls-options.md) and [HTTP TLS overview](../../reference/routing-configuration/http/tls/overview.md). | - | No |
diff --git a/docs/content/reference/static-configuration/file.toml b/docs/content/reference/static-configuration/file.toml
index 3c3b138c55..ba125c7c4c 100644
--- a/docs/content/reference/static-configuration/file.toml
+++ b/docs/content/reference/static-configuration/file.toml
@@ -58,6 +58,7 @@
encodeQuerySemicolons = true
sanitizePath = true
maxHeaderBytes = 42
+ maxHeaderValueCount = 42
aliasHeadersStrategy = "foobar"
underscoreHeadersStrategy = "foobar"
[entryPoints.EntryPoint0.http.redirections]
diff --git a/docs/content/reference/static-configuration/file.yaml b/docs/content/reference/static-configuration/file.yaml
index 454949a693..f0087f76ba 100644
--- a/docs/content/reference/static-configuration/file.yaml
+++ b/docs/content/reference/static-configuration/file.yaml
@@ -96,6 +96,7 @@ entryPoints:
encodeQuerySemicolons: true
sanitizePath: true
maxHeaderBytes: 42
+ maxHeaderValueCount: 42
aliasHeadersStrategy: foobar
underscoreHeadersStrategy: foobar
http2:
diff --git a/go.mod b/go.mod
index 3978113b42..783f93dcfe 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/traefik/traefik/v3
-go 1.26.0
+go 1.27.0
require (
github.com/BurntSushi/toml v1.6.0
diff --git a/integration/fixtures/simple_max_header_value_count.toml b/integration/fixtures/simple_max_header_value_count.toml
new file mode 100644
index 0000000000..c7444b71ed
--- /dev/null
+++ b/integration/fixtures/simple_max_header_value_count.toml
@@ -0,0 +1,25 @@
+[global]
+ checkNewVersion = false
+ sendAnonymousUsage = false
+
+[entryPoints]
+ [entryPoints.web]
+ address = ":8000"
+ [entryPoints.web.http]
+ maxHeaderValueCount = 10
+
+[providers.file]
+ filename = "{{ .SelfFilename }}"
+
+## dynamic configuration ##
+
+[http.routers]
+ [http.routers.test-router]
+ entryPoints = ["web"]
+ service = "test-service"
+ rule = "Host(`127.0.0.1`)"
+
+[http.services]
+ [http.services.test-service]
+ [[http.services.test-service.loadBalancer.servers]]
+ url = "{{ .TestServer }}"
diff --git a/integration/https_test.go b/integration/https_test.go
index 702de16c45..ac8d177538 100644
--- a/integration/https_test.go
+++ b/integration/https_test.go
@@ -1468,10 +1468,8 @@ func (s *HTTPSSuite) modifyCertificateConfFileContent(certFileName, confFileName
TLS: &dynamic.TLSConfiguration{
Certificates: []*traefiktls.CertAndStores{
{
- Certificate: traefiktls.Certificate{
- CertFile: types.FileOrContent("fixtures/https/" + certFileName + ".cert"),
- KeyFile: types.FileOrContent("fixtures/https/" + certFileName + ".key"),
- },
+ CertFile: types.FileOrContent("fixtures/https/" + certFileName + ".cert"),
+ KeyFile: types.FileOrContent("fixtures/https/" + certFileName + ".key"),
},
},
},
diff --git a/integration/simple_test.go b/integration/simple_test.go
index e175fd0bad..a6159ac148 100644
--- a/integration/simple_test.go
+++ b/integration/simple_test.go
@@ -14,6 +14,7 @@ import (
"net/http/httptest"
"os"
"regexp"
+ "strconv"
"strings"
"sync/atomic"
"syscall"
@@ -2438,6 +2439,50 @@ func (s *SimpleSuite) TestAllowACMEByPassRedirect() {
assert.Equal(s.T(), http.StatusMovedPermanently, resp.StatusCode)
}
+func (s *SimpleSuite) TestMaxHeaderValueCount() {
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.WriteHeader(http.StatusOK)
+ }))
+ defer ts.Close()
+
+ file := s.adaptFile("fixtures/simple_max_header_value_count.toml", struct {
+ TestServer string
+ }{ts.URL})
+
+ s.traefikCmd(withConfigFile(file))
+
+ testCases := []struct {
+ name string
+ headerCount int
+ expectedStatus int
+ }{
+ {
+ name: "5 headers",
+ headerCount: 5,
+ expectedStatus: http.StatusOK,
+ },
+ {
+ name: "20 headers",
+ headerCount: 20,
+ expectedStatus: http.StatusRequestHeaderFieldsTooLarge,
+ },
+ }
+
+ for _, test := range testCases {
+ s.Run(test.name, func() {
+ req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000", nil)
+ require.NoError(s.T(), err)
+
+ for i := range test.headerCount {
+ req.Header.Add("X-Header", strconv.Itoa(i))
+ }
+
+ err = try.Request(req, 2*time.Second, try.StatusCodeIs(test.expectedStatus))
+ require.NoError(s.T(), err)
+ })
+ }
+}
+
func (s *SimpleSuite) TestUnderscoreHeadersStrategy() {
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if _, ok := r.Header["X_auth_user"]; ok {
diff --git a/pkg/api/handler_certificate_test.go b/pkg/api/handler_certificate_test.go
index 2ba1d9aabc..ad41eda3c7 100644
--- a/pkg/api/handler_certificate_test.go
+++ b/pkg/api/handler_certificate_test.go
@@ -537,10 +537,8 @@ func TestHandler_Certificates(t *testing.T) {
if test.setup.loadCerts {
dynamicConfigs := []*tlspkg.CertAndStores{{
- Certificate: tlspkg.Certificate{
- CertFile: localhostCert,
- KeyFile: localhostKey,
- },
+ CertFile: localhostCert,
+ KeyFile: localhostKey,
}}
tlsManager.UpdateConfigs(t.Context(), nil, nil, dynamicConfigs)
@@ -549,28 +547,20 @@ func TestHandler_Certificates(t *testing.T) {
if test.setup.loadMultipleCerts {
dynamicConfigs := []*tlspkg.CertAndStores{
{
- Certificate: tlspkg.Certificate{
- CertFile: localhostCert,
- KeyFile: localhostKey,
- },
+ CertFile: localhostCert,
+ KeyFile: localhostKey,
},
{
- Certificate: tlspkg.Certificate{
- CertFile: warnCert,
- KeyFile: warnKey,
- },
+ CertFile: warnCert,
+ KeyFile: warnKey,
},
{
- Certificate: tlspkg.Certificate{
- CertFile: expiredCert,
- KeyFile: expiredKey,
- },
+ CertFile: expiredCert,
+ KeyFile: expiredKey,
},
{
- Certificate: tlspkg.Certificate{
- CertFile: acmeCert,
- KeyFile: acmeKey,
- },
+ CertFile: acmeCert,
+ KeyFile: acmeKey,
},
}
diff --git a/pkg/config/static/entrypoints.go b/pkg/config/static/entrypoints.go
index ca6487ae0f..cbaf2c9568 100644
--- a/pkg/config/static/entrypoints.go
+++ b/pkg/config/static/entrypoints.go
@@ -102,6 +102,7 @@ type HTTPConfig struct {
EncodeQuerySemicolons bool `description:"Defines whether request query semicolons should be URLEncoded." json:"encodeQuerySemicolons,omitempty" toml:"encodeQuerySemicolons,omitempty" yaml:"encodeQuerySemicolons,omitempty" export:"true"`
SanitizePath *bool `description:"Defines whether to enable request path sanitization (removal of /./, /../ and multiple slash sequences)." json:"sanitizePath,omitempty" toml:"sanitizePath,omitempty" yaml:"sanitizePath,omitempty" export:"true"`
MaxHeaderBytes int `description:"Maximum size of request headers in bytes." json:"maxHeaderBytes,omitempty" toml:"maxHeaderBytes,omitempty" yaml:"maxHeaderBytes,omitempty" export:"true"`
+ MaxHeaderValueCount int `description:"Maximum number of request header values." json:"maxHeaderValueCount,omitempty" toml:"maxHeaderValueCount,omitempty" yaml:"maxHeaderValueCount,omitempty" export:"true"`
AliasHeadersStrategy string `description:"Defines the strategy to handle the requests carrying a header whose name aliases another header name (keep, delete, and reject)." json:"aliasHeadersStrategy,omitempty" toml:"aliasHeadersStrategy,omitempty" yaml:"aliasHeadersStrategy,omitempty" export:"true"`
// UnderscoreHeadersStrategy is the strategy to handle request headers with underscores in their names.
@@ -114,6 +115,7 @@ type HTTPConfig struct {
func (h *HTTPConfig) SetDefaults() {
h.SanitizePath = new(true)
h.MaxHeaderBytes = http.DefaultMaxHeaderBytes
+ h.MaxHeaderValueCount = http.DefaultMaxHeaderValueCount
}
// EncodedCharacters configures which encoded characters are allowed in the request path.
diff --git a/pkg/config/static/static_config_test.go b/pkg/config/static/static_config_test.go
index 489d78eb1c..01f974b88e 100644
--- a/pkg/config/static/static_config_test.go
+++ b/pkg/config/static/static_config_test.go
@@ -222,8 +222,9 @@ func TestConfiguration_SetEffectiveConfiguration(t *testing.T) {
ProxyProtocol: nil,
ForwardedHeaders: &ForwardedHeaders{},
HTTP: HTTPConfig{
- SanitizePath: new(true),
- MaxHeaderBytes: 1048576,
+ SanitizePath: new(true),
+ MaxHeaderBytes: 1048576,
+ MaxHeaderValueCount: 500,
},
HTTP2: &HTTP2Config{
MaxConcurrentStreams: 250,
@@ -270,8 +271,9 @@ func TestConfiguration_SetEffectiveConfiguration(t *testing.T) {
ProxyProtocol: nil,
ForwardedHeaders: &ForwardedHeaders{},
HTTP: HTTPConfig{
- SanitizePath: new(true),
- MaxHeaderBytes: 1048576,
+ SanitizePath: new(true),
+ MaxHeaderBytes: 1048576,
+ MaxHeaderValueCount: 500,
},
HTTP2: &HTTP2Config{
MaxConcurrentStreams: 250,
@@ -329,8 +331,9 @@ func TestConfiguration_SetEffectiveConfiguration(t *testing.T) {
ProxyProtocol: nil,
ForwardedHeaders: &ForwardedHeaders{},
HTTP: HTTPConfig{
- SanitizePath: new(true),
- MaxHeaderBytes: 1048576,
+ SanitizePath: new(true),
+ MaxHeaderBytes: 1048576,
+ MaxHeaderValueCount: 500,
},
HTTP2: &HTTP2Config{
MaxConcurrentStreams: 250,
@@ -392,8 +395,9 @@ func TestConfiguration_SetEffectiveConfiguration(t *testing.T) {
ProxyProtocol: nil,
ForwardedHeaders: &ForwardedHeaders{},
HTTP: HTTPConfig{
- SanitizePath: new(true),
- MaxHeaderBytes: 1048576,
+ SanitizePath: new(true),
+ MaxHeaderBytes: 1048576,
+ MaxHeaderValueCount: 500,
},
HTTP2: &HTTP2Config{
MaxConcurrentStreams: 250,
@@ -503,8 +507,9 @@ func TestConfiguration_SetEffectiveConfiguration(t *testing.T) {
},
ForwardedHeaders: &ForwardedHeaders{},
HTTP: HTTPConfig{
- SanitizePath: new(true),
- MaxHeaderBytes: 1048576,
+ SanitizePath: new(true),
+ MaxHeaderBytes: 1048576,
+ MaxHeaderValueCount: 500,
},
HTTP2: &HTTP2Config{
MaxConcurrentStreams: 250,
diff --git a/pkg/middlewares/auth/forward_test.go b/pkg/middlewares/auth/forward_test.go
index 96a462a540..8e5f779967 100644
--- a/pkg/middlewares/auth/forward_test.go
+++ b/pkg/middlewares/auth/forward_test.go
@@ -598,12 +598,12 @@ func TestForwardAuthFailResponseHeaders(t *testing.T) {
func TestForwardAuthClientClosedRequest(t *testing.T) {
requestStarted := make(chan struct{})
- requestCancelled := make(chan struct{})
responseComplete := make(chan struct{})
authTs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
close(requestStarted)
- <-requestCancelled
+ // Wait for the client to give up on the request, so the auth server never answers before the cancellation is observed.
+ <-r.Context().Done()
}))
t.Cleanup(authTs.Close)
@@ -629,11 +629,7 @@ func TestForwardAuthClientClosedRequest(t *testing.T) {
<-requestStarted
- // Cancel request and wait for cancellation to propagate
cancel()
- <-ctx.Done()
-
- close(requestCancelled)
<-responseComplete
diff --git a/pkg/provider/acme/challenge_tls.go b/pkg/provider/acme/challenge_tls.go
index 911a1c5758..5b8dc603cd 100644
--- a/pkg/provider/acme/challenge_tls.go
+++ b/pkg/provider/acme/challenge_tls.go
@@ -153,11 +153,9 @@ func createMessage(certs map[string]*Certificate) dynamic.Message {
for _, cert := range certs {
certConf := &traefiktls.CertAndStores{
- Certificate: traefiktls.Certificate{
- CertFile: types.FileOrContent(cert.Certificate),
- KeyFile: types.FileOrContent(cert.Key),
- },
- Stores: []string{tlsalpn01.ACMETLS1Protocol},
+ CertFile: types.FileOrContent(cert.Certificate),
+ KeyFile: types.FileOrContent(cert.Key),
+ Stores: []string{tlsalpn01.ACMETLS1Protocol},
}
conf.Configuration.TLS.Certificates = append(conf.Configuration.TLS.Certificates, certConf)
}
diff --git a/pkg/provider/acme/provider.go b/pkg/provider/acme/provider.go
index 4887015298..acf7266ebf 100644
--- a/pkg/provider/acme/provider.go
+++ b/pkg/provider/acme/provider.go
@@ -890,11 +890,9 @@ func (p *Provider) buildMessage() dynamic.Message {
for _, cert := range p.certificates {
certConf := &traefiktls.CertAndStores{
- Certificate: traefiktls.Certificate{
- CertFile: types.FileOrContent(cert.Certificate.Certificate),
- KeyFile: types.FileOrContent(cert.Key),
- },
- Stores: []string{cert.Store},
+ CertFile: types.FileOrContent(cert.Certificate.Certificate),
+ KeyFile: types.FileOrContent(cert.Key),
+ Stores: []string{cert.Store},
}
conf.Configuration.TLS.Certificates = append(conf.Configuration.TLS.Certificates, certConf)
}
diff --git a/pkg/provider/acme/provider_test.go b/pkg/provider/acme/provider_test.go
index 057d0a6232..0df589fab6 100644
--- a/pkg/provider/acme/provider_test.go
+++ b/pkg/provider/acme/provider_test.go
@@ -49,9 +49,7 @@ func TestGetUncheckedCertificates(t *testing.T) {
domains: []string{"*.traefik.wtf"},
acmeCertificates: []*CertAndStore{
{
- Certificate: Certificate{
- Domain: types.Domain{Main: "*.traefik.wtf"},
- },
+ Domain: types.Domain{Main: "*.traefik.wtf"},
},
},
expectedDomains: nil,
@@ -72,9 +70,7 @@ func TestGetUncheckedCertificates(t *testing.T) {
domains: []string{"traefik.wtf", "foo.traefik.wtf"},
acmeCertificates: []*CertAndStore{
{
- Certificate: Certificate{
- Domain: types.Domain{Main: "traefik.wtf"},
- },
+ Domain: types.Domain{Main: "traefik.wtf"},
},
},
expectedDomains: []string{"foo.traefik.wtf"},
@@ -90,9 +86,7 @@ func TestGetUncheckedCertificates(t *testing.T) {
domains: []string{"traefik.wtf"},
acmeCertificates: []*CertAndStore{
{
- Certificate: Certificate{
- Domain: types.Domain{Main: "traefik.wtf"},
- },
+ Domain: types.Domain{Main: "traefik.wtf"},
},
},
expectedDomains: nil,
@@ -108,9 +102,7 @@ func TestGetUncheckedCertificates(t *testing.T) {
domains: []string{"who.traefik.wtf", "foo.traefik.wtf"},
acmeCertificates: []*CertAndStore{
{
- Certificate: Certificate{
- Domain: types.Domain{Main: "*.traefik.wtf"},
- },
+ Domain: types.Domain{Main: "*.traefik.wtf"},
},
},
expectedDomains: nil,
@@ -120,9 +112,7 @@ func TestGetUncheckedCertificates(t *testing.T) {
domains: []string{"traefik.wtf", "foo.traefik.wtf"},
acmeCertificates: []*CertAndStore{
{
- Certificate: Certificate{
- Domain: types.Domain{Main: "*.traefik.wtf"},
- },
+ Domain: types.Domain{Main: "*.traefik.wtf"},
},
},
expectedDomains: []string{"traefik.wtf"},
diff --git a/pkg/provider/docker/config_test.go b/pkg/provider/docker/config_test.go
index dcb360d49a..9a9c21a058 100644
--- a/pkg/provider/docker/config_test.go
+++ b/pkg/provider/docker/config_test.go
@@ -406,10 +406,8 @@ func TestDynConfBuilder_DefaultRule(t *testing.T) {
t.Parallel()
p := Provider{
- Shared: Shared{
- ExposedByDefault: true,
- DefaultRule: test.defaultRule,
- },
+ ExposedByDefault: true,
+ DefaultRule: test.defaultRule,
}
require.NoError(t, p.Init())
@@ -3910,14 +3908,12 @@ func TestDynConfBuilder_build(t *testing.T) {
t.Parallel()
p := Provider{
- Shared: Shared{
- AllowEmptyServices: test.allowEmptyServices,
- ExposedByDefault: true,
- UseBindPortIP: test.useBindPortIP,
- DefaultRule: "Host(`{{ normalize .Name }}.traefik.wtf`)",
- },
+ AllowEmptyServices: test.allowEmptyServices,
+ ExposedByDefault: true,
+ UseBindPortIP: test.useBindPortIP,
+ DefaultRule: "Host(`{{ normalize .Name }}.traefik.wtf`)",
+ Constraints: test.constraints,
}
- p.Constraints = test.constraints
require.NoError(t, p.Init())
diff --git a/pkg/provider/docker/pswarm_test.go b/pkg/provider/docker/pswarm_test.go
index 0847303590..f82c18d47f 100644
--- a/pkg/provider/docker/pswarm_test.go
+++ b/pkg/provider/docker/pswarm_test.go
@@ -152,23 +152,21 @@ func TestSwarmProvider_listServices(t *testing.T) {
dockerVersion: "1.30",
networks: []networktypes.Summary{
{
- Network: networktypes.Network{
- Name: "network_name",
- ID: "yk6l57rfwizjzxxzftn4amaot",
- Created: time.Now(),
- Scope: "swarm",
- Driver: "overlay",
- EnableIPv6: false,
- Internal: true,
- Ingress: false,
- ConfigOnly: false,
- Options: map[string]string{
- "com.docker.networktypes.driver.overlay.vxlanid_list": "4098",
- "com.docker.networktypes.enable_ipv6": "false",
- },
- Labels: map[string]string{
- "com.docker.stack.namespace": "test",
- },
+ Name: "network_name",
+ ID: "yk6l57rfwizjzxxzftn4amaot",
+ Created: time.Now(),
+ Scope: "swarm",
+ Driver: "overlay",
+ EnableIPv6: false,
+ Internal: true,
+ Ingress: false,
+ ConfigOnly: false,
+ Options: map[string]string{
+ "com.docker.networktypes.driver.overlay.vxlanid_list": "4098",
+ "com.docker.networktypes.enable_ipv6": "false",
+ },
+ Labels: map[string]string{
+ "com.docker.stack.namespace": "test",
},
},
},
@@ -209,23 +207,21 @@ func TestSwarmProvider_listServices(t *testing.T) {
dockerVersion: "1.30",
networks: []networktypes.Summary{
{
- Network: networktypes.Network{
- Name: "network_name",
- ID: "yk6l57rfwizjzxxzftn4amaot",
- Created: time.Now(),
- Scope: "swarm",
- Driver: "overlay",
- EnableIPv6: false,
- Internal: true,
- Ingress: false,
- ConfigOnly: false,
- Options: map[string]string{
- "com.docker.networktypes.driver.overlay.vxlanid_list": "4098",
- "com.docker.networktypes.enable_ipv6": "false",
- },
- Labels: map[string]string{
- "com.docker.stack.namespace": "test",
- },
+ Name: "network_name",
+ ID: "yk6l57rfwizjzxxzftn4amaot",
+ Created: time.Now(),
+ Scope: "swarm",
+ Driver: "overlay",
+ EnableIPv6: false,
+ Internal: true,
+ Ingress: false,
+ ConfigOnly: false,
+ Options: map[string]string{
+ "com.docker.networktypes.driver.overlay.vxlanid_list": "4098",
+ "com.docker.networktypes.enable_ipv6": "false",
+ },
+ Labels: map[string]string{
+ "com.docker.stack.namespace": "test",
},
},
},
diff --git a/pkg/provider/kubernetes/crd/client_test.go b/pkg/provider/kubernetes/crd/client_test.go
index 5d1c9aba7f..6255cf8f5e 100644
--- a/pkg/provider/kubernetes/crd/client_test.go
+++ b/pkg/provider/kubernetes/crd/client_test.go
@@ -8,24 +8,19 @@ import (
"github.com/stretchr/testify/require"
traefikcrdfake "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/generated/clientset/versioned/fake"
corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubefake "k8s.io/client-go/kubernetes/fake"
)
func TestClientIgnoresHelmOwnedSecrets(t *testing.T) {
secret := &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "default",
- Name: "secret",
- },
+ Namespace: "default",
+ Name: "secret",
}
helmSecret := &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "default",
- Name: "helm-secret",
- Labels: map[string]string{
- "owner": "helm",
- },
+ Namespace: "default",
+ Name: "helm-secret",
+ Labels: map[string]string{
+ "owner": "helm",
},
}
diff --git a/pkg/provider/kubernetes/crd/kubernetes.go b/pkg/provider/kubernetes/crd/kubernetes.go
index f146d6fbe4..d19ee289d6 100644
--- a/pkg/provider/kubernetes/crd/kubernetes.go
+++ b/pkg/provider/kubernetes/crd/kubernetes.go
@@ -1580,10 +1580,8 @@ func getTLS(k8sClient Client, secretName, namespace string) (*tls.CertAndStores,
}
return &tls.CertAndStores{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(cert),
- KeyFile: types.FileOrContent(key),
- },
+ CertFile: types.FileOrContent(cert),
+ KeyFile: types.FileOrContent(key),
}, nil
}
diff --git a/pkg/provider/kubernetes/crd/kubernetes_test.go b/pkg/provider/kubernetes/crd/kubernetes_test.go
index 21281637f7..654c56dcc5 100644
--- a/pkg/provider/kubernetes/crd/kubernetes_test.go
+++ b/pkg/provider/kubernetes/crd/kubernetes_test.go
@@ -788,10 +788,8 @@ func TestLoadIngressRouteTCPs(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
- KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
- },
+ CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
+ KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
},
},
},
@@ -5831,10 +5829,8 @@ func TestLoadIngressRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
- KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
- },
+ CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
+ KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
},
},
},
@@ -8023,11 +8019,9 @@ func TestLoadIngressRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
- KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
- },
- Stores: []string{"default"},
+ CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
+ KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
+ Stores: []string{"default"},
},
},
Stores: map[string]tls.Store{
diff --git a/pkg/provider/kubernetes/gateway/client.go b/pkg/provider/kubernetes/gateway/client.go
index 135fa93789..ad484fb2c8 100644
--- a/pkg/provider/kubernetes/gateway/client.go
+++ b/pkg/provider/kubernetes/gateway/client.go
@@ -524,9 +524,7 @@ func (c *clientWrapper) UpdateHTTPRouteStatus(ctx context.Context, route ktypes.
currentRoute = currentRoute.DeepCopy()
currentRoute.Status = gatev1.HTTPRouteStatus{
- RouteStatus: gatev1.RouteStatus{
- Parents: parentStatuses,
- },
+ Parents: parentStatuses,
}
if _, err = c.csGateway.GatewayV1().HTTPRoutes(route.Namespace).UpdateStatus(ctx, currentRoute, metav1.UpdateOptions{}); err != nil {
@@ -566,9 +564,7 @@ func (c *clientWrapper) UpdateGRPCRouteStatus(ctx context.Context, route ktypes.
currentRoute = currentRoute.DeepCopy()
currentRoute.Status = gatev1.GRPCRouteStatus{
- RouteStatus: gatev1.RouteStatus{
- Parents: parentStatuses,
- },
+ Parents: parentStatuses,
}
if _, err = c.csGateway.GatewayV1().GRPCRoutes(route.Namespace).UpdateStatus(ctx, currentRoute, metav1.UpdateOptions{}); err != nil {
@@ -608,9 +604,7 @@ func (c *clientWrapper) UpdateTCPRouteStatus(ctx context.Context, route ktypes.N
currentRoute = currentRoute.DeepCopy()
currentRoute.Status = gatev1alpha2.TCPRouteStatus{
- RouteStatus: gatev1.RouteStatus{
- Parents: parentStatuses,
- },
+ Parents: parentStatuses,
}
if _, err = c.csGateway.GatewayV1alpha2().TCPRoutes(route.Namespace).UpdateStatus(ctx, currentRoute, metav1.UpdateOptions{}); err != nil {
@@ -650,9 +644,7 @@ func (c *clientWrapper) UpdateTLSRouteStatus(ctx context.Context, route ktypes.N
currentRoute = currentRoute.DeepCopy()
currentRoute.Status = gatev1.TLSRouteStatus{
- RouteStatus: gatev1.RouteStatus{
- Parents: parentStatuses,
- },
+ Parents: parentStatuses,
}
if _, err = c.csGateway.GatewayV1().TLSRoutes(route.Namespace).UpdateStatus(ctx, currentRoute, metav1.UpdateOptions{}); err != nil {
diff --git a/pkg/provider/kubernetes/gateway/grpcroute.go b/pkg/provider/kubernetes/gateway/grpcroute.go
index 26de2c98ab..23863af44a 100644
--- a/pkg/provider/kubernetes/gateway/grpcroute.go
+++ b/pkg/provider/kubernetes/gateway/grpcroute.go
@@ -116,9 +116,7 @@ func (p *Provider) loadGRPCRoute(ctx context.Context, gateways []gatewayWithList
}
status := gatev1.GRPCRouteStatus{
- RouteStatus: gatev1.RouteStatus{
- Parents: parentStatuses,
- },
+ Parents: parentStatuses,
}
if err := p.client.UpdateGRPCRouteStatus(ctx, ktypes.NamespacedName{Namespace: route.Namespace, Name: route.Name}, gateways, status); err != nil {
logger.Warn().
diff --git a/pkg/provider/kubernetes/gateway/httproute.go b/pkg/provider/kubernetes/gateway/httproute.go
index 11f3230690..1c292eb000 100644
--- a/pkg/provider/kubernetes/gateway/httproute.go
+++ b/pkg/provider/kubernetes/gateway/httproute.go
@@ -120,9 +120,7 @@ func (p *Provider) loadHTTPRoute(ctx context.Context, gateways []gatewayWithList
}
status := gatev1.HTTPRouteStatus{
- RouteStatus: gatev1.RouteStatus{
- Parents: parentStatuses,
- },
+ Parents: parentStatuses,
}
if err := p.client.UpdateHTTPRouteStatus(ctx, ktypes.NamespacedName{Namespace: route.Namespace, Name: route.Name}, gateways, status); err != nil {
logger.Warn().
diff --git a/pkg/provider/kubernetes/gateway/kubernetes.go b/pkg/provider/kubernetes/gateway/kubernetes.go
index ab685e21b3..3424111f80 100644
--- a/pkg/provider/kubernetes/gateway/kubernetes.go
+++ b/pkg/provider/kubernetes/gateway/kubernetes.go
@@ -965,10 +965,8 @@ func (p *Provider) getTLSCert(secretName gatev1.ObjectName, namespace string) (*
}
certAndStore := &tls.CertAndStores{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(cert),
- KeyFile: types.FileOrContent(key),
- },
+ CertFile: types.FileOrContent(cert),
+ KeyFile: types.FileOrContent(key),
}
if _, err := certAndStore.GetCertificate(); err != nil {
return nil, fmt.Errorf("validating certificate: %w", err)
diff --git a/pkg/provider/kubernetes/gateway/kubernetes_test.go b/pkg/provider/kubernetes/gateway/kubernetes_test.go
index d1aad70110..ba870be779 100644
--- a/pkg/provider/kubernetes/gateway/kubernetes_test.go
+++ b/pkg/provider/kubernetes/gateway/kubernetes_test.go
@@ -620,10 +620,8 @@ func TestLoadHTTPRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -878,10 +876,8 @@ func TestLoadHTTPRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -950,16 +946,12 @@ func TestLoadHTTPRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -1458,10 +1450,8 @@ func TestLoadHTTPRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -1569,10 +1559,8 @@ func TestLoadHTTPRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -5611,10 +5599,8 @@ func TestLoadTLSRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -5915,10 +5901,8 @@ func TestLoadTLSRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -7252,10 +7236,8 @@ func TestLoadMixedRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -7462,10 +7444,8 @@ func TestLoadMixedRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -7644,10 +7624,8 @@ func TestLoadMixedRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -7826,10 +7804,8 @@ func TestLoadMixedRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -7966,10 +7942,8 @@ func TestLoadMixedRoutes(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -8392,10 +8366,8 @@ func TestLoadRoutesWithReferenceGrants(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(listenerCert),
- KeyFile: types.FileOrContent(listenerKey),
- },
+ CertFile: types.FileOrContent(listenerCert),
+ KeyFile: types.FileOrContent(listenerKey),
},
},
},
@@ -9236,10 +9208,8 @@ func Test_managesGateway(t *testing.T) {
{
desc: "no scoping manages everything",
gw: &gatev1.Gateway{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "default",
- Name: "foo",
- },
+ Namespace: "default",
+ Name: "foo",
},
want: true,
},
@@ -9247,10 +9217,8 @@ func Test_managesGateway(t *testing.T) {
desc: "matching ref",
gateways: []NamespacedName{{Namespace: "default", Name: "foo"}},
gw: &gatev1.Gateway{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "default",
- Name: "foo",
- },
+ Namespace: "default",
+ Name: "foo",
},
want: true,
},
@@ -9258,10 +9226,8 @@ func Test_managesGateway(t *testing.T) {
desc: "different name",
gateways: []NamespacedName{{Namespace: "default", Name: "foo"}},
gw: &gatev1.Gateway{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "default",
- Name: "bar",
- },
+ Namespace: "default",
+ Name: "bar",
},
want: false,
},
@@ -9269,10 +9235,8 @@ func Test_managesGateway(t *testing.T) {
desc: "different namespace",
gateways: []NamespacedName{{Namespace: "default", Name: "foo"}},
gw: &gatev1.Gateway{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "other",
- Name: "foo",
- },
+ Namespace: "other",
+ Name: "foo",
},
want: false,
},
@@ -9283,10 +9247,8 @@ func Test_managesGateway(t *testing.T) {
{Namespace: "other", Name: "bar"},
},
gw: &gatev1.Gateway{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "default",
- Name: "foo",
- },
+ Namespace: "default",
+ Name: "foo",
},
want: true,
},
@@ -9297,10 +9259,8 @@ func Test_managesGateway(t *testing.T) {
{Namespace: "other", Name: "bar"},
},
gw: &gatev1.Gateway{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "default",
- Name: "baz",
- },
+ Namespace: "default",
+ Name: "baz",
},
want: false,
},
diff --git a/pkg/provider/kubernetes/gateway/tcproute.go b/pkg/provider/kubernetes/gateway/tcproute.go
index 192d9e54be..fa80349224 100644
--- a/pkg/provider/kubernetes/gateway/tcproute.go
+++ b/pkg/provider/kubernetes/gateway/tcproute.go
@@ -108,9 +108,7 @@ func (p *Provider) loadTCPRoutes(ctx context.Context, gateways []gatewayWithList
}
routeStatus := gatev1alpha2.TCPRouteStatus{
- RouteStatus: gatev1alpha2.RouteStatus{
- Parents: parentStatuses,
- },
+ Parents: parentStatuses,
}
if err := p.client.UpdateTCPRouteStatus(ctx, ktypes.NamespacedName{Namespace: route.Namespace, Name: route.Name}, gateways, routeStatus); err != nil {
logger.Warn().
diff --git a/pkg/provider/kubernetes/gateway/tlsroute.go b/pkg/provider/kubernetes/gateway/tlsroute.go
index d1e119b794..51d409053f 100644
--- a/pkg/provider/kubernetes/gateway/tlsroute.go
+++ b/pkg/provider/kubernetes/gateway/tlsroute.go
@@ -129,9 +129,7 @@ func (p *Provider) loadTLSRoutes(ctx context.Context, gateways []gatewayWithList
}
routeStatus := gatev1.TLSRouteStatus{
- RouteStatus: gatev1.RouteStatus{
- Parents: parentStatuses,
- },
+ Parents: parentStatuses,
}
if err := p.client.UpdateTLSRouteStatus(ctx, ktypes.NamespacedName{Namespace: route.Namespace, Name: route.Name}, gateways, routeStatus); err != nil {
logger.Warn().
diff --git a/pkg/provider/kubernetes/ingress-nginx/build_test.go b/pkg/provider/kubernetes/ingress-nginx/build_test.go
index 302cbaa96d..d8ad2d6a0e 100644
--- a/pkg/provider/kubernetes/ingress-nginx/build_test.go
+++ b/pkg/provider/kubernetes/ingress-nginx/build_test.go
@@ -7,7 +7,6 @@ import (
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
corev1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubefake "k8s.io/client-go/kubernetes/fake"
)
@@ -57,8 +56,8 @@ func TestProvider_resolveBasicAuth_authMap(t *testing.T) {
t.Parallel()
kubeClient := kubefake.NewClientset(&corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{Name: "basic-auth", Namespace: "default"},
- Data: map[string][]byte{"user2": []byte("hash2"), "user1": []byte("hash1")},
+ Name: "basic-auth", Namespace: "default",
+ Data: map[string][]byte{"user2": []byte("hash2"), "user1": []byte("hash1")},
})
client := newClient(kubeClient)
diff --git a/pkg/provider/kubernetes/ingress-nginx/client_test.go b/pkg/provider/kubernetes/ingress-nginx/client_test.go
index e6ed09596f..5684899e2a 100644
--- a/pkg/provider/kubernetes/ingress-nginx/client_test.go
+++ b/pkg/provider/kubernetes/ingress-nginx/client_test.go
@@ -94,18 +94,14 @@ func TestIsLoadBalancerIngressEquals(t *testing.T) {
func TestClientIgnoresHelmOwnedSecrets(t *testing.T) {
secret := &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "default",
- Name: "secret",
- },
+ Namespace: "default",
+ Name: "secret",
}
helmSecret := &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "default",
- Name: "helm-secret",
- Labels: map[string]string{
- "owner": "helm",
- },
+ Namespace: "default",
+ Name: "helm-secret",
+ Labels: map[string]string{
+ "owner": "helm",
},
}
@@ -146,13 +142,11 @@ func TestClientIgnoresHelmOwnedSecrets(t *testing.T) {
func TestClientIgnoresEmptyEndpointSliceUpdates(t *testing.T) {
emptyEndpointSlice := &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- Name: "empty-endpointslice",
- Namespace: "test",
- ResourceVersion: "1244",
- Annotations: map[string]string{
- "test-annotation": "_",
- },
+ Name: "empty-endpointslice",
+ Namespace: "test",
+ ResourceVersion: "1244",
+ Annotations: map[string]string{
+ "test-annotation": "_",
},
}
@@ -161,12 +155,10 @@ func TestClientIgnoresEmptyEndpointSliceUpdates(t *testing.T) {
samplePortProtocol := corev1.ProtocolTCP
sampleAddressReady := true
filledEndpointSlice := &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- Name: "filled-endpointslice",
- Namespace: "test",
- ResourceVersion: "1234",
- },
- AddressType: discoveryv1.AddressTypeIPv4,
+ Name: "filled-endpointslice",
+ Namespace: "test",
+ ResourceVersion: "1234",
+ AddressType: discoveryv1.AddressTypeIPv4,
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.13.37.1"},
Conditions: discoveryv1.EndpointConditions{
diff --git a/pkg/provider/kubernetes/ingress-nginx/kubernetes_test.go b/pkg/provider/kubernetes/ingress-nginx/kubernetes_test.go
index 28c14cdcfe..62bf24825f 100644
--- a/pkg/provider/kubernetes/ingress-nginx/kubernetes_test.go
+++ b/pkg/provider/kubernetes/ingress-nginx/kubernetes_test.go
@@ -1313,10 +1313,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
},
@@ -2883,10 +2881,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
},
@@ -3452,10 +3448,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
},
@@ -3737,10 +3731,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
},
@@ -9920,10 +9912,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
},
@@ -12948,10 +12938,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
Options: map[string]tls.Options{
@@ -13722,10 +13710,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
Options: map[string]tls.Options{
@@ -13972,10 +13958,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
Options: map[string]tls.Options{
@@ -14295,10 +14279,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
Options: map[string]tls.Options{
@@ -17299,10 +17281,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
Options: map[string]tls.Options{
@@ -17465,10 +17445,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
Options: map[string]tls.Options{
@@ -21409,10 +21387,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
},
@@ -22455,10 +22431,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
},
@@ -22989,16 +22963,12 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
},
@@ -23120,10 +23090,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
},
@@ -23266,10 +23234,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
Options: map[string]tls.Options{
@@ -23630,10 +23596,8 @@ func TestLoadIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: "-----BEGIN CERTIFICATE-----",
- KeyFile: "-----BEGIN CERTIFICATE-----",
- },
+ CertFile: "-----BEGIN CERTIFICATE-----",
+ KeyFile: "-----BEGIN CERTIFICATE-----",
},
},
},
diff --git a/pkg/provider/kubernetes/ingress-nginx/translator.go b/pkg/provider/kubernetes/ingress-nginx/translator.go
index 83aac3c27d..1655aca506 100644
--- a/pkg/provider/kubernetes/ingress-nginx/translator.go
+++ b/pkg/provider/kubernetes/ingress-nginx/translator.go
@@ -42,10 +42,8 @@ func (p *Provider) translate(ctx context.Context, mc *model) *dynamic.Configurat
for _, k := range slices.Sorted(maps.Keys(mc.Certs)) {
cp := mc.Certs[k]
conf.TLS.Certificates = append(conf.TLS.Certificates, &tls.CertAndStores{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(cp.Cert),
- KeyFile: types.FileOrContent(cp.Key),
- },
+ CertFile: types.FileOrContent(cp.Cert),
+ KeyFile: types.FileOrContent(cp.Key),
})
}
diff --git a/pkg/provider/kubernetes/ingress/client_test.go b/pkg/provider/kubernetes/ingress/client_test.go
index 38b7e475b5..cef5483b05 100644
--- a/pkg/provider/kubernetes/ingress/client_test.go
+++ b/pkg/provider/kubernetes/ingress/client_test.go
@@ -134,18 +134,14 @@ func TestIsLoadBalancerIngressEquals(t *testing.T) {
func TestClientIgnoresHelmOwnedSecrets(t *testing.T) {
secret := &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "default",
- Name: "secret",
- },
+ Namespace: "default",
+ Name: "secret",
}
helmSecret := &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Namespace: "default",
- Name: "helm-secret",
- Labels: map[string]string{
- "owner": "helm",
- },
+ Namespace: "default",
+ Name: "helm-secret",
+ Labels: map[string]string{
+ "owner": "helm",
},
}
@@ -190,13 +186,11 @@ func TestClientIgnoresHelmOwnedSecrets(t *testing.T) {
func TestClientIgnoresEmptyEndpointSliceUpdates(t *testing.T) {
emptyEndpointSlice := &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- Name: "empty-endpointslice",
- Namespace: "test",
- ResourceVersion: "1244",
- Annotations: map[string]string{
- "test-annotation": "_",
- },
+ Name: "empty-endpointslice",
+ Namespace: "test",
+ ResourceVersion: "1244",
+ Annotations: map[string]string{
+ "test-annotation": "_",
},
}
@@ -205,12 +199,10 @@ func TestClientIgnoresEmptyEndpointSliceUpdates(t *testing.T) {
samplePortProtocol := corev1.ProtocolTCP
sampleAddressReady := true
filledEndpointSlice := &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- Name: "filled-endpointslice",
- Namespace: "test",
- ResourceVersion: "1234",
- },
- AddressType: discoveryv1.AddressTypeIPv4,
+ Name: "filled-endpointslice",
+ Namespace: "test",
+ ResourceVersion: "1234",
+ AddressType: discoveryv1.AddressTypeIPv4,
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.13.37.1"},
Conditions: discoveryv1.EndpointConditions{
diff --git a/pkg/provider/kubernetes/ingress/kubernetes.go b/pkg/provider/kubernetes/ingress/kubernetes.go
index 09e2572ba8..677b2415ab 100644
--- a/pkg/provider/kubernetes/ingress/kubernetes.go
+++ b/pkg/provider/kubernetes/ingress/kubernetes.go
@@ -839,10 +839,8 @@ func getCertificates(ctx context.Context, ingress *netv1.Ingress, k8sClient Clie
}
tlsConfigs[configKey] = &tls.CertAndStores{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent(cert),
- KeyFile: types.FileOrContent(key),
- },
+ CertFile: types.FileOrContent(cert),
+ KeyFile: types.FileOrContent(key),
}
}
}
diff --git a/pkg/provider/kubernetes/ingress/kubernetes_test.go b/pkg/provider/kubernetes/ingress/kubernetes_test.go
index 9ef668b99b..8855ebd6ce 100644
--- a/pkg/provider/kubernetes/ingress/kubernetes_test.go
+++ b/pkg/provider/kubernetes/ingress/kubernetes_test.go
@@ -1389,10 +1389,8 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
- KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
- },
+ CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
+ KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
},
},
},
@@ -3221,10 +3219,8 @@ func TestGetCertificates(t *testing.T) {
client: clientMock{
secrets: []*corev1.Secret{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "test-secret",
- Namespace: "testing",
- },
+ Name: "test-secret",
+ Namespace: "testing",
Data: map[string][]byte{
"tls.key": []byte("tls-key"),
},
@@ -3239,10 +3235,8 @@ func TestGetCertificates(t *testing.T) {
client: clientMock{
secrets: []*corev1.Secret{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "test-secret",
- Namespace: "testing",
- },
+ Name: "test-secret",
+ Namespace: "testing",
Data: map[string][]byte{
"tls.crt": []byte("tls-crt"),
},
@@ -3257,11 +3251,9 @@ func TestGetCertificates(t *testing.T) {
client: clientMock{
secrets: []*corev1.Secret{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "test-secret",
- Namespace: "testing",
- },
- Data: map[string][]byte{},
+ Name: "test-secret",
+ Namespace: "testing",
+ Data: map[string][]byte{},
},
},
},
@@ -3284,20 +3276,16 @@ func TestGetCertificates(t *testing.T) {
client: clientMock{
secrets: []*corev1.Secret{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "test-secret2",
- Namespace: "testing",
- },
+ Name: "test-secret2",
+ Namespace: "testing",
Data: map[string][]byte{
"tls.crt": []byte("tls-crt"),
"tls.key": []byte("tls-key"),
},
},
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "test-secret",
- Namespace: "testing",
- },
+ Name: "test-secret",
+ Namespace: "testing",
Data: map[string][]byte{
"tls.crt": []byte("tls-crt"),
"tls.key": []byte("tls-key"),
diff --git a/pkg/provider/kubernetes/k8s/endpointslice_indexer_test.go b/pkg/provider/kubernetes/k8s/endpointslice_indexer_test.go
index 5c75205cf5..0eb2f77220 100644
--- a/pkg/provider/kubernetes/k8s/endpointslice_indexer_test.go
+++ b/pkg/provider/kubernetes/k8s/endpointslice_indexer_test.go
@@ -25,34 +25,26 @@ func Test_EndpointSlicesByServiceName(t *testing.T) {
svcName: "app",
endpointSlices: []*discoveryv1.EndpointSlice{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-a",
- Namespace: "default",
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-a",
+ Namespace: "default",
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-b",
- Namespace: "default",
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-b",
+ Namespace: "default",
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
},
expected: []*discoveryv1.EndpointSlice{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-a",
- Namespace: "default",
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-a",
+ Namespace: "default",
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-b",
- Namespace: "default",
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-b",
+ Namespace: "default",
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
},
},
@@ -62,11 +54,9 @@ func Test_EndpointSlicesByServiceName(t *testing.T) {
svcName: "unknown",
endpointSlices: []*discoveryv1.EndpointSlice{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-a",
- Namespace: "default",
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-a",
+ Namespace: "default",
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
},
expected: []*discoveryv1.EndpointSlice{},
@@ -77,11 +67,9 @@ func Test_EndpointSlicesByServiceName(t *testing.T) {
svcName: "app",
endpointSlices: []*discoveryv1.EndpointSlice{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-a",
- Namespace: "other",
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-a",
+ Namespace: "other",
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
},
expected: []*discoveryv1.EndpointSlice{},
@@ -92,11 +80,9 @@ func Test_EndpointSlicesByServiceName(t *testing.T) {
svcName: "app",
endpointSlices: []*discoveryv1.EndpointSlice{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-a",
- Namespace: "default",
- Labels: map[string]string{discoveryv1.LabelServiceName: "other"},
- },
+ Name: "slice-a",
+ Namespace: "default",
+ Labels: map[string]string{discoveryv1.LabelServiceName: "other"},
},
},
expected: []*discoveryv1.EndpointSlice{},
@@ -107,34 +93,26 @@ func Test_EndpointSlicesByServiceName(t *testing.T) {
svcName: "app",
endpointSlices: []*discoveryv1.EndpointSlice{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-b",
- Namespace: "default",
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-b",
+ Namespace: "default",
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-a",
- Namespace: "default",
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-a",
+ Namespace: "default",
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
},
expected: []*discoveryv1.EndpointSlice{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-a",
- Namespace: "default",
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-a",
+ Namespace: "default",
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-b",
- Namespace: "default",
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-b",
+ Namespace: "default",
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
},
},
@@ -144,38 +122,30 @@ func Test_EndpointSlicesByServiceName(t *testing.T) {
svcName: "app",
endpointSlices: []*discoveryv1.EndpointSlice{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-a",
- Namespace: "default",
- CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 2, 0, 0, 0, 0, time.UTC)),
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-a",
+ Namespace: "default",
+ CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 2, 0, 0, 0, 0, time.UTC)),
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-b",
- Namespace: "default",
- CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)),
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-b",
+ Namespace: "default",
+ CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)),
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
},
expected: []*discoveryv1.EndpointSlice{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-b",
- Namespace: "default",
- CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)),
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-b",
+ Namespace: "default",
+ CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)),
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-a",
- Namespace: "default",
- CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 2, 0, 0, 0, 0, time.UTC)),
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-a",
+ Namespace: "default",
+ CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 2, 0, 0, 0, 0, time.UTC)),
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
},
},
@@ -185,38 +155,30 @@ func Test_EndpointSlicesByServiceName(t *testing.T) {
svcName: "app",
endpointSlices: []*discoveryv1.EndpointSlice{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-a",
- Namespace: "default",
- CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 2, 0, 0, 0, 0, time.UTC)),
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-a",
+ Namespace: "default",
+ CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 2, 0, 0, 0, 0, time.UTC)),
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-z",
- Namespace: "default",
- CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)),
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-z",
+ Namespace: "default",
+ CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)),
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
},
expected: []*discoveryv1.EndpointSlice{
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-z",
- Namespace: "default",
- CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)),
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-z",
+ Namespace: "default",
+ CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)),
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
{
- ObjectMeta: metav1.ObjectMeta{
- Name: "slice-a",
- Namespace: "default",
- CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 2, 0, 0, 0, 0, time.UTC)),
- Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
- },
+ Name: "slice-a",
+ Namespace: "default",
+ CreationTimestamp: metav1.NewTime(time.Date(2025, 1, 2, 0, 0, 0, 0, time.UTC)),
+ Labels: map[string]string{discoveryv1.LabelServiceName: "app"},
},
},
},
diff --git a/pkg/provider/kubernetes/k8s/event_handler_test.go b/pkg/provider/kubernetes/k8s/event_handler_test.go
index 656ad765c9..a2178ed19a 100644
--- a/pkg/provider/kubernetes/k8s/event_handler_test.go
+++ b/pkg/provider/kubernetes/k8s/event_handler_test.go
@@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/assert"
discoveryv1 "k8s.io/api/discovery/v1"
netv1 "k8s.io/api/networking/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func Test_detectChanges(t *testing.T) {
@@ -38,141 +37,105 @@ func Test_detectChanges(t *testing.T) {
{
name: "With same version",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
},
},
{
name: "With different version",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
+ ResourceVersion: "2",
},
},
{
name: "Ingress With same version",
oldObj: &netv1.Ingress{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
},
newObj: &netv1.Ingress{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
},
},
{
name: "Ingress With different version",
oldObj: &netv1.Ingress{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
},
newObj: &netv1.Ingress{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
+ ResourceVersion: "2",
},
want: true,
},
{
name: "With same annotations",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- Annotations: map[string]string{
- "test-annotation": "_",
- },
+ ResourceVersion: "1",
+ Annotations: map[string]string{
+ "test-annotation": "_",
},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- Annotations: map[string]string{
- "test-annotation": "_",
- },
+ ResourceVersion: "2",
+ Annotations: map[string]string{
+ "test-annotation": "_",
},
},
},
{
name: "With different annotations",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- Annotations: map[string]string{
- "test-annotation": "V",
- },
+ ResourceVersion: "1",
+ Annotations: map[string]string{
+ "test-annotation": "V",
},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- Annotations: map[string]string{
- "test-annotation": "X",
- },
+ ResourceVersion: "2",
+ Annotations: map[string]string{
+ "test-annotation": "X",
},
},
},
{
name: "With same endpoints and ports",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
- Endpoints: []discoveryv1.Endpoint{},
- Ports: []discoveryv1.EndpointPort{},
+ ResourceVersion: "1",
+ Endpoints: []discoveryv1.Endpoint{},
+ Ports: []discoveryv1.EndpointPort{},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
- Endpoints: []discoveryv1.Endpoint{},
- Ports: []discoveryv1.EndpointPort{},
+ ResourceVersion: "1",
+ Endpoints: []discoveryv1.Endpoint{},
+ Ports: []discoveryv1.EndpointPort{},
},
},
{
name: "With different len of endpoints",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
- Endpoints: []discoveryv1.Endpoint{},
+ ResourceVersion: "1",
+ Endpoints: []discoveryv1.Endpoint{},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
- Endpoints: []discoveryv1.Endpoint{{}},
+ ResourceVersion: "2",
+ Endpoints: []discoveryv1.Endpoint{{}},
},
want: true,
},
{
name: "With different endpoints",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
}},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
+ ResourceVersion: "2",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.11"},
}},
@@ -182,18 +145,14 @@ func Test_detectChanges(t *testing.T) {
{
name: "With different endpoint ready condition",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
Conditions: discoveryv1.EndpointConditions{Ready: new(true)},
}},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
+ ResourceVersion: "2",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
Conditions: discoveryv1.EndpointConditions{Ready: new(false)},
@@ -204,18 +163,14 @@ func Test_detectChanges(t *testing.T) {
{
name: "With different endpoint serving condition",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
Conditions: discoveryv1.EndpointConditions{Serving: new(true)},
}},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
+ ResourceVersion: "2",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
Conditions: discoveryv1.EndpointConditions{Serving: new(false)},
@@ -226,18 +181,14 @@ func Test_detectChanges(t *testing.T) {
{
name: "With different endpoint terminating condition",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
Conditions: discoveryv1.EndpointConditions{Terminating: new(false)},
}},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
+ ResourceVersion: "2",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
Conditions: discoveryv1.EndpointConditions{Terminating: new(true)},
@@ -248,17 +199,13 @@ func Test_detectChanges(t *testing.T) {
{
name: "With endpoint serving condition nil then explicitly true",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
}},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
+ ResourceVersion: "2",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
Conditions: discoveryv1.EndpointConditions{Serving: new(true)},
@@ -268,17 +215,13 @@ func Test_detectChanges(t *testing.T) {
{
name: "With endpoint serving condition nil then explicitly false",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
}},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
+ ResourceVersion: "2",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
Conditions: discoveryv1.EndpointConditions{Serving: new(false)},
@@ -289,17 +232,13 @@ func Test_detectChanges(t *testing.T) {
{
name: "With endpoint terminating condition nil then explicitly false",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
}},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
+ ResourceVersion: "2",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
Conditions: discoveryv1.EndpointConditions{Terminating: new(false)},
@@ -309,17 +248,13 @@ func Test_detectChanges(t *testing.T) {
{
name: "With endpoint terminating condition nil then explicitly true",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
}},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
+ ResourceVersion: "2",
Endpoints: []discoveryv1.Endpoint{{
Addresses: []string{"10.10.10.10"},
Conditions: discoveryv1.EndpointConditions{Terminating: new(true)},
@@ -330,33 +265,25 @@ func Test_detectChanges(t *testing.T) {
{
name: "With different len of ports",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
- Ports: []discoveryv1.EndpointPort{},
+ ResourceVersion: "1",
+ Ports: []discoveryv1.EndpointPort{},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
- Ports: []discoveryv1.EndpointPort{{}},
+ ResourceVersion: "2",
+ Ports: []discoveryv1.EndpointPort{{}},
},
want: true,
},
{
name: "With different ports",
oldObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "1",
- },
+ ResourceVersion: "1",
Ports: []discoveryv1.EndpointPort{{
Port: new(int32(80)),
}},
},
newObj: &discoveryv1.EndpointSlice{
- ObjectMeta: metav1.ObjectMeta{
- ResourceVersion: "2",
- },
+ ResourceVersion: "2",
Ports: []discoveryv1.EndpointPort{{
Port: new(int32(8080)),
}},
diff --git a/pkg/provider/kv/kv_test.go b/pkg/provider/kv/kv_test.go
index 0b6a27a3c5..946f280dbd 100644
--- a/pkg/provider/kv/kv_test.go
+++ b/pkg/provider/kv/kv_test.go
@@ -864,20 +864,16 @@ func Test_buildConfiguration(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent("foobar"),
- KeyFile: types.FileOrContent("foobar"),
- },
+ CertFile: types.FileOrContent("foobar"),
+ KeyFile: types.FileOrContent("foobar"),
Stores: []string{
"foobar",
"foobar",
},
},
{
- Certificate: tls.Certificate{
- CertFile: types.FileOrContent("foobar"),
- KeyFile: types.FileOrContent("foobar"),
- },
+ CertFile: types.FileOrContent("foobar"),
+ KeyFile: types.FileOrContent("foobar"),
Stores: []string{
"foobar",
"foobar",
diff --git a/pkg/provider/merge_test.go b/pkg/provider/merge_test.go
index 2dd890dd60..2ef33229d2 100644
--- a/pkg/provider/merge_test.go
+++ b/pkg/provider/merge_test.go
@@ -81,20 +81,16 @@ func TestMergeCollectionSet_BasicMapMerge(t *testing.T) {
func TestMergeCollectionSet_EmbeddedStruct(t *testing.T) {
dst := &testCollectionSetWithEmbedded{
- TestEmbedded: TestEmbedded{
- EmbeddedItems: map[string]*testResource{
- "embedded1": {Value: "dst-embedded"},
- },
+ EmbeddedItems: map[string]*testResource{
+ "embedded1": {Value: "dst-embedded"},
},
Items: map[string]*testResource{
"item1": {Value: "dst-item"},
},
}
src := &testCollectionSetWithEmbedded{
- TestEmbedded: TestEmbedded{
- EmbeddedItems: map[string]*testResource{
- "embedded2": {Value: "src-embedded"},
- },
+ EmbeddedItems: map[string]*testResource{
+ "embedded2": {Value: "src-embedded"},
},
Items: map[string]*testResource{
"item2": {Value: "src-item"},
@@ -106,11 +102,9 @@ func TestMergeCollectionSet_EmbeddedStruct(t *testing.T) {
assert.Empty(t, tracker.toDelete)
assert.Equal(t, &testCollectionSetWithEmbedded{
- TestEmbedded: TestEmbedded{
- EmbeddedItems: map[string]*testResource{
- "embedded1": {Value: "dst-embedded"},
- "embedded2": {Value: "src-embedded"},
- },
+ EmbeddedItems: map[string]*testResource{
+ "embedded1": {Value: "dst-embedded"},
+ "embedded2": {Value: "src-embedded"},
},
Items: map[string]*testResource{
"item1": {Value: "dst-item"},
@@ -348,8 +342,8 @@ func TestMerge(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert1.pem", KeyFile: "key1.pem"},
- Stores: []string{"store1"},
+ CertFile: "cert1.pem", KeyFile: "key1.pem",
+ Stores: []string{"store1"},
},
},
},
@@ -358,8 +352,8 @@ func TestMerge(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert2.pem", KeyFile: "key2.pem"},
- Stores: []string{"store2"},
+ CertFile: "cert2.pem", KeyFile: "key2.pem",
+ Stores: []string{"store2"},
},
},
},
@@ -369,12 +363,12 @@ func TestMerge(t *testing.T) {
expected: buildExpectedConfiguration(func(c *dynamic.Configuration) {
c.TLS.Certificates = []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert1.pem", KeyFile: "key1.pem"},
- Stores: []string{"store1"},
+ CertFile: "cert1.pem", KeyFile: "key1.pem",
+ Stores: []string{"store1"},
},
{
- Certificate: tls.Certificate{CertFile: "cert2.pem", KeyFile: "key2.pem"},
- Stores: []string{"store2"},
+ CertFile: "cert2.pem", KeyFile: "key2.pem",
+ Stores: []string{"store2"},
},
}
}),
@@ -386,8 +380,8 @@ func TestMerge(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert.pem", KeyFile: "key.pem"},
- Stores: []string{"store1"},
+ CertFile: "cert.pem", KeyFile: "key.pem",
+ Stores: []string{"store1"},
},
},
},
@@ -396,8 +390,8 @@ func TestMerge(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert.pem", KeyFile: "key.pem"},
- Stores: []string{"store2"},
+ CertFile: "cert.pem", KeyFile: "key.pem",
+ Stores: []string{"store2"},
},
},
},
@@ -407,8 +401,8 @@ func TestMerge(t *testing.T) {
expected: buildExpectedConfiguration(func(c *dynamic.Configuration) {
c.TLS.Certificates = []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert.pem", KeyFile: "key.pem"},
- Stores: []string{"store1", "store2"},
+ CertFile: "cert.pem", KeyFile: "key.pem",
+ Stores: []string{"store1", "store2"},
},
}
}),
@@ -420,8 +414,8 @@ func TestMerge(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert.pem", KeyFile: "key.pem"},
- Stores: []string{"store1", "store2"},
+ CertFile: "cert.pem", KeyFile: "key.pem",
+ Stores: []string{"store1", "store2"},
},
},
},
@@ -430,8 +424,8 @@ func TestMerge(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert.pem", KeyFile: "key.pem"},
- Stores: []string{"store2", "store3"},
+ CertFile: "cert.pem", KeyFile: "key.pem",
+ Stores: []string{"store2", "store3"},
},
},
},
@@ -441,8 +435,8 @@ func TestMerge(t *testing.T) {
expected: buildExpectedConfiguration(func(c *dynamic.Configuration) {
c.TLS.Certificates = []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert.pem", KeyFile: "key.pem"},
- Stores: []string{"store1", "store2", "store3"},
+ CertFile: "cert.pem", KeyFile: "key.pem",
+ Stores: []string{"store1", "store2", "store3"},
},
}
}),
@@ -454,8 +448,8 @@ func TestMerge(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert.pem", KeyFile: "key.pem"},
- Stores: []string{"store1"},
+ CertFile: "cert.pem", KeyFile: "key.pem",
+ Stores: []string{"store1"},
},
},
},
@@ -464,8 +458,8 @@ func TestMerge(t *testing.T) {
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert.pem", KeyFile: "key.pem"},
- Stores: []string{"store2"},
+ CertFile: "cert.pem", KeyFile: "key.pem",
+ Stores: []string{"store2"},
},
},
},
@@ -475,8 +469,8 @@ func TestMerge(t *testing.T) {
expected: buildExpectedConfiguration(func(c *dynamic.Configuration) {
c.TLS.Certificates = []*tls.CertAndStores{
{
- Certificate: tls.Certificate{CertFile: "cert.pem", KeyFile: "key.pem"},
- Stores: []string{"store1"},
+ CertFile: "cert.pem", KeyFile: "key.pem",
+ Stores: []string{"store1"},
},
}
}),
diff --git a/pkg/provider/nomad/nomad_test.go b/pkg/provider/nomad/nomad_test.go
index d5442d50fb..5ff1831d22 100644
--- a/pkg/provider/nomad/nomad_test.go
+++ b/pkg/provider/nomad/nomad_test.go
@@ -80,10 +80,8 @@ func Test_globalConfig(t *testing.T) {
for _, test := range cases {
t.Run(test.Name, func(t *testing.T) {
p := Provider{
- Configuration: Configuration{
- ExposedByDefault: test.ExposedByDefault,
- Prefix: test.Prefix,
- },
+ ExposedByDefault: test.ExposedByDefault,
+ Prefix: test.Prefix,
}
result := p.getExtraConf(test.Tags)
require.Equal(t, test.exp, result)
diff --git a/pkg/provider/tailscale/provider_test.go b/pkg/provider/tailscale/provider_test.go
index 279299b3c3..1036fe69c5 100644
--- a/pkg/provider/tailscale/provider_test.go
+++ b/pkg/provider/tailscale/provider_test.go
@@ -175,12 +175,12 @@ func TestProvider_sendDynamicConfig(t *testing.T) {
},
want: []*traefiktls.CertAndStores{
{
- Certificate: traefiktls.Certificate{CertFile: "bar.crt", KeyFile: "bar.key"},
- Stores: []string{traefiktls.DefaultTLSStoreName},
+ CertFile: "bar.crt", KeyFile: "bar.key",
+ Stores: []string{traefiktls.DefaultTLSStoreName},
},
{
- Certificate: traefiktls.Certificate{CertFile: "foo.crt", KeyFile: "foo.key"},
- Stores: []string{traefiktls.DefaultTLSStoreName},
+ CertFile: "foo.crt", KeyFile: "foo.key",
+ Stores: []string{traefiktls.DefaultTLSStoreName},
},
},
},
diff --git a/pkg/redactor/redactor_config_test.go b/pkg/redactor/redactor_config_test.go
index b30bd7373d..dd5dc9fd5e 100644
--- a/pkg/redactor/redactor_config_test.go
+++ b/pkg/redactor/redactor_config_test.go
@@ -24,7 +24,6 @@ import (
"github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd"
"github.com/traefik/traefik/v3/pkg/provider/kubernetes/gateway"
"github.com/traefik/traefik/v3/pkg/provider/kubernetes/ingress"
- "github.com/traefik/traefik/v3/pkg/provider/kv"
"github.com/traefik/traefik/v3/pkg/provider/kv/consul"
"github.com/traefik/traefik/v3/pkg/provider/kv/etcd"
"github.com/traefik/traefik/v3/pkg/provider/kv/redis"
@@ -456,11 +455,9 @@ func init() {
},
Certificates: []*traefiktls.CertAndStores{
{
- Certificate: traefiktls.Certificate{
- CertFile: "cert.pem",
- KeyFile: "key.pem",
- },
- Stores: []string{"foo"},
+ CertFile: "cert.pem",
+ KeyFile: "key.pem",
+ Stores: []string{"foo"},
},
},
Stores: map[string]traefiktls.Store{
@@ -604,46 +601,38 @@ func TestDo_staticConfiguration(t *testing.T) {
}
config.Providers.Docker = &docker.Provider{
- Shared: docker.Shared{
- ExposedByDefault: true,
- Constraints: `Label("foo", "bar")`,
- AllowEmptyServices: true,
- Network: "MyNetwork",
- UseBindPortIP: true,
- Watch: true,
- DefaultRule: "PathPrefix(`/`)",
- },
- ClientConfig: docker.ClientConfig{
- Endpoint: "MyEndPoint", TLS: &types.ClientTLS{
- CA: "myCa",
- Cert: "mycert.pem",
- Key: "mycert.key",
- InsecureSkipVerify: true,
- },
- HTTPClientTimeout: 42,
+ ExposedByDefault: true,
+ Constraints: `Label("foo", "bar")`,
+ AllowEmptyServices: true,
+ Network: "MyNetwork",
+ UseBindPortIP: true,
+ Watch: true,
+ DefaultRule: "PathPrefix(`/`)",
+ Endpoint: "MyEndPoint", TLS: &types.ClientTLS{
+ CA: "myCa",
+ Cert: "mycert.pem",
+ Key: "mycert.key",
+ InsecureSkipVerify: true,
},
+ HTTPClientTimeout: 42,
}
config.Providers.Swarm = &docker.SwarmProvider{
- Shared: docker.Shared{
- ExposedByDefault: true,
- Constraints: `Label("foo", "bar")`,
- AllowEmptyServices: true,
- Network: "MyNetwork",
- UseBindPortIP: true,
- Watch: true,
- DefaultRule: "PathPrefix(`/`)",
+ ExposedByDefault: true,
+ Constraints: `Label("foo", "bar")`,
+ AllowEmptyServices: true,
+ Network: "MyNetwork",
+ UseBindPortIP: true,
+ Watch: true,
+ DefaultRule: "PathPrefix(`/`)",
+ Endpoint: "MyEndPoint", TLS: &types.ClientTLS{
+ CA: "myCa",
+ Cert: "mycert.pem",
+ Key: "mycert.key",
+ InsecureSkipVerify: true,
},
- ClientConfig: docker.ClientConfig{
- Endpoint: "MyEndPoint", TLS: &types.ClientTLS{
- CA: "myCa",
- Cert: "mycert.pem",
- Key: "mycert.key",
- InsecureSkipVerify: true,
- },
- HTTPClientTimeout: 42,
- },
- RefreshSeconds: 42,
+ HTTPClientTimeout: 42,
+ RefreshSeconds: 42,
}
config.Providers.KubernetesIngress = &ingress.Provider{
@@ -685,34 +674,32 @@ func TestDo_staticConfiguration(t *testing.T) {
}
config.Providers.ConsulCatalog = &consulcatalog.ProviderBuilder{
- Configuration: consulcatalog.Configuration{
- Constraints: `Label("foo", "bar")`,
- Endpoint: &consulcatalog.EndpointConfig{
- Address: "MyAddress",
- Scheme: "MyScheme",
- DataCenter: "MyDatacenter",
- Token: "MyToken",
- TLS: &types.ClientTLS{
- CA: "myCa",
- Cert: "mycert.pem",
- Key: "mycert.key",
- InsecureSkipVerify: true,
- },
- HTTPAuth: &consulcatalog.EndpointHTTPAuthConfig{
- Username: "MyUsername",
- Password: "MyPassword",
- },
- EndpointWaitTime: 42,
+ Constraints: `Label("foo", "bar")`,
+ Endpoint: &consulcatalog.EndpointConfig{
+ Address: "MyAddress",
+ Scheme: "MyScheme",
+ DataCenter: "MyDatacenter",
+ Token: "MyToken",
+ TLS: &types.ClientTLS{
+ CA: "myCa",
+ Cert: "mycert.pem",
+ Key: "mycert.key",
+ InsecureSkipVerify: true,
},
- Prefix: "MyPrefix",
- RefreshInterval: 42,
- RequireConsistent: true,
- Stale: true,
- Cache: true,
- ExposedByDefault: true,
- DefaultRule: "PathPrefix(`/`)",
+ HTTPAuth: &consulcatalog.EndpointHTTPAuthConfig{
+ Username: "MyUsername",
+ Password: "MyPassword",
+ },
+ EndpointWaitTime: 42,
},
- Namespaces: []string{"ns1", "ns2"},
+ Prefix: "MyPrefix",
+ RefreshInterval: 42,
+ RequireConsistent: true,
+ Stale: true,
+ Cache: true,
+ ExposedByDefault: true,
+ DefaultRule: "PathPrefix(`/`)",
+ Namespaces: []string{"ns1", "ns2"},
}
config.Providers.Ecs = &ecs.Provider{
@@ -729,11 +716,9 @@ func TestDo_staticConfiguration(t *testing.T) {
}
config.Providers.Consul = &consul.ProviderBuilder{
- Provider: kv.Provider{
- RootKey: "RootKey",
- Endpoints: nil,
- },
- Token: "secret",
+ RootKey: "RootKey",
+ Endpoints: nil,
+ Token: "secret",
TLS: &types.ClientTLS{
CA: "myCa",
Cert: "mycert.pem",
@@ -744,12 +729,10 @@ func TestDo_staticConfiguration(t *testing.T) {
}
config.Providers.Etcd = &etcd.Provider{
- Provider: kv.Provider{
- RootKey: "RootKey",
- Endpoints: nil,
- },
- Username: "username",
- Password: "password",
+ RootKey: "RootKey",
+ Endpoints: nil,
+ Username: "username",
+ Password: "password",
TLS: &types.ClientTLS{
CA: "myCa",
Cert: "mycert.pem",
@@ -759,21 +742,17 @@ func TestDo_staticConfiguration(t *testing.T) {
}
config.Providers.ZooKeeper = &zk.Provider{
- Provider: kv.Provider{
- RootKey: "RootKey",
- Endpoints: nil,
- },
- Username: "username",
- Password: "password",
+ RootKey: "RootKey",
+ Endpoints: nil,
+ Username: "username",
+ Password: "password",
}
config.Providers.Redis = &redis.Provider{
- Provider: kv.Provider{
- RootKey: "RootKey",
- Endpoints: nil,
- },
- Username: "username",
- Password: "password",
+ RootKey: "RootKey",
+ Endpoints: nil,
+ Username: "username",
+ Password: "password",
TLS: &types.ClientTLS{
CA: "myCa",
Cert: "mycert.pem",
diff --git a/pkg/server/aggregator_test.go b/pkg/server/aggregator_test.go
index a5fe799464..a0b27e2623 100644
--- a/pkg/server/aggregator_test.go
+++ b/pkg/server/aggregator_test.go
@@ -150,15 +150,17 @@ func Test_mergeConfiguration_tlsCertificates(t *testing.T) {
"tlsalpn.acme": &dynamic.Configuration{
TLS: &dynamic.TLSConfiguration{
Certificates: []*tls.CertAndStores{{
- Certificate: tls.Certificate{CertFile: "foo", KeyFile: "bar"},
- Stores: []string{tlsalpn01.ACMETLS1Protocol},
+ CertFile: "foo",
+ KeyFile: "bar",
+ Stores: []string{tlsalpn01.ACMETLS1Protocol},
}},
},
},
},
expected: []*tls.CertAndStores{{
- Certificate: tls.Certificate{CertFile: "foo", KeyFile: "bar"},
- Stores: []string{tlsalpn01.ACMETLS1Protocol},
+ CertFile: "foo",
+ KeyFile: "bar",
+ Stores: []string{tlsalpn01.ACMETLS1Protocol},
}},
},
}
diff --git a/pkg/server/router/tcp/router_test.go b/pkg/server/router/tcp/router_test.go
index 221042cd25..c6a48f5bdf 100644
--- a/pkg/server/router/tcp/router_test.go
+++ b/pkg/server/router/tcp/router_test.go
@@ -152,8 +152,8 @@ func Test_Routing(t *testing.T) {
},
},
[]*traefiktls.CertAndStores{{
- Certificate: traefiktls.Certificate{CertFile: types.FileOrContent(certPEM), KeyFile: types.FileOrContent(keyPEM)},
- Stores: []string{tlsalpn01.ACMETLS1Protocol},
+ CertFile: types.FileOrContent(certPEM), KeyFile: types.FileOrContent(keyPEM),
+ Stores: []string{tlsalpn01.ACMETLS1Protocol},
}})
middlewaresBuilder := tcpmiddleware.NewBuilder(conf.TCPMiddlewares)
diff --git a/pkg/server/server_entrypoint_tcp.go b/pkg/server/server_entrypoint_tcp.go
index f4c541b984..2d27f9c416 100644
--- a/pkg/server/server_entrypoint_tcp.go
+++ b/pkg/server/server_entrypoint_tcp.go
@@ -773,13 +773,14 @@ func newHTTPServer(ctx context.Context, ln net.Listener, configuration *static.E
}
serverHTTP := &http.Server{
- Protocols: &protocols,
- Handler: handler,
- ErrorLog: stdlog.New(logs.NoLevel(log.Logger, zerolog.DebugLevel), "", 0),
- ReadTimeout: time.Duration(configuration.Transport.RespondingTimeouts.ReadTimeout),
- WriteTimeout: time.Duration(configuration.Transport.RespondingTimeouts.WriteTimeout),
- IdleTimeout: time.Duration(configuration.Transport.RespondingTimeouts.IdleTimeout),
- MaxHeaderBytes: configuration.HTTP.MaxHeaderBytes,
+ Protocols: &protocols,
+ Handler: handler,
+ ErrorLog: stdlog.New(logs.NoLevel(log.Logger, zerolog.DebugLevel), "", 0),
+ ReadTimeout: time.Duration(configuration.Transport.RespondingTimeouts.ReadTimeout),
+ WriteTimeout: time.Duration(configuration.Transport.RespondingTimeouts.WriteTimeout),
+ IdleTimeout: time.Duration(configuration.Transport.RespondingTimeouts.IdleTimeout),
+ MaxHeaderBytes: configuration.HTTP.MaxHeaderBytes,
+ MaxHeaderValueCount: configuration.HTTP.MaxHeaderValueCount,
HTTP2: &http.HTTP2Config{
MaxConcurrentStreams: int(configuration.HTTP2.MaxConcurrentStreams),
MaxDecoderHeaderTableSize: int(configuration.HTTP2.MaxDecoderHeaderTableSize),
diff --git a/pkg/tls/tlsmanager_test.go b/pkg/tls/tlsmanager_test.go
index 1cee202766..99ed26109c 100644
--- a/pkg/tls/tlsmanager_test.go
+++ b/pkg/tls/tlsmanager_test.go
@@ -78,10 +78,8 @@ ZboOWVe3icTy64BT3OQhmg==
func TestTLSInStore(t *testing.T) {
dynamicConfigs := []*CertAndStores{{
- Certificate: Certificate{
- CertFile: localhostCert,
- KeyFile: localhostKey,
- },
+ CertFile: localhostCert,
+ KeyFile: localhostKey,
}}
tlsManager := NewManager(nil)
@@ -95,10 +93,8 @@ func TestTLSInStore(t *testing.T) {
func TestTLSInvalidStore(t *testing.T) {
dynamicConfigs := []*CertAndStores{{
- Certificate: Certificate{
- CertFile: localhostCert,
- KeyFile: localhostKey,
- },
+ CertFile: localhostCert,
+ KeyFile: localhostKey,
}}
tlsManager := NewManager(nil)
@@ -120,10 +116,8 @@ func TestTLSInvalidStore(t *testing.T) {
func TestManager_Get(t *testing.T) {
dynamicConfigs := []*CertAndStores{{
- Certificate: Certificate{
- CertFile: localhostCert,
- KeyFile: localhostKey,
- },
+ CertFile: localhostCert,
+ KeyFile: localhostKey,
}}
tlsConfigs := map[string]Options{
@@ -402,10 +396,8 @@ func TestManager_UpdateConfigs_OCSPConfig(t *testing.T) {
tlsManager.UpdateConfigs(testContext, nil, nil, []*CertAndStores{
{
- Certificate: Certificate{
- CertFile: certWithOCSPServer,
- KeyFile: certKey,
- },
+ CertFile: certWithOCSPServer,
+ KeyFile: certKey,
},
})