Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 14 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/tools/record"
"k8s.io/utils/ptr"
ctrlruntime "sigs.k8s.io/controller-runtime"
ctrlcache "sigs.k8s.io/controller-runtime/pkg/cache"
Expand All @@ -41,6 +42,7 @@ import (
gotkacl "github.com/fluxcd/pkg/runtime/acl"
gotkclient "github.com/fluxcd/pkg/runtime/client"
gotkctrl "github.com/fluxcd/pkg/runtime/controller"
gotkevents "github.com/fluxcd/pkg/runtime/events"
gotkfeatures "github.com/fluxcd/pkg/runtime/features"
gotkjitter "github.com/fluxcd/pkg/runtime/jitter"
gotkelection "github.com/fluxcd/pkg/runtime/leaderelection"
Expand Down Expand Up @@ -184,13 +186,15 @@ func main() {
// check will continue to fail until this controller instance is elected leader.
gotkprobes.SetupChecks(mgr, setupLog)

eventRecorder := mustSetupEventRecorder(mgr, eventsAddr, controllerName)

// Register the ArtifactGenerator controller with the manager.
if err = (&controller.ArtifactGeneratorReconciler{
ControllerName: controllerName,
Client: mgr.GetClient(),
APIReader: mgr.GetAPIReader(),
Scheme: mgr.GetScheme(),
EventRecorder: mgr.GetEventRecorderFor(controllerName),
EventRecorder: eventRecorder,
Comment thread
matheuscscp marked this conversation as resolved.
Storage: artifactStorage,
ArtifactFetchRetries: httpRetry,
DependencyRequeueInterval: requeueDependency,
Expand Down Expand Up @@ -225,3 +229,12 @@ func main() {
os.Exit(1)
}
}

func mustSetupEventRecorder(mgr ctrlruntime.Manager, eventsAddr, controllerName string) record.EventRecorder {
eventRecorder, err := gotkevents.NewRecorder(mgr, ctrlruntime.Log, eventsAddr, controllerName)
if err != nil {
setupLog.Error(err, "unable to create event recorder")
os.Exit(1)
}
return eventRecorder
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ require (
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
github.com/fluxcd/cli-utils v0.37.1-flux.1 // indirect
github.com/fluxcd/pkg/apis/acl v0.9.0 // indirect
github.com/fluxcd/pkg/apis/event v0.22.0 // indirect
github.com/fluxcd/pkg/lockedfile v0.7.0 // indirect
github.com/fluxcd/pkg/oci v0.59.0 // indirect
github.com/fluxcd/pkg/sourceignore v0.16.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ github.com/fluxcd/cli-utils v0.37.1-flux.1 h1:WnG2mHxCPZMj/soIq/S/1zvbrGCJN3GJGb
github.com/fluxcd/cli-utils v0.37.1-flux.1/go.mod h1:aND5wX3LuTFtB7eUT7vsWr8mmxRVSPR2Wkvbn0SqPfw=
github.com/fluxcd/pkg/apis/acl v0.9.0 h1:wBpgsKT+jcyZEcM//OmZr9RiF8klL3ebrDp2u2ThsnA=
github.com/fluxcd/pkg/apis/acl v0.9.0/go.mod h1:TttNS+gocsGLwnvmgVi3/Yscwqrjc17+vhgYfqkfrV4=
github.com/fluxcd/pkg/apis/event v0.22.0 h1:nCW0TnneMnscSnj9NlaSKcvyC+436MbY1GyKn/4YnII=
github.com/fluxcd/pkg/apis/event v0.22.0/go.mod h1:Hoi4DejaNKVahGkRXqGBjT9h1aKmhc7RCYcsgoTieqc=
github.com/fluxcd/pkg/apis/meta v1.25.0 h1:fmZgMoe7yITGfhFqdOs7w2GOu3Y/2Vvz4+4p/eay3eA=
github.com/fluxcd/pkg/apis/meta v1.25.0/go.mod h1:1D92RqAet0/n/cH5S0khBXweirHWkw9rCO0V4NCY6xc=
github.com/fluxcd/pkg/artifact v0.7.0 h1:gACHm8Xn8K9RcZ+TuJKCYf3Av3Le3iBW7tpnxVDuHmw=
Expand Down