Skip to content

Commit 351088c

Browse files
committed
feat: add environment flag to shared options and log its value in run commands
1 parent d27bcba commit 351088c

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

cmd/usage-operator/app/app.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ func NewUsageOperatorCommand(ctx context.Context) *cobra.Command {
3333
}
3434

3535
type RawSharedOptions struct {
36-
DryRun bool `json:"dry-run"`
36+
Environment string `json:"environment"`
37+
DryRun bool `json:"dry-run"`
3738
}
3839

3940
type SharedOptions struct {
@@ -48,6 +49,7 @@ func (o *SharedOptions) AddPersistentFlags(cmd *cobra.Command) {
4849
logging.InitFlags(cmd.PersistentFlags())
4950
// misc
5051
cmd.PersistentFlags().BoolVar(&o.DryRun, "dry-run", false, "If set, the command aborts after evaluation of the given flags.")
52+
cmd.PersistentFlags().StringVar(&o.Environment, "environment", "", "Environment name. Required. This is used to distinguish between different environments that are watching the same Onboarding cluster. Must be globally unique.")
5153
}
5254

5355
func (o *SharedOptions) Complete() error {

cmd/usage-operator/app/init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func (o *InitOptions) Complete(ctx context.Context) error {
5858

5959
func (o *InitOptions) Run(ctx context.Context) error {
6060
log := o.Log.WithName("main")
61+
log.Info("Environment", "value", o.Environment)
6162

6263
// apply CRDs
6364
crdManager := crdutil.NewCRDManager(apiconst.ClusterLabel, crds.CRDs)

cmd/usage-operator/app/run.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ func (o *RunOptions) PrintCompletedOptions(cmd *cobra.Command) {
239239

240240
func (o *RunOptions) Run(ctx context.Context) error {
241241
setupLog = o.Log.WithName("setup")
242+
setupLog.Info("Environment", "value", o.Environment)
242243

243244
webhookServer := webhook.NewServer(webhook.Options{
244245
TLSOpts: o.WebhookTLSOpts,

0 commit comments

Comments
 (0)