Skip to content

Commit

Permalink
Added scoped namespaces to manager options
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhuynh2 authored and milero committed Mar 23, 2022
1 parent a5defc0 commit 4ea79b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/wordpress-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,21 @@ func main() {
os.Exit(genericErrorExitCode)
}

// Create a new Cmd to provide shared dependencies and start components
mgr, err := manager.New(cfg, manager.Options{
opt := manager.Options{
LeaderElection: options.LeaderElection,
LeaderElectionID: options.LeaderElectionID,
LeaderElectionNamespace: options.LeaderElectionNamespace,
LeaderElectionResourceLock: "leases",
MetricsBindAddress: options.MetricsBindAddress,
HealthProbeBindAddress: options.HealthProbeBindAddress,
})
}

if options.ScopedNamespace != "" {
opt.Namespace = options.ScopedNamespace
}

// Create a new Cmd to provide shared dependencies and start components
mgr, err := manager.New(cfg, opt)
if err != nil {
setupLog.Error(err, "unable to create a new manager")
os.Exit(genericErrorExitCode)
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ var (

// HealthProbeBindAddress is the TCP address that the controller should bind to for serving health probes.
HealthProbeBindAddress = ":8081"

ScopedNamespace = os.Getenv("SCOPED_NAMESPACE")
)

func namespace() string {
Expand Down

0 comments on commit 4ea79b5

Please sign in to comment.