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

Create Config without using auto-configure functionality or setting env variables #2319

Closed
Fabian-K opened this issue Jun 30, 2020 · 5 comments · Fixed by #2377
Closed

Create Config without using auto-configure functionality or setting env variables #2319

Fabian-K opened this issue Jun 30, 2020 · 5 comments · Fixed by #2377
Assignees

Comments

@Fabian-K
Copy link
Contributor

Hi,

I´m looking for a away to create a Config without using auto-configuration functionality while not relying on env variables or properties.

Currently when constructing a config like this, it still invokes the auto-configuration. I instead want to explicitly use the values provided (as they differ in terms of authorization from what is provided via auto-configuration)

val config: Config = ConfigBuilder()
                    .withCaCertData(...)
                    .withUsername(...)
                    .withNamespace(...)
                    .withOauthToken(...)
                    .withMasterUrl(...)
                    .build()

val client = DefaultKubernetesClient(config)

Is this already possible and I´m just not seeing it? :)

Thanks, Fabian

@rohanKanojia
Copy link
Member

@Fabian-K : Hi, extremely sorry for the late reply. I think you might already have figured it out yourself. I checked code and there seem to be property kubernetes.disable.autoConfig which might do the trick for you. I'm not

@Deprecated
public Config() {
if (!Utils.getSystemPropertyOrEnvVar(KUBERNETES_DISABLE_AUTO_CONFIG_SYSTEM_PROPERTY, false)) {
autoConfigure(this, null);
}

@Fabian-K
Copy link
Contributor Author

No problem, thanks for the reply!

Properties and Env Values are depending on the environment not always straight forward to set. I also somehow feel that it should be possible to say in code: "use exactly these config values which I provide".

The no-argument constructor is deprecated for some time now (2017). What do you think about removing the autoConfigure part from it and simply return an empty config? This way, the ConfigBuilder would not include auto-configuration any more. To make the breaking change obvious, this could be a private constructor, used e.g. by a new static method Config.empty().

@rohanKanojia
Copy link
Member

I'm afraid that changing the default behavior of ConfigBuilder might break backward compatibility. I've seen lots of people using that ConfigBuilder to create client Config. But I agree this method has been deprecated for a long time. @manusa @oscerd What do you think about Fabian's suggestion?

@Fabian-K
Copy link
Contributor Author

An alternative might be to offer a new static method Config.empty() that uses a new private constructor Config(Boolean autoConfigure)

@oscerd
Copy link
Member

oscerd commented Jul 17, 2020

We can do that, maybe by moving to 4.11.x and stress this in the release note. I don't think this is a change requiring a major bump like moving to 5.x

rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jul 29, 2020
@rohanKanojia rohanKanojia self-assigned this Jul 29, 2020
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jul 29, 2020
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jul 30, 2020
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants