Skip to content

Commit

Permalink
kie-kogito-serverless-operator-536: Adjust cors configuration for the…
Browse files Browse the repository at this point in the history
… dev profile deployments, and JS and DI deployments
  • Loading branch information
wmedvede committed Sep 20, 2024
1 parent e91495d commit 35c2df9
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 149 deletions.
21 changes: 2 additions & 19 deletions controllers/platform/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,6 @@ func (d *DataIndexHandler) GetEnvironmentVariables() []corev1.EnvVar {
Name: "KOGITO_DATA_INDEX_QUARKUS_PROFILE",
Value: "http-events-support",
},
{
Name: "QUARKUS_HTTP_CORS",
Value: "true",
},
{
Name: "QUARKUS_HTTP_CORS_ORIGINS",
Value: "/.*/",
},
}
}

Expand Down Expand Up @@ -372,17 +364,8 @@ func (j *JobServiceHandler) GetLocalServiceBaseUrl() string {
return GenerateServiceURL(constants.DefaultHTTPProtocol, j.platform.Namespace, j.GetServiceName())
}

func (j *JobServiceHandler) GetEnvironmentVariables() []corev1.EnvVar {
return []corev1.EnvVar{
{
Name: "QUARKUS_HTTP_CORS",
Value: "true",
},
{
Name: "QUARKUS_HTTP_CORS_ORIGINS",
Value: "/.*/",
},
}
func (j JobServiceHandler) GetEnvironmentVariables() []corev1.EnvVar {
return []corev1.EnvVar{}
}

func (j *JobServiceHandler) GetPodResourceRequirements() corev1.ResourceRequirements {
Expand Down
1 change: 1 addition & 0 deletions controllers/profiles/common/constants/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ const (
KnativeHealthEnabled = "org.kie.kogito.addons.knative.eventing.health-enabled"
KnativeInjectedEnvVar = "${K_SINK}"
TriggerFinalizer = "trigger-deletion"
QuarkusDevUICorsEnabled = "quarkus.dev-ui.cors.enabled"
)
8 changes: 8 additions & 0 deletions controllers/profiles/common/properties/managed.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"context"
"fmt"

"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles/common/persistence"

"github.com/apache/incubator-kie-kogito-serverless-operator/utils"
Expand Down Expand Up @@ -148,6 +149,9 @@ func NewManagedPropertyHandler(workflow *operatorapi.SonataFlow, platform *opera
platform: platform,
}
props := properties.NewProperties()
if profiles.IsDevProfile(workflow) {
setDevProfileProperties(props)
}
props.Set(constants.KogitoUserTasksEventsEnabled, "false")
if platform != nil {
p, err := resolvePlatformWorkflowProperties(platform)
Expand Down Expand Up @@ -183,6 +187,10 @@ func NewManagedPropertyHandler(workflow *operatorapi.SonataFlow, platform *opera
return handler.withKogitoServiceUrl(), nil
}

func setDevProfileProperties(props *properties.Properties) {
props.Set(fmt.Sprintf("%%dev.%s", constants.QuarkusDevUICorsEnabled), "false")
}

// ApplicationManagedProperties immutable default application properties that can be used with any workflow based on Quarkus.
// Alias for NewManagedPropertyHandler(workflow).Build()
func ApplicationManagedProperties(workflow *operatorapi.SonataFlow, platform *operatorapi.SonataFlowPlatform) (string, error) {
Expand Down
Loading

0 comments on commit 35c2df9

Please sign in to comment.