Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add creating event recorder for controller in creating resource #69

Merged
merged 1 commit into from
Apr 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/kubebuilder/create/resource/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (

"github.com/kubernetes-sigs/kubebuilder/pkg/controller"
"github.com/kubernetes-sigs/kubebuilder/pkg/controller/types"
"k8s.io/client-go/tools/record"

{{.Group}}{{.Version}}client "{{.Repo}}/pkg/client/clientset/versioned/typed/{{.Group}}/{{.Version}}"
{{.Group}}{{.Version}}lister "{{.Repo}}/pkg/client/listers/{{.Group}}/{{.Version}}"
Expand All @@ -64,6 +65,9 @@ type {{.Kind}}Controller struct {
// INSERT ADDITIONAL FIELDS HERE
{{lower .Kind}}Lister {{.Group}}{{.Version}}lister.{{.Kind}}Lister
{{lower .Kind}}client {{.Group}}{{.Version}}client.{{title .Group}}{{title .Version}}Interface
// recorder is an event recorder for recording Event resources to the
// Kubernetes API.
{{lower .Kind}}recorder record.EventRecorder
}

// ProvideController provides a controller that will be run at startup. Kubebuilder will use codegeneration
Expand All @@ -73,6 +77,7 @@ func ProvideController(arguments args.InjectArgs) (*controller.GenericController
bc := &{{.Kind}}Controller{
{{lower .Kind}}Lister: arguments.ControllerManager.GetInformerProvider(&{{.Group}}{{.Version}}.{{.Kind}}{}).({{.Group}}{{.Version}}informer.{{.Kind}}Informer).Lister(),
{{lower .Kind}}client: arguments.Clientset.{{title .Group}}{{title .Version}}(),
{{lower .Kind}}recorder: arguments.CreateRecorder("{{.Kind}}Controller"),
}

// Create a new controller that will call {{.Kind}}Controller.Reconcile on changes to {{.Kind}}s
Expand Down