Skip to content

Commit

Permalink
SRVLOGIC-390: Adjust cors configuration for the dev profile deploymen…
Browse files Browse the repository at this point in the history
…ts, and JS and DI deployments
  • Loading branch information
wmedvede committed Sep 20, 2024
1 parent f6fb723 commit 1d54079
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 148 deletions.
19 changes: 1 addition & 18 deletions controllers/platform/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,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 @@ -346,16 +338,7 @@ func (j JobServiceHandler) GetLocalServiceBaseUrl() string {
}

func (j JobServiceHandler) GetEnvironmentVariables() []corev1.EnvVar {
return []corev1.EnvVar{
{
Name: "QUARKUS_HTTP_CORS",
Value: "true",
},
{
Name: "QUARKUS_HTTP_CORS_ORIGINS",
Value: "/.*/",
},
}
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}"
KnativeEventingBrokerDefault = "default"
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 1d54079

Please sign in to comment.