Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 16 additions & 2 deletions cmd/cluster-cloud-controller-manager-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.

_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/klog/klogr"
"k8s.io/klog/v2"
Expand All @@ -49,8 +50,10 @@ var (
)

const (
defaultManagedNamespace = "openshift-cloud-controller-manager"
defaultImagesLocation = "/etc/cloud-controller-manager-config/images.json"
defaultManagedNamespace = "openshift-cloud-controller-manager"
defaultImagesLocation = "/etc/cloud-controller-manager-config/images.json"
releaseVersionEnvVariableName = "RELEASE_VERSION"
unknownVersionValue = "unknown"
)

func init() {
Expand Down Expand Up @@ -133,6 +136,8 @@ func main() {
if err = (&controllers.CloudOperatorReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("cloud-controller-manager-operator"),
ReleaseVersion: getReleaseVersion(),
ManagedNamespace: *managedNamespace,
ImagesFile: *imagesFile,
}).SetupWithManager(mgr); err != nil {
Expand All @@ -156,3 +161,12 @@ func main() {
os.Exit(1)
}
}

func getReleaseVersion() string {
releaseVersion := os.Getenv(releaseVersionEnvVariableName)
if len(releaseVersion) == 0 {
releaseVersion = unknownVersionValue
klog.Infof("%s environment variable is missing, defaulting to %q", releaseVersionEnvVariableName, unknownVersionValue)
}
return releaseVersion
}
3 changes: 2 additions & 1 deletion controllers/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ObjectWatcher interface {

func NewObjectWatcher(opts WatcherOptions) (ObjectWatcher, error) {
if opts.Cache == nil {
return nil, errors.New("Cache is required")
return nil, errors.New("cache is required")
}

// Use the default Kubernetes Scheme if unset
Expand Down Expand Up @@ -128,6 +128,7 @@ func (e *eventToChannelHandler) queueEventForObject(oldObj, newObj interface{})
}
if new.GetName() != e.name {
// Not the right object, skip
return
}

if oldObj != nil {
Expand Down
Loading