Skip to content

Commit

Permalink
chore: update tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
traefiker authored Jul 17, 2024
1 parent fb791fc commit f8c0cf4
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 33 deletions.
2 changes: 1 addition & 1 deletion WALKTHROUGH.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ helm upgrade traefik -n traefik --wait \
--set hub.token=license \
--set image.registry=ghcr.io \
--set image.repository=traefik/traefik-hub \
--set image.tag=v3.2.0 \
--set image.tag=v3.3.0 \
traefik/traefik
```

Expand Down
4 changes: 2 additions & 2 deletions api-gateway/1-getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ helm install traefik-hub -n traefik --wait \
--set ingressRoute.dashboard.entryPoints={web} \
--set image.registry=ghcr.io \
--set image.repository=traefik/traefik-hub \
--set image.tag=v3.2.0 \
--set image.tag=v3.3.0 \
--set ports.web.nodePort=30000 \
--set ports.websecure.nodePort=30001 \
traefik/traefik
Expand All @@ -118,7 +118,7 @@ helm upgrade traefik-hub -n traefik-hub --wait \
--set ingressRoute.dashboard.entryPoints={web} \
--set image.registry=ghcr.io \
--set image.repository=traefik/traefik-hub \
--set image.tag=v3.2.0 \
--set image.tag=v3.3.0 \
--set ports.web.nodePort=30000 \
--set ports.websecure.nodePort=30001 \
traefik/traefik
Expand Down
4 changes: 2 additions & 2 deletions api-management/1-getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ helm install traefik-hub -n traefik --wait \
--set ingressRoute.dashboard.entryPoints={web} \
--set image.registry=ghcr.io \
--set image.repository=traefik/traefik-hub \
--set image.tag=v3.2.0 \
--set image.tag=v3.3.0 \
--set ports.web.nodePort=30000 \
--set ports.websecure.nodePort=30001 \
traefik/traefik
Expand All @@ -113,7 +113,7 @@ helm upgrade traefik-hub -n traefik --wait \
--set ingressRoute.dashboard.entryPoints={web} \
--set image.registry=ghcr.io \
--set image.repository=traefik/traefik-hub \
--set image.tag=v3.2.0 \
--set image.tag=v3.3.0 \
--set ports.web.nodePort=30000 \
--set ports.websecure.nodePort=30001 \
traefik/traefik
Expand Down
2 changes: 1 addition & 1 deletion src/api-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1.8
# syntax=docker/dockerfile:1.9

# golang builder
FROM golang:1.22 AS builder
Expand Down
3 changes: 2 additions & 1 deletion tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/traefik/hub/tests
go 1.22.0

require (
github.com/fluxcd/pkg/envsubst v1.1.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
github.com/testcontainers/testcontainers-go v0.31.0
Expand Down Expand Up @@ -100,3 +99,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/abbot/go-http-auth => github.com/containous/go-http-auth v0.4.1-0.20200324110947-a37a7636d23e
2 changes: 0 additions & 2 deletions tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0
github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fluxcd/pkg/envsubst v1.1.0 h1:b0a9QsG36btk3MIWf7yM9FhVPhyXh6lLJu8eZk4Fyow=
github.com/fluxcd/pkg/envsubst v1.1.0/go.mod h1:4Uca9c2Bhu4+65sa6NbChEA3zZKhqyAjtgDEi+Zq9Y8=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
Expand Down
32 changes: 9 additions & 23 deletions tests/testhelpers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"testing"
"time"

"github.com/fluxcd/pkg/envsubst"
"github.com/docker/docker/api/types/container"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -48,8 +48,10 @@ func CreateKubernetesCluster(ctx context.Context, t *testing.T) (*k3s.K3sContain
ContainerRequest: testcontainers.ContainerRequest{
Image: rancherImage,
ExposedPorts: []string{"80/tcp", "443/tcp", "6443/tcp", "8443/tcp"},
NetworkMode: "host",
Privileged: true,
HostConfigModifier: func(hc *container.HostConfig) {
hc.NetworkMode = "host"
},
Privileged: true,
},
}),
)
Expand Down Expand Up @@ -119,7 +121,7 @@ func InstallTraefikHubAPIGW(ctx context.Context, t *testing.T, k8s client.Client
"--set", "ingressRoute.dashboard.entryPoints={web}",
"--set", "image.registry=ghcr.io",
"--set", "image.repository=traefik/traefik-hub",
"--set", "image.tag=v3.2.0",
"--set", "image.tag=v3.3.0",
"--set", "ports.web.nodePort=30000",
"--set", "ports.websecure.nodePort=30001",
"traefik/traefik")
Expand Down Expand Up @@ -147,7 +149,7 @@ func InstallTraefikHubAPIM(ctx context.Context, t *testing.T, k8s client.Client)
"--set", "ingressRoute.dashboard.entryPoints={web}",
"--set", "image.registry=ghcr.io",
"--set", "image.repository=traefik/traefik-hub",
"--set", "image.tag=v3.2.0",
"--set", "image.tag=v3.3.0",
"--set", "ports.web.nodePort=30000",
"--set", "ports.websecure.nodePort=30001",
"traefik/traefik")
Expand Down Expand Up @@ -259,7 +261,8 @@ func getJobState(ctx context.Context, t *testing.T, k8s client.Client, labelSele

// Inspired by Gateway API implementation
// See https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/utils/kubernetes/apply.go
// ApplyFile apply a yaml on k8s client

// ApplyFile applies a yaml on k8s client
func ApplyFile(ctx context.Context, k8s client.Client, filepath string) (result []string, err error) {
data, err := os.ReadFile(filepath)
if err != nil {
Expand All @@ -269,23 +272,6 @@ func ApplyFile(ctx context.Context, k8s client.Client, filepath string) (result
return applyYAMLOrJSONDecoder(ctx, k8s, decoder)
}

// ApplyFile execute ensubst and apply a yaml on k8s client
func ApplyEnvSubstFile(ctx context.Context, k8s client.Client, filepath string, debug bool) (result []string, err error) {
data, err := os.ReadFile(filepath)
if err != nil {
return nil, err
}
output, err := envsubst.EvalEnv(string(data), false)
if err != nil {
return nil, err
}
if debug {
testcontainers.Logger.Printf("Yaml after envsubst: %s\n", output)
}
decoder := yaml.NewYAMLOrJSONDecoder(bytes.NewBufferString(output), 4096)
return applyYAMLOrJSONDecoder(ctx, k8s, decoder)
}

func applyYAMLOrJSONDecoder(ctx context.Context, k8s client.Client, decoder *yaml.YAMLOrJSONDecoder) (result []string, err error) {
resources, err := prepareResources(decoder)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tests/walkthrough/walkthrough_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (s *WalkthroughTestSuite) TestWalkthrough() {
"--set", "hub.token=license",
"--set", "image.registry=ghcr.io",
"--set", "image.repository=traefik/traefik-hub",
"--set", "image.tag=v3.2.0",
"--set", "image.tag=v3.3.0",
"traefik/traefik")

req, err = http.NewRequest(http.MethodGet, "http://walkthrough.docker.localhost/basic-auth", nil)
Expand Down

0 comments on commit f8c0cf4

Please sign in to comment.