Skip to content

Commit 30e0c82

Browse files
committed
feat: support for api defined routes
1 parent 059b671 commit 30e0c82

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

internal/lagoon/routes.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type RoutesV2 struct {
2020
type RouteV2 struct {
2121
Domain string `json:"domain"`
2222
LagoonService string `json:"service"`
23-
ComposeService string `json:"composeService"` // the
23+
ComposeService string `json:"composeService"`
2424
TLSAcme *bool `json:"tls-acme"`
2525
Migrate *bool `json:"migrate,omitempty"`
2626
Insecure *string `json:"insecure,omitempty"`
@@ -40,6 +40,31 @@ type RouteV2 struct {
4040
WildcardApex *bool `json:"wildcardApex,omitempty"`
4141
RequestVerification *bool `json:"disableRequestVerification,omitempty"`
4242
PathRoutes []PathRoute `json:"pathRoutes,omitempty"`
43+
Source string `json:"source,omitempty"`
44+
}
45+
46+
// handle `tlsAcme`/`monitoringPath` from the API and `tls-acme`/`monitoring-path` from .lagoon.yml
47+
// :ugh: legacy stuff
48+
// maybe one day we can produce warnings/deprecation of certain fields but today is not that day
49+
func (r *RouteV2) UnmarshalJSON(data []byte) error {
50+
type TempRouteV2 RouteV2
51+
tr := &struct {
52+
TLSAcme_ *bool `json:"tlsAcme,omitempty"`
53+
MonitoringPath_ *string `json:"monitoringPath,omitempty"`
54+
*TempRouteV2
55+
}{
56+
TempRouteV2: (*TempRouteV2)(r),
57+
}
58+
if err := json.Unmarshal(data, tr); err != nil {
59+
return err
60+
}
61+
if tr.TLSAcme_ != nil {
62+
r.TLSAcme = tr.TLSAcme_
63+
}
64+
if tr.MonitoringPath_ != nil {
65+
r.MonitoringPath = *tr.MonitoringPath_
66+
}
67+
return nil
4368
}
4469

4570
// Ingress represents a Lagoon route.

internal/templating/templates_ingress.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ func GenerateIngressTemplate(
135135
additionalAnnotations["nginx.ingress.kubernetes.io/server-snippet"] = "add_header X-Robots-Tag \"noindex, nofollow\";\n"
136136
}
137137

138+
if route.Source != "" {
139+
additionalLabels["route.lagoon.sh/source"] = strings.ToLower(route.Source)
140+
}
141+
138142
// if idling request verification is in the `.lagoon.yml` and true, add the annotation. this supports production and development environment types
139143
// in the event that production environments support idling properly that option could be available to then
140144
// idle standby environments or production environments generally in opensource lagoon

0 commit comments

Comments
 (0)