Skip to content

Commit ff01ec0

Browse files
committed
refactor: switch BundleGenerationConfiguration to ConfigMapping
Signed-off-by: Chris Laprun <[email protected]>
1 parent cc88ea3 commit ff01ec0

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

bundle-generator/deployment/src/main/java/io/quarkiverse/operatorsdk/bundle/deployment/BundleGenerator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ private static HashSet<String> addCRDManifestBuilder(Map<String, CRDInfo> crds,
9393

9494
private static SortedMap<String, String> generateBundleLabels(CSVMetadataHolder csvMetadata,
9595
BundleGenerationConfiguration bundleConfiguration, Version version) {
96-
var packageName = bundleConfiguration.packageName.orElse(csvMetadata.bundleName);
96+
var packageName = bundleConfiguration.packageName().orElse(csvMetadata.bundleName);
9797

9898
SortedMap<String, String> values = new TreeMap<>();
9999
values.put(join(BUNDLE_PREFIX, CHANNEL, DEFAULT, ANNOTATIONS_VERSION),
100-
bundleConfiguration.defaultChannel.orElse(bundleConfiguration.channels.get(0)));
101-
values.put(join(BUNDLE_PREFIX, CHANNELS, ANNOTATIONS_VERSION), String.join(COMMA, bundleConfiguration.channels));
100+
bundleConfiguration.defaultChannel().orElse(bundleConfiguration.channels().get(0)));
101+
values.put(join(BUNDLE_PREFIX, CHANNELS, ANNOTATIONS_VERSION), String.join(COMMA, bundleConfiguration.channels()));
102102
values.put(join(BUNDLE_PREFIX, MANIFESTS, ANNOTATIONS_VERSION), MANIFESTS + SLASH);
103103
values.put(join(BUNDLE_PREFIX, MEDIA_TYPE, ANNOTATIONS_VERSION), REGISTRY_PLUS + ANNOTATIONS_VERSION);
104104
values.put(join(BUNDLE_PREFIX, METADATA, ANNOTATIONS_VERSION), METADATA + SLASH);

bundle-generator/deployment/src/main/java/io/quarkiverse/operatorsdk/bundle/deployment/BundleProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private static class IsGenerationEnabled implements BooleanSupplier {
6363

6464
@Override
6565
public boolean getAsBoolean() {
66-
return config.enabled;
66+
return config.enabled();
6767
}
6868
}
6969

@@ -75,16 +75,16 @@ CSVMetadataBuildItem gatherCSVMetadata(KubernetesConfig kubernetesConfig,
7575
CombinedIndexBuildItem combinedIndexBuildItem,
7676
JarBuildItem jarBuildItem) {
7777
final var index = combinedIndexBuildItem.getIndex();
78-
final var defaultName = bundleConfiguration.packageName
78+
final var defaultName = bundleConfiguration.packageName()
7979
.orElse(ResourceNameUtil.getResourceName(kubernetesConfig, appConfiguration));
8080

8181
// note that version, replaces, etc. should probably be settable at the reconciler level
8282
// use version specified in bundle configuration, if not use the one extracted from the project, if available
8383
final var version = kubernetesConfig.getVersion().orElse(appConfiguration.getVersion());
84-
final var defaultVersion = bundleConfiguration.version
84+
final var defaultVersion = bundleConfiguration.version()
8585
.orElse(ApplicationInfoBuildItem.UNSET_VALUE.equals(version) ? null : version);
8686

87-
final var defaultReplaces = bundleConfiguration.replaces.orElse(null);
87+
final var defaultReplaces = bundleConfiguration.replaces().orElse(null);
8888

8989
final var sharedMetadataHolders = getSharedMetadataHolders(defaultName, defaultVersion, defaultReplaces, index);
9090
final var csvGroups = new HashMap<CSVMetadataHolder, List<ReconcilerAugmentedClassInfo>>();

bundle-generator/runtime/src/main/java/io/quarkiverse/operatorsdk/bundle/runtime/BundleGenerationConfiguration.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,47 @@
44
import java.util.Optional;
55

66
import io.quarkiverse.operatorsdk.annotations.CSVMetadata;
7-
import io.quarkus.runtime.annotations.ConfigItem;
87
import io.quarkus.runtime.annotations.ConfigRoot;
8+
import io.smallrye.config.ConfigMapping;
9+
import io.smallrye.config.WithDefault;
910

10-
@ConfigRoot(name = "operator-sdk.bundle")
11-
public class BundleGenerationConfiguration {
11+
@ConfigMapping(prefix = "operator-sdk.bundle")
12+
@ConfigRoot
13+
public interface BundleGenerationConfiguration {
1214
/**
1315
* Whether the extension should generate the Operator bundle.
1416
*/
15-
@ConfigItem(defaultValue = "true")
16-
public Boolean enabled;
17+
@WithDefault("true")
18+
Boolean enabled();
1719

1820
/**
1921
* The list of channels that bundle belongs to. By default, it's "alpha".
2022
*/
21-
@ConfigItem(defaultValue = "alpha")
22-
public List<String> channels;
23+
@WithDefault("alpha")
24+
List<String> channels();
2325

2426
/**
2527
* The default channel for the bundle.
2628
*/
27-
@ConfigItem
28-
public Optional<String> defaultChannel;
29+
Optional<String> defaultChannel();
2930

3031
/**
3132
* The name of the package that bundle belongs to.
3233
*
3334
* @deprecated Use {@link CSVMetadata#bundleName()} instead
3435
*/
3536
@Deprecated(forRemoval = true)
36-
@ConfigItem
37-
public Optional<String> packageName;
37+
Optional<String> packageName();
3838

3939
/**
4040
* The replaces value that should be used in the generated CSV.
4141
*/
42-
@ConfigItem
43-
public Optional<String> replaces;
42+
Optional<String> replaces();
4443

4544
/**
4645
* The version value that should be used in the generated CSV instead of the automatically detected one extracted from the
4746
* project information.
4847
*/
49-
@ConfigItem
50-
public Optional<String> version;
48+
Optional<String> version();
5149

5250
}

0 commit comments

Comments
 (0)