fix: create response header middleware only when configuration ask for it
This commit is contained in:
parent
2e7da70a48
commit
1adb18e186
@ -212,6 +212,7 @@ func createMiddlewareAddResponseHeader(
|
|||||||
namespace *corev1.Namespace,
|
namespace *corev1.Namespace,
|
||||||
application *Application,
|
application *Application,
|
||||||
) (*traefikv1alpha1.Middleware, error) {
|
) (*traefikv1alpha1.Middleware, error) {
|
||||||
|
if configuration.ResponseHeaders != nil {
|
||||||
middlewareName := fmt.Sprintf("%s-response-header-middleware", configuration.Name)
|
middlewareName := fmt.Sprintf("%s-response-header-middleware", configuration.Name)
|
||||||
return traefikv1alpha1.NewMiddleware(ctx, middlewareName, &traefikv1alpha1.MiddlewareArgs{
|
return traefikv1alpha1.NewMiddleware(ctx, middlewareName, &traefikv1alpha1.MiddlewareArgs{
|
||||||
Metadata: &metav1.ObjectMetaArgs{
|
Metadata: &metav1.ObjectMetaArgs{
|
||||||
@ -226,13 +227,22 @@ func createMiddlewareAddResponseHeader(
|
|||||||
},
|
},
|
||||||
}, pulumi.Parent(application))
|
}, pulumi.Parent(application))
|
||||||
}
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func createIngress(ctx *pulumi.Context, configuration *configuration, namespace *corev1.Namespace, certificate *v1.Certificate, servicesConfiguration []ingressConfiguration, application *Application, responseHeaderMiddleware *traefikv1alpha1.Middleware) (*netv1.Ingress, error) {
|
func createIngress(ctx *pulumi.Context, configuration *configuration, namespace *corev1.Namespace, certificate *v1.Certificate, servicesConfiguration []ingressConfiguration, application *Application, responseHeaderMiddleware *traefikv1alpha1.Middleware) (*netv1.Ingress, error) {
|
||||||
if configuration.ShouldCreateIngress {
|
if configuration.ShouldCreateIngress {
|
||||||
host := pulumi.String(configuration.Dns)
|
host := pulumi.String(configuration.Dns)
|
||||||
middlewares := pulumi.All(namespace.Metadata.Name().Elem(), responseHeaderMiddleware.Metadata.Name().Elem()).ApplyT(func(args []interface{}) string {
|
|
||||||
|
var middlewares pulumi.StringInput
|
||||||
|
if configuration.ResponseHeaders != nil {
|
||||||
|
middlewares = pulumi.All(namespace.Metadata.Name().Elem(), responseHeaderMiddleware.Metadata.Name().Elem()).ApplyT(func(args []interface{}) string {
|
||||||
return fmt.Sprintf("kube-ingress-gzip-compress@kubernetescrd,%s-%s@kubernetescrd", args[0], args[1])
|
return fmt.Sprintf("kube-ingress-gzip-compress@kubernetescrd,%s-%s@kubernetescrd", args[0], args[1])
|
||||||
}).(pulumi.StringOutput)
|
}).(pulumi.StringOutput)
|
||||||
|
} else {
|
||||||
|
middlewares = pulumi.String("kube-ingress-gzip-compress@kubernetescrd")
|
||||||
|
}
|
||||||
|
|
||||||
ingressAnnotations := pulumi.StringMap{
|
ingressAnnotations := pulumi.StringMap{
|
||||||
"traefik.ingress.kubernetes.io/router.middlewares": middlewares,
|
"traefik.ingress.kubernetes.io/router.middlewares": middlewares,
|
||||||
"traefik.ingress.kubernetes.io/router.entrypoints": pulumi.String("websecure"),
|
"traefik.ingress.kubernetes.io/router.entrypoints": pulumi.String("websecure"),
|
||||||
|
Loading…
Reference in New Issue
Block a user