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

Typed Config for GOP #241

Merged
merged 10 commits into from
Nov 15, 2024
Merged

Typed Config for GOP #241

merged 10 commits into from
Nov 15, 2024

Conversation

nihussmann
Copy link
Contributor

No description provided.

This allows for adding internal properties (can't be set by user via
config), preparing for Schema to become the typed configuration object.

Reuse @JsonPropertyDescription that already was on almost all properties.

A more explicit and more common alternative would have been to use
@JsonProperty, but this would basically mean to duplicate all
@JsonPropertyDescription annotations adding more than 100 LOC of bloat.
For future usage as config singleton used by all classes.
* More compact output than JSON,
* more reuse,
* Less complex code, all Config conversions (fromMap, toMap, toYaml) in
one place
* Get rid of complicated ConfigToConfigFileConverterTest
Allows for a smooth transition from injecting Map via Configuration to
injecting
 Config object directly.
Config and CLI options in one place promise easier maintenance.

Not directly related minor refactorings:

* Schema now knows the possible values for VaultMode.
* Allow for setting config file and map at the same time
* this also makes precedence of config options more explicit in code
* On top of that, also prepares for adding more config options like
secrets or
multiple maps or secrets
* Hides stack traces when not debug or trace.
* Some more classes that are only needed during initialization were
converted to static, which make GitopsPlaygroundCliMainScripted a bit
simpler.

Downsides:

Drop params
--petclinic-base-domain
--nginx-base-domain
Because they will soon be refactored anyway and would require separate
classes.

@immutable needed to be removed, because Picocli can't handle Strings.
All options like @immutable or using lombok seem impossible or come with
 huge downsides themselves.
So it would be pragmatic to accept a mutable config :/
@nihussmann nihussmann changed the title Feature/typed config Typed Config for GOP Nov 12, 2024
@nihussmann nihussmann marked this pull request as draft November 12, 2024 09:23
pom.xml Show resolved Hide resolved
@nihussmann nihussmann force-pushed the feature/typed-config branch 2 times, most recently from 46195af to a90b27b Compare November 12, 2024 10:58
@@ -161,6 +162,6 @@ class ScmmRepoTest {
}

private ScmmRepo createRepo(String repoTarget = "dont-care-repo-target") {
return new TestScmmRepoProvider(new Configuration(config), new FileSystemUtils()).getRepo(repoTarget)
return new TestScmmRepoProvider(Config.fromMap(config), new FileSystemUtils()).getRepo(repoTarget)
Copy link
Contributor

Choose a reason for hiding this comment

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

change map to Config in tests?

@@ -13,7 +14,7 @@ class NetworkingUtilsTest {
]
]

K8sClientForTest k8sClient = new K8sClientForTest(config)
K8sClientForTest k8sClient = new K8sClientForTest(Config.fromMap( config))
Copy link
Contributor

Choose a reason for hiding this comment

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

Config ?

@@ -47,6 +48,6 @@ class DeployerTest {
]
]

return new Deployer(new Configuration(config), argoCdStrat, helmStrat)
return new Deployer(Config.fromMap(config), argoCdStrat, helmStrat)
Copy link
Contributor

Choose a reason for hiding this comment

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

Config?

@@ -85,7 +86,7 @@ spec:
]


def repoProvider = new TestScmmRepoProvider(new Configuration(config), new FileSystemUtils()) {
def repoProvider = new TestScmmRepoProvider(Config.fromMap(config), new FileSystemUtils()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Config?

@@ -13,7 +14,7 @@ class FeatureTest {
namePrefix: "foo-"
]
]
K8sClientForTest k8sClient = new K8sClientForTest(config)
K8sClientForTest k8sClient = new K8sClientForTest(Config.fromMap( config))
Copy link
Contributor

Choose a reason for hiding this comment

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

use Config instead Map ?

config.application['mirrorRepos'] = true
when(airGappedUtils.mirrorHelmRepoToGit(any(Map))).thenReturn('a/b')
config.application.mirrorRepos = true
when(airGappedUtils.mirrorHelmRepoToGit(any())).thenReturn('a/b')
Copy link
Contributor

Choose a reason for hiding this comment

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

specifiy any()

Copy link
Contributor

Choose a reason for hiding this comment

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

changed

@nihussmann nihussmann marked this pull request as ready for review November 13, 2024 10:15
@nihussmann nihussmann merged commit 81c230b into main Nov 15, 2024
1 check passed
@nihussmann nihussmann deleted the feature/typed-config branch November 15, 2024 14:51
schnatterer added a commit that referenced this pull request Dec 19, 2024
After they moved there from ApplicationConfigurator in #241
schnatterer added a commit that referenced this pull request Dec 19, 2024
After they moved there from ApplicationConfigurator in #241
schnatterer added a commit that referenced this pull request Dec 19, 2024
After they moved there from ApplicationConfigurator in #241
schnatterer added a commit that referenced this pull request Dec 19, 2024
After they moved there from ApplicationConfigurator in #241
schnatterer added a commit that referenced this pull request Dec 19, 2024
After they moved there from ApplicationConfigurator in #241
nihussmann pushed a commit that referenced this pull request Jan 2, 2025
After they moved there from ApplicationConfigurator in #241
schnatterer added a commit that referenced this pull request Jan 7, 2025
After they moved there from ApplicationConfigurator in #241
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