Skip to content

Commit c210c4c

Browse files
committed
cvo: Add config-file flag
Add a new flag instead of a new environment variable to specify the path of the configuration file. Using env variables has the benefit of better backwards compatibility, for example, specifying not used env variable has no impact. Using a not-implemented flag results in an error. The flag is primarily intended for use in HyperShift, thus, these topics are relevant. In case the feature gate does not get into default, we must not drop the flag out of nowhere, which could cause issues in HyperShift. However, the new API is very small, and it is not likely for this functionality to be dropped along the way. An alternative is to use an env variable before the feature gets into default; however, I do not think this is worth the risk at the moment.
1 parent c410434 commit c210c4c

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

cmd/cluster-version-operator/start.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func init() {
3131

3232
cmd.PersistentFlags().StringVar(&opts.ListenAddr, "listen", opts.ListenAddr, "Address to listen on for metrics")
3333
cmd.PersistentFlags().StringVar(&opts.Kubeconfig, "kubeconfig", opts.Kubeconfig, "Kubeconfig file to access a remote cluster (testing only)")
34+
cmd.PersistentFlags().StringVar(&opts.ConfigFile, "config-file", opts.ConfigFile, "Configuration file for the CVO (represented by a clusterversionoperators.operator.openshift.io manifest file). DevPreview functionality.")
3435
cmd.PersistentFlags().StringVar(&opts.NodeName, "node-name", opts.NodeName, "kubernetes node name CVO is scheduled on.")
3536
cmd.PersistentFlags().BoolVar(&opts.EnableAutoUpdate, "enable-auto-update", opts.EnableAutoUpdate, "Enables the autoupdate controller.")
3637
cmd.PersistentFlags().StringVar(&opts.ReleaseImage, "release-image", opts.ReleaseImage, "The Openshift release image url.")

pkg/cvo/cvo.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ type Operator struct {
183183
// always be implicitly enabled.
184184
alwaysEnableCapabilities []configv1.ClusterVersionCapability
185185

186+
// configFile is a path to a ClusterVersionOperator configuration file
187+
configFile string
188+
186189
// configuration, if enabled, reconciles the ClusterVersionOperator configuration.
187190
configuration *configuration.ClusterVersionOperatorConfiguration
188191
}
@@ -209,6 +212,7 @@ func New(
209212
promqlTarget clusterconditions.PromQLTarget,
210213
injectClusterIdIntoPromQL bool,
211214
updateService string,
215+
configFile string,
212216
alwaysEnableCapabilities []configv1.ClusterVersionCapability,
213217
) (*Operator, error) {
214218
eventBroadcaster := record.NewBroadcaster()
@@ -237,6 +241,7 @@ func New(
237241
availableUpdatesQueue: workqueue.NewTypedRateLimitingQueueWithConfig[any](workqueue.DefaultTypedControllerRateLimiter[any](), workqueue.TypedRateLimitingQueueConfig[any]{Name: "availableupdates"}),
238242
upgradeableQueue: workqueue.NewTypedRateLimitingQueueWithConfig[any](workqueue.DefaultTypedControllerRateLimiter[any](), workqueue.TypedRateLimitingQueueConfig[any]{Name: "upgradeable"}),
239243

244+
configFile: configFile,
240245
hypershift: hypershift,
241246
exclude: exclude,
242247
clusterProfile: clusterProfile,

pkg/start/start.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type Options struct {
6464
ServingKeyFile string
6565

6666
Kubeconfig string
67+
ConfigFile string
6768
NodeName string
6869
ListenAddr string
6970

@@ -517,6 +518,7 @@ func (o *Options) NewControllerContext(cb *ClientBuilder) (*Context, error) {
517518
o.PromQLTarget,
518519
o.InjectClusterIdIntoPromQL,
519520
o.UpdateService,
521+
o.ConfigFile,
520522
stringsToCapabilities(o.AlwaysEnableCapabilities),
521523
)
522524
if err != nil {

0 commit comments

Comments
 (0)