Skip to content

The generated controller in v0.19.0 no longer have "add" function so how do I add watches? #3613

@apm-opentt

Description

@apm-opentt

Type of question

Are you asking about community best practices, how to implement a specific feature, or about general context and help around the operator-sdk?
Yes.

Question

What did you do?
A clear and concise description of the steps you took (or insert a code snippet).
I want to migrate my operator code that was based on operator-sdk v0.18.x to v0.19.x. I ran operator-sdk create api command and answered yes create resource and controller.
What did you expect to see?
A clear and concise description of what you expected to happen (or insert a code snippet).
In operator-sdk v0.18.x I can see Add and add functions generated in xxx_controller.go. I added my watch code in the add function to watch and respond to changes in resources. I expected the generated xxx_controller.go using v0.19.x to generate the same Add and add functions so I can migrate my code.

	// TODO(user): Modify this to be the types you create that are owned by the primary resource
	// Watch for changes to secondary resource Pods and requeue the owner TransactionTracking
	err = c.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &h, deploymentPredicate)

What did you see instead? Under which circumstances?
A clear and concise description of what you expected to happen (or insert a code snippet).
The Add and add functions are no longer generated in the xxx_controller.go file.

Environment

  • operator-sdk version: v0.19.0

    insert release or Git SHA here
    operator-sdk version: "v0.19.0", commit: "8e28aca60994c5cb1aec0251b85f0116cc4c9427", kubernetes version: "v1.18.2", go version: "go1.14.4 darwin/amd64"

  • Kubernetes version information:

    insert output of kubectl version here
    Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T23:35:15Z", GoVersion:"go1.14.2", Compiler:"gc", Platform:"darwin/amd64"}

  • Kubernetes cluster kind:

Additional context
Add any other context about the question here.
I search in the v0.19.0 documentation as well as in the release note. I could not find any mention of this change and how to migrate my watch code. Is there existing documentation on how to create watch for v0.19.x?

Metadata

Metadata

Labels

kind/documentationCategorizes issue or PR as related to documentation.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions