diff --git a/pkg/openstack/horizon.go b/pkg/openstack/horizon.go index f450bca21..d43080ab8 100644 --- a/pkg/openstack/horizon.go +++ b/pkg/openstack/horizon.go @@ -22,6 +22,15 @@ import ( // ReconcileHorizon - func ReconcileHorizon(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion, helper *helper.Helper) (ctrl.Result, error) { + const ( + HorizonHSTSHeaderAnnotation string = "haproxy.router.openshift.io/hsts_header" + HorizonHSTSHeaderAnnotationValue string = "max-age=31536000;includeSubDomains;preload" + ) + + var HSTSAnnotation map[string]string = map[string]string{ + HorizonHSTSHeaderAnnotation: HorizonHSTSHeaderAnnotationValue, + } + horizon := &horizonv1.Horizon{ ObjectMeta: metav1.ObjectMeta{ Name: "horizon", @@ -73,6 +82,9 @@ func ReconcileHorizon(ctx context.Context, instance *corev1beta1.OpenStackContro return ctrl.Result{}, err } + // Set HSTS Headers for Horizon Route + instance.Spec.Horizon.APIOverride.Route.Annotations = HSTSAnnotation + // make sure to get to EndpointConfig when all service got created if len(svcs.Items) == 1 { endpointDetails, ctrlResult, err := EnsureEndpointConfig( @@ -117,7 +129,6 @@ func ReconcileHorizon(ctx context.Context, instance *corev1beta1.OpenStackContro } return nil }) - if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( corev1beta1.OpenStackControlPlaneHorizonReadyCondition,