Skip to content

chore: simplify init functions#863

Merged
philipgough merged 1 commit intoobservatorium:mainfrom
simonpasquier:fix-dangerous-init
Jan 15, 2026
Merged

chore: simplify init functions#863
philipgough merged 1 commit intoobservatorium:mainfrom
simonpasquier:fix-dangerous-init

Conversation

@simonpasquier
Copy link
Copy Markdown
Contributor

This commit removes the init() function which initializes the providerFactories variable. This mechanism is fragile because it assumes that no other init() function will call onboardNewProvider() before the map is initialized. In practice the Go compiler evaluates the init() functions from a single package in lexical filename order meaning that we could have a Go file evaluated before
authentication/authentication.go in the future.

Copy link
Copy Markdown
Member

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

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

LGTM!

@simonpasquier
Copy link
Copy Markdown
Contributor Author

The generate failure is being addressed in #864

This commit removes the init() function which initializes the
`providerFactories` variable. This mechanism is fragile because it
assumes that no other init() function will call `onboardNewProvider()`
before the map is initialized. In practice the Go compiler evaluates the
init() functions from a single package in lexical filename order meaning
that we could have a Go file evaluated before
`authentication/authentication.go` in the future.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@philipgough philipgough merged commit 9df2d7f into observatorium:main Jan 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants