Skip to content

Commit

Permalink
Renamed managed props visitor and reviewed description of NewAppPrope…
Browse files Browse the repository at this point in the history
…rtyHandler
  • Loading branch information
dmartinol committed Feb 2, 2024
1 parent 4a743bd commit c842feb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion controllers/profiles/common/mutate_visitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func ServiceMutateVisitor(workflow *operatorapi.SonataFlow) MutateVisitor {
}
}

func UserPropertiesMutateVisitor(ctx context.Context, catalog discovery.ServiceCatalog,
func ManagedPropertiesMutateVisitor(ctx context.Context, catalog discovery.ServiceCatalog,
workflow *operatorapi.SonataFlow, platform *operatorapi.SonataFlowPlatform, userProps *corev1.ConfigMap) MutateVisitor {
return func(object client.Object) controllerutil.MutateFn {
return func() error {
Expand Down
4 changes: 2 additions & 2 deletions controllers/profiles/common/object_creators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Test_ensureWorkflowPropertiesConfigMapMutator(t *testing.T) {

userProps, _ := UserPropsConfigMapCreator(workflow)
userPropsCM := userProps.(*corev1.ConfigMap)
visitor := UserPropertiesMutateVisitor(context.TODO(), nil, workflow, nil, userPropsCM)
visitor := ManagedPropertiesMutateVisitor(context.TODO(), nil, workflow, nil, userPropsCM)
mutateFn := visitor(managedProps)

assert.NoError(t, mutateFn())
Expand Down Expand Up @@ -82,7 +82,7 @@ func Test_ensureWorkflowPropertiesConfigMapMutator_DollarReplacement(t *testing.
userPropsCM := userProps.(*corev1.ConfigMap)
userPropsCM.Data[workflowproj.ApplicationPropertiesFileName] = "mp.messaging.outgoing.kogito_outgoing_stream.url=${kubernetes:services.v1/event-listener}"

mutateVisitorFn := UserPropertiesMutateVisitor(context.TODO(), nil, workflow, nil, userPropsCM)
mutateVisitorFn := ManagedPropertiesMutateVisitor(context.TODO(), nil, workflow, nil, userPropsCM)

err := mutateVisitorFn(managedPropsCM)()
assert.NoError(t, err)
Expand Down
9 changes: 5 additions & 4 deletions controllers/profiles/common/properties/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,14 @@ func (a *appPropertyHandler) addDefaultMutableProperty(name string, value string
}

// NewAppPropertyHandler creates a property handler for a given workflow to execute in the provided platform.
// This handler is intended to build the application properties required by the workflow to execute properly, note that
// the produced properties might vary depending on the platfom, for example, if the job service managed by the platform
// This handler is intended to build the managed application properties required by the workflow to execute properly together with
// the user properties defined in the user-managed ConfigMap.
// Note that the produced properties might vary depending on the platfom, for example, if the job service managed by the platform
// a particular set of properties will be added, etc.
// By default, the following properties are incorporated:
// The set of immutable properties provided by the operator. (user can never change)
// The set of defaultMutableProperties that are provided by the operator, and that the user might overwrite if it changes
// the workflow ConfigMap. This set includes for example the required properties to connect with the data index and the
// The set of defaultMutableProperties that are provided by the operator, and that the user cannot overwrite even if it changes
// the user-managed ConfigMap. This set includes for example the required properties to connect with the data index and the
// job service when any of these services are managed by the platform.
func NewAppPropertyHandler(workflow *operatorapi.SonataFlow, platform *operatorapi.SonataFlowPlatform) (AppPropertyHandler, error) {
handler := &appPropertyHandler{
Expand Down
2 changes: 1 addition & 1 deletion controllers/profiles/dev/states_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (e *ensureRunningWorkflowState) Do(ctx context.Context, workflow *operatora
if err != nil {
return ctrl.Result{Requeue: false}, objs, err
}
managedPropsCM, _, err := e.ensurers.managedPropsConfigMap.Ensure(ctx, workflow, pl, common.UserPropertiesMutateVisitor(ctx, e.StateSupport.Catalog, workflow, pl, userPropsCM.(*corev1.ConfigMap)))
managedPropsCM, _, err := e.ensurers.managedPropsConfigMap.Ensure(ctx, workflow, pl, common.ManagedPropertiesMutateVisitor(ctx, e.StateSupport.Catalog, workflow, pl, userPropsCM.(*corev1.ConfigMap)))
if err != nil {
return ctrl.Result{Requeue: false}, objs, err
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/profiles/prod/deployment_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (d *deploymentReconciler) reconcileWithBuiltImage(ctx context.Context, work
return ctrl.Result{}, nil, err
}
managedPropsCM, _, err := d.ensurers.managedPropsConfigMap.Ensure(ctx, workflow, pl,
common.UserPropertiesMutateVisitor(ctx, d.StateSupport.Catalog, workflow, pl, userPropsCM.(*v1.ConfigMap)))
common.ManagedPropertiesMutateVisitor(ctx, d.StateSupport.Catalog, workflow, pl, userPropsCM.(*v1.ConfigMap)))
if err != nil {
workflow.Status.Manager().MarkFalse(api.RunningConditionType, api.ExternalResourcesNotFoundReason, "Unable to retrieve the managed properties config map")
_, err = d.PerformStatusUpdate(ctx, workflow)
Expand Down

0 comments on commit c842feb

Please sign in to comment.