-
Notifications
You must be signed in to change notification settings - Fork 84
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
oci: Use controller-runtime pkg/log specifically #646
Conversation
This helps avoid importing the controller-runtime pkg/client/config package which has a flag initialization for "kubeconfig". This results in all the users of the oci package to also have the flag initialized in their applications. The usage of controller-runtime in oci package is just for logging. Importing the pkg/log package specifically helps avoid importing the client config which sets the flag. Signed-off-by: Sunny <darkowlzz@protonmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks. I was able to verify that it works as expected when imported.
@darkowlzz we should add a test case that prevents a regression here. |
@makkes we can add a test that imports this package and checks for flags. But this is a very general problem for all the packages that use controller-runtime. Such a test will have to be added to all the other packages too to make sure they never import the root level controller-runtime package accidentally. I'm not sure how feasible that is. Once the upstream removes the flag initialization, all these work would become unnecessary. |
We can start small by adding a test for this one. No need to make this just another huge project. |
Add a black box test to import the auth package as a consumer of the package and make sure that no flags are injected. Being in a test, it ignores all the default test flags with "test." prefix. Signed-off-by: Sunny <darkowlzz@protonmail.com>
I've added a small test under |
Is there an ETA when this fix will be merged? We (Kyverno) encountered this issue while importing some of the fluxcd packages, would love to get this in! |
@realshuting you can now use |
Thank you @stefanprodan! |
Verified the test fails without the fix. Thanks @darkowlzz |
This helps avoid importing the controller-runtime pkg/client/config package which has a flag initialization for "kubeconfig". This results in all the users of the oci package to also have the flag initialized in their applications. The root level controller-runtime package has type aliases which we use a lot for ease of use, but the package also imports the client config package.
The usage of controller-runtime in oci package is just for logging. Importing the pkg/log package specifically helps avoid importing the client config which sets the flag.
Fixes #645
Verified by building kyverno locally and testing.
GCP integration test run: https://github.com/fluxcd/pkg/actions/runs/6098520241/job/16548522220