Skip to content

Commit 44826dc

Browse files
committed
fix: lagoon routes json wildcards
1 parent b9cd1a2 commit 44826dc

File tree

4 files changed

+80
-2
lines changed

4 files changed

+80
-2
lines changed

cmd/template_ingress_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,25 @@ func TestTemplateRoutes(t *testing.T) {
413413
templatePath: "testdata/output",
414414
want: "internal/testdata/basic/ingress-templates/test25-pathroutes",
415415
},
416+
{
417+
name: "test25 check wildcard LAGOON_ROUTES_JSON",
418+
args: testdata.GetSeedData(
419+
testdata.TestData{
420+
ProjectName: "example-project",
421+
EnvironmentName: "wildcardjson",
422+
Branch: "wildcardjson",
423+
LagoonYAML: "internal/testdata/node/lagoon.yml",
424+
ProjectVariables: []lagoon.EnvironmentVariable{
425+
{
426+
Name: "LAGOON_ROUTES_JSON",
427+
Value: base64.StdEncoding.EncodeToString([]byte(`{"routes":[{"domain":"test1.example.com","wildcard":true,"service":"node","tls-acme":false,"monitoring-path":"/bypass-cache"}]}`)),
428+
Scope: "build",
429+
},
430+
},
431+
}, true),
432+
templatePath: "testoutput",
433+
want: "internal/testdata/node/ingress-templates/ingress-24",
434+
},
416435
}
417436
for _, tt := range tests {
418437
t.Run(tt.name, func(t *testing.T) {

internal/lagoon/routes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ func handleAPIRoute(defaultIngressClass string, apiRoute RouteV2) (RouteV2, erro
390390
if err := validation.IsDNS1123Subdomain(strings.ToLower(apiRoute.IngressName)); err != nil {
391391
apiRoute.IngressName = fmt.Sprintf("%s-%s", apiRoute.IngressName[:len(apiRoute.IngressName)-10], helpers.GetMD5HashWithNewLine(apiRoute.Domain)[:5])
392392
}
393+
routeAdd.IngressName = apiRoute.IngressName
393394
}
394395

395396
if apiRoute.RequestVerification != nil {

internal/lagoon/routes_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ func TestMergeRouteStructures(t *testing.T) {
672672
AlternativeNames: []string{},
673673
Wildcard: helpers.BoolPtr(true),
674674
WildcardApex: helpers.BoolPtr(true),
675-
IngressName: "example.com",
675+
IngressName: "wildcard-example.com",
676676
RequestVerification: helpers.BoolPtr(false),
677677
},
678678
{
@@ -685,7 +685,7 @@ func TestMergeRouteStructures(t *testing.T) {
685685
AlternativeNames: []string{},
686686
Wildcard: helpers.BoolPtr(true),
687687
WildcardApex: helpers.BoolPtr(true),
688-
IngressName: "a.example.com",
688+
IngressName: "wildcard-a.example.com",
689689
RequestVerification: helpers.BoolPtr(false),
690690
},
691691
},
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
annotations:
6+
fastly.amazee.io/watch: "false"
7+
idling.amazee.io/disable-request-verification: "false"
8+
ingress.kubernetes.io/ssl-redirect: "true"
9+
kubernetes.io/tls-acme: "false"
10+
lagoon.sh/branch: wildcardjson
11+
lagoon.sh/version: v2.7.x
12+
monitor.stakater.com/enabled: "false"
13+
monitor.stakater.com/overridePath: /bypass-cache
14+
nginx.ingress.kubernetes.io/ssl-redirect: "true"
15+
creationTimestamp: null
16+
labels:
17+
activestandby.lagoon.sh/migrate: "false"
18+
app.kubernetes.io/instance: wildcard-test1.example.com
19+
app.kubernetes.io/managed-by: build-deploy-tool
20+
app.kubernetes.io/name: custom-ingress
21+
lagoon.sh/autogenerated: "false"
22+
lagoon.sh/buildType: branch
23+
lagoon.sh/environment: wildcardjson
24+
lagoon.sh/environmentType: production
25+
lagoon.sh/project: example-project
26+
lagoon.sh/service: wildcard-test1.example.com
27+
lagoon.sh/service-type: custom-ingress
28+
lagoon.sh/template: custom-ingress-0.1.0
29+
name: wildcard-test1.example.com
30+
spec:
31+
rules:
32+
- host: '*.test1.example.com'
33+
http:
34+
paths:
35+
- backend:
36+
service:
37+
name: node
38+
port:
39+
name: http
40+
path: /
41+
pathType: Prefix
42+
- host: test1.example.com
43+
http:
44+
paths:
45+
- backend:
46+
service:
47+
name: node
48+
port:
49+
name: http
50+
path: /
51+
pathType: Prefix
52+
tls:
53+
- hosts:
54+
- '*.test1.example.com'
55+
- test1.example.com
56+
secretName: wildcard-test1.example.com-tls
57+
status:
58+
loadBalancer: {}

0 commit comments

Comments
 (0)