Skip to content

Conversation

komish
Copy link
Contributor

@komish komish commented Aug 5, 2020

Signed-off-by: Jose R. Gonzalez [email protected]

Description of the change:

With v1.0, the scaffolding creates a manager with some default options using "sigs.k8s.io/controller-runtime".NewManager() (changed from "sigs.k8s.io/controller-runtime/pkg/manager".New()) This seems to be accounted for in other places in the docs.

Motivation for the change:

Thought it might help with consistency across the documentation. Not sure if the Tutorial in its current form was going to stick around but figured I'd send this PR either way and we just close if it not.

Checklist

If the pull request includes user-facing changes, extra documentation is required:

Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

good catcher 👍

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2020
@camilamacedo86 camilamacedo86 added this to the v1.0.0 milestone Aug 5, 2020
jmrodri
jmrodri previously approved these changes Aug 5, 2020
Copy link
Member

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no controller-runtime.pkg/manager.NewManager() constructor, perhaps you're thinking of controller-runtime.NewManager()? If so, we need to also update the import alias from manager to ctrl, which is what main.go uses.

@jmrodri jmrodri dismissed their stale review August 5, 2020 21:56

Canceling my review as @estroz pointed out, there's a problem here.

@camilamacedo86
Copy link
Contributor

Hi @estroz,

The first comment shows a little confuse. But the change here is just to fix the constructor in the examples to be consistent with the new code that is scaffolded. Replace manager.New With manager.NewManager.

@komish
Copy link
Contributor Author

komish commented Aug 5, 2020

I'm seeing the following import in a main.go from operator-sdk 0.18 (i.e. "old state")

import (
// ... other imports here
	"sigs.k8s.io/controller-runtime/pkg/manager"
)

I see it used to create a manager like so:

	// Create a new manager to provide shared dependencies and start components
	mgr, err := manager.New(cfg, options)
	if err != nil {
		log.Error(err, "")
		os.Exit(1)
	}

New state does refer to the import of controller-runtime as ctrl and ctrl.NewManager() used to get the manager unless I'm misunderstanding. Either way - I can update this to ctrl in the docs as well if that's the desired outcome @estroz is detailing.

Can you confirm? If so, I'll push straight away.

The Manager can restrict the namespace that all controllers will watch for resources:
```Go
mgr, err := manager.New(cfg, manager.Options{Namespace: namespace})
mgr, err := manager.NewManager(cfg, manager.Options{Namespace: namespace})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mgr, err := manager.NewManager(cfg, manager.Options{Namespace: namespace})
mgr, err := ctrl.NewManager(cfg, manager.Options{Namespace: namespace})

By default this will be the namespace that the operator is running in. To watch all namespaces leave the namespace option empty:
```Go
mgr, err := manager.New(cfg, manager.Options{Namespace: ""})
mgr, err := manager.NewManager(cfg, manager.Options{Namespace: ""})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mgr, err := manager.NewManager(cfg, manager.Options{Namespace: ""})
mgr, err := ctrl.NewManager(cfg, manager.Options{Namespace: ""})

var namespaces []string // List of Namespaces
// Create a new Cmd to provide shared dependencies and start components
mgr, err := manager.New(cfg, manager.Options{
mgr, err := manager.NewManager(cfg, manager.Options{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mgr, err := manager.NewManager(cfg, manager.Options{
mgr, err := ctrl.NewManager(cfg, manager.Options{

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Updating and pushing momentarily.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2020
Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2020
@komish
Copy link
Contributor Author

komish commented Aug 5, 2020

Should be good to go!

@jmrodri jmrodri merged commit c9348b5 into operator-framework:master Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants