Skip to content

Commit

Permalink
feat: support for unidler request verfication disabling (#332)
Browse files Browse the repository at this point in the history
* feat: support for unidler request verfication disabling

* test: update tests for disable request verifications
  • Loading branch information
shreddedbacon authored Jul 14, 2024
1 parent 5923c75 commit 017d8e3
Show file tree
Hide file tree
Showing 72 changed files with 678 additions and 313 deletions.
12 changes: 12 additions & 0 deletions cmd/template_autogen_ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,18 @@ func TestAutogeneratedIngressGeneration(t *testing.T) {
emptyDir: true,
want: "",
},
{
name: "test27 autogenerated route unidler request verification disable",
args: testdata.GetSeedData(
testdata.TestData{
ProjectName: "example-project",
EnvironmentName: "main",
Branch: "main",
LagoonYAML: "../internal/testdata/node/lagoon.unidler.yml",
}, true),
templatePath: "testdata/output",
want: "../internal/testdata/node/autogen-templates/ingress-15",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
12 changes: 12 additions & 0 deletions cmd/template_ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,18 @@ func TestTemplateRoutes(t *testing.T) {
wantErr: true,
wantErrMsg: "this environment requests 2 custom routes, this would exceed the route quota of 1",
},
{
name: "test24 unidler request verification disable",
args: testdata.GetSeedData(
testdata.TestData{
ProjectName: "example-project",
EnvironmentName: "main",
Branch: "main",
LagoonYAML: "../internal/testdata/node/lagoon.unidler.yml",
}, true),
templatePath: "testdata/output",
want: "../internal/testdata/node/ingress-templates/ingress-23",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
57 changes: 29 additions & 28 deletions internal/generator/buildvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,35 @@ type MonitoringConfig struct {

// ServiceValues is the values for a specific service used by a lagoon build
type ServiceValues struct {
Name string `json:"name"` // this is the actual compose service name
OverrideName string `json:"overrideName"` // if an override name is provided, use it
Type string `json:"type"`
AutogeneratedRoutesEnabled bool `json:"autogeneratedRoutesEnabled"`
AutogeneratedRoutesTLSAcme bool `json:"autogeneratedRoutesTLSAcme"`
AutogeneratedRouteDomain string `json:"autogeneratedRouteDomain"`
ShortAutogeneratedRouteDomain string `json:"shortAutogeneratedRouteDomain"`
NativeCronjobs map[string]CronjobValues `json:"nativeCronjobs"`
InPodCronjobs string `json:"inPodCronjobs"`
ImageName string `json:"imageName"`
DeploymentServiceType string `json:"deploymentServiecType"`
ServicePort int32 `json:"servicePort,omitempty"`
PersistentVolumePath string `json:"persistentVolumePath,omitempty"`
PersistentVolumeName string `json:"persistentVolumeName,omitempty"`
PersistentVolumeSize string `json:"persistentVolumeSize,omitempty"`
UseSpotInstances bool `json:"useSpot"`
NodeSelectors *map[string]string `json:"nodeSelectors"`
Tolerations *[]corev1.Toleration `json:"tolerations"`
Affinity *corev1.Affinity `json:"affinity"`
CronjobUseSpotInstances bool `json:"cronjobUseSpot"`
CronjobNodeSelectors *map[string]string `json:"cronjobNodeSelectors"`
CronjobTolerations *[]corev1.Toleration `json:"cronjobTolerations"`
CronjobAffinity *corev1.Affinity `json:"cronjobAffinity"`
DBaasReadReplica bool `json:"dBaasReadReplica"`
DBaaSEnvironment string `json:"dbaasEnvironment"`
IsDBaaS bool `json:"isDBaaS"`
IsSingle bool `json:"isSingle"`
BackupsEnabled bool `json:"backupsEnabled"`
Name string `json:"name"` // this is the actual compose service name
OverrideName string `json:"overrideName"` // if an override name is provided, use it
Type string `json:"type"`
AutogeneratedRoutesEnabled bool `json:"autogeneratedRoutesEnabled"`
AutogeneratedRoutesTLSAcme bool `json:"autogeneratedRoutesTLSAcme"`
AutogeneratedRoutesRequestVerification bool `json:"autogeneratedRoutesRequestVerification"`
AutogeneratedRouteDomain string `json:"autogeneratedRouteDomain"`
ShortAutogeneratedRouteDomain string `json:"shortAutogeneratedRouteDomain"`
NativeCronjobs map[string]CronjobValues `json:"nativeCronjobs"`
InPodCronjobs string `json:"inPodCronjobs"`
ImageName string `json:"imageName"`
DeploymentServiceType string `json:"deploymentServiecType"`
ServicePort int32 `json:"servicePort,omitempty"`
PersistentVolumePath string `json:"persistentVolumePath,omitempty"`
PersistentVolumeName string `json:"persistentVolumeName,omitempty"`
PersistentVolumeSize string `json:"persistentVolumeSize,omitempty"`
UseSpotInstances bool `json:"useSpot"`
NodeSelectors *map[string]string `json:"nodeSelectors"`
Tolerations *[]corev1.Toleration `json:"tolerations"`
Affinity *corev1.Affinity `json:"affinity"`
CronjobUseSpotInstances bool `json:"cronjobUseSpot"`
CronjobNodeSelectors *map[string]string `json:"cronjobNodeSelectors"`
CronjobTolerations *[]corev1.Toleration `json:"cronjobTolerations"`
CronjobAffinity *corev1.Affinity `json:"cronjobAffinity"`
DBaasReadReplica bool `json:"dBaasReadReplica"`
DBaaSEnvironment string `json:"dbaasEnvironment"`
IsDBaaS bool `json:"isDBaaS"`
IsSingle bool `json:"isSingle"`
BackupsEnabled bool `json:"backupsEnabled"`
}

// CronjobValues is the values for cronjobs
Expand Down
15 changes: 8 additions & 7 deletions internal/generator/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,14 @@ func generateAutogenRoutes(
"lagoon.sh/service": serviceOverrideName,
"lagoon.sh/service-type": service.Type,
},
IngressClass: ingressClass,
Autogenerated: true,
LagoonService: serviceOverrideName,
IngressName: serviceOverrideName,
ComposeService: service.Name,
Insecure: &insecure,
AlternativeNames: alternativeNames,
IngressClass: ingressClass,
Autogenerated: true,
LagoonService: serviceOverrideName,
IngressName: serviceOverrideName,
ComposeService: service.Name,
Insecure: &insecure,
AlternativeNames: alternativeNames,
RequestVerification: helpers.BoolPtr(service.AutogeneratedRoutesRequestVerification),
}
autogenRoutes.Routes = append(autogenRoutes.Routes, autogenRoute)
}
Expand Down
Loading

0 comments on commit 017d8e3

Please sign in to comment.