Skip to content

deprecate OPERATOR_NAME environment variable #3361

@camilamacedo86

Description

@camilamacedo86

We need to deprecate: OPERATOR_NAME environment variable is an artifact of the legacy operator-sdk project scaffolding and use --leader-election-id should be used instead.

The OperatorName is the name of the directory of the operator by default which in go we set the info in the repo attribute in the PROJECT file. However, if we will or not use the repo for Ansible/Helm is an ongoing discussion. See: #3341 (comment)

Example:

	if operatorName, found := os.LookupEnv("OPERATOR_NAME"); found {
		setupLog.Info("environment variable OPERATOR_NAME has been deprecated, use --leader-election-id instead.")
		if pflag.Lookup("leader-election-id").Changed {
			setupLog.Info("ignoring OPERATOR_NAME environment variable since --leader-election-id is set")
		} else {
			leaderElectionID = operatorName
		}
	}

	options := ctrl.Options{
		MetricsBindAddress:      metricsAddr,
		LeaderElection:          enableLeaderElection,
		LeaderElectionID:        leaderElectionID,
		LeaderElectionNamespace: leaderElectionNamespace,
		NewClient:               manager.NewDelegatingClientFunc(),
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    kubebuilder-integrationRelates to rewriting the SDK in Kubebuilder plugin formlanguage/ansibleIssue is related to an Ansible operator projectlanguage/helmIssue is related to a Helm operator project

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions