Skip to content

Commit

Permalink
fix #4167 : Default integrationPlatform created at operator startup d…
Browse files Browse the repository at this point in the history
…ose not honor OPERATOR_ID config
  • Loading branch information
valdar authored and squakez committed Mar 29, 2023
1 parent 7c6bee6 commit f9376ec
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/cmd/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,20 +247,26 @@ func Run(healthPort, monitoringPort int32, leaderElection bool, leaderElectionID

// findOrCreateIntegrationPlatform create default integration platform in operator namespace if not already exists.
func findOrCreateIntegrationPlatform(ctx context.Context, c client.Client, operatorNamespace string) error {
operatorID := defaults.OperatorID()
var platformName string
if defaults.OperatorID() != "" {
platformName = defaults.OperatorID()
if operatorID != "" {
platformName = operatorID
} else {
platformName = platform.DefaultPlatformName
}

if pl, err := kubernetes.GetIntegrationPlatform(ctx, c, platformName, operatorNamespace); pl == nil || k8serrors.IsNotFound(err) {
defaultPlatform := v1.NewIntegrationPlatform(operatorNamespace, platformName)

if defaultPlatform.Labels == nil {
defaultPlatform.Labels = make(map[string]string)
}
defaultPlatform.Labels["camel.apache.org/platform.generated"] = "true"

if operatorID != "" {
defaultPlatform.SetOperatorID(operatorID)
}

if _, err := c.CamelV1().IntegrationPlatforms(operatorNamespace).Create(ctx, &defaultPlatform, metav1.CreateOptions{}); err != nil {
return err
}
Expand Down

0 comments on commit f9376ec

Please sign in to comment.