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 flags to override hardcoded images #449

Merged
merged 4 commits into from
Oct 7, 2021
Merged
Changes from 2 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
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ func main() {
// Add flags related to this operator
var metricsAddr string
var enableLeaderElection bool
var collectorImage string
var targetAllocatorImage string
pflag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
pflag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
pflag.StringVar(&collectorImage, "collector-image", "", "The default OpenTelemetry collector image. This image is used when no image is specified in the CustomResource.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this have a default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default images are hardcoded in the config package

o.collectorImage = fmt.Sprintf("otel/opentelemetry-collector:%s", o.version.OpenTelemetryCollector)
.

The config package hardcodes image name and sets the tag based on the version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made some changes and moved the logic to main. It looks better now and cleaner.

pflag.StringVar(&targetAllocatorImage, "target-allocator-image", "", "The default OpenTelemetry target allocator image. This image is used when no image is specified in the CustomResource.")

// Add flags related to this operator
v := version.Get()
Expand Down Expand Up @@ -95,6 +99,8 @@ func main() {
cfg := config.New(
config.WithLogger(ctrl.Log.WithName("config")),
config.WithVersion(v),
config.WithCollectorImage(collectorImage),
config.WithTargetAllocatorImage(targetAllocatorImage),
config.WithAutoDetect(ad),
)

Expand Down