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

fix (kubernetes-client-api) : Config's autoConfigure should disable auto configuration #6153

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

rohanKanojia
Copy link
Member

@rohanKanojia rohanKanojia commented Jul 18, 2024

Description

Fix #6137

Config's autoConfigure field should behave as per expectations.

We need to make changes to ConfigBuilder and ConfigFluent in order to achieve this.

  • Add a new Constructor with additional boolean arguments autoConfigure and shouldSetDefaultValues
  • Add a new package private class SundrioConfig that would extend Config for generating the Sundrio Builder for Config
  • Move generated classes ConfigBuilder and ConfigFluent to src/main/java
    • ConfigBuilder would extend generated SundrioConfigBuilder and override the build() method by calling disableAutoConfig() if autoConfigure is not provided by the user. Earlier ConfigBuidler was calling new Config() (this was enabling auto configuration)
  • Make all fields in Config and ResourceConfig classes use boxed types instead of primitive types so that we can distinguish whether user has configured them.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@rohanKanojia rohanKanojia marked this pull request as ready for review July 19, 2024 04:05
Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

Let's review this together after the stand-up, I'm not sure how these changes deal with the issue

@rohanKanojia rohanKanojia force-pushed the pr/issue6137 branch 2 times, most recently from c1a47c8 to dbbe657 Compare July 22, 2024 06:04
Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

Could you please create an initial PR with the tests so that it's clear that the changes in the constructor are not affecting the previous behavior.

OAuthTokenProvider oauthTokenProvider, Map<String, String> customHeaders, int requestRetryBackoffLimit,
int requestRetryBackoffInterval, int uploadRequestTimeout, boolean onlyHttpWatches, NamedContext currentContext,
List<NamedContext> contexts, boolean autoConfigure) {
autoConfigure(this, null);
Copy link
Member

Choose a reason for hiding this comment

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

This looks weird. Why is autoconfigure always invoked? It wasn't before (in some of the methods)

Comment on lines 395 to 396
this.apiVersion = Objects.equals(this.apiVersion, apiVersion) ? "v1" : apiVersion;
this.namespace = Objects.equals(this.namespace, namespace) ? null : namespace;
Copy link
Member

Choose a reason for hiding this comment

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

these also look weird?
why is the variable overridden to an arbitrary (magic) value in case the current and provided values match?

@rohanKanojia rohanKanojia force-pushed the pr/issue6137 branch 8 times, most recently from 952b090 to d20f386 Compare August 7, 2024 10:23
@rohanKanojia rohanKanojia force-pushed the pr/issue6137 branch 7 times, most recently from b8eca9b to b2e2a09 Compare August 8, 2024 10:56
…le auto configuration

`Config`'s autoConfigure field should behave as per expectations. We
need to make changes to ConfigBuilder and ConfigFluent in order to
achieve this.
- Add a new Constructor with additional boolean arguments `autoConfigure` and
  `shouldSetDefaultValues`
- Add a new class `SundrioConfig` that would extend `Config` for
  generating the Sundrio Builder for Config
- Move generated classes `ConfigBuilder` and `ConfigFluent` to `src/main/java`
  - `ConfigBuilder` would extend generated SundrioConfigBuilder and
    override the `build()` method by calling `disableAutoConfig()` if
    `autoConfigure` is nto provided by the user. Earlier `ConfigBuidler` was calling `new Config()`
    (this was enabling auto configuration)
- Make all fields in Config class use boxed types instead of primitive
  types so that we can distinguish whether they have been configured by
  user.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
Copy link

sonarqubecloud bot commented Aug 8, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots

See analysis details on SonarCloud

@manusa manusa self-requested a review August 8, 2024 12:41
@manusa manusa added this to the 7.0.0 milestone Aug 8, 2024 — with automated-tasks
Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

LGTM, thx!

@manusa manusa merged commit 08b0e9f into fabric8io:main Aug 8, 2024
19 of 21 checks passed
@rohanKanojia rohanKanojia deleted the pr/issue6137 branch August 8, 2024 12:59
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.

ConfigBuilder.withAutoConfigure is not working
2 participants