Skip to content

Commit f42357d

Browse files
authored
fix: make CRD output directory follow Kubernetes extension configuration (#605)
Fixes #603
1 parent c14b448 commit f42357d

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

core/deployment/src/main/java/io/quarkiverse/operatorsdk/deployment/CRDGeneration.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package io.quarkiverse.operatorsdk.deployment;
22

3+
import static io.quarkus.kubernetes.deployment.Constants.KUBERNETES;
4+
5+
import java.nio.file.Path;
6+
import java.nio.file.Paths;
37
import java.util.HashMap;
48
import java.util.HashSet;
59
import java.util.Map;
@@ -72,8 +76,10 @@ CRDGenerationInfo generate(OutputTargetBuildItem outputTarget,
7276
final var generated = new HashSet<String>();
7377

7478
if (needGeneration) {
75-
final String outputDirName = crdConfiguration.outputDirectory;
76-
final var outputDir = outputTarget.getOutputDirectory().resolve(outputDirName).toFile();
79+
Path targetDirectory = crdConfiguration.outputDirectory.map(
80+
d -> Paths.get("").toAbsolutePath().resolve(d))
81+
.orElse(outputTarget.getOutputDirectory().resolve(KUBERNETES));
82+
final var outputDir = targetDirectory.toFile();
7783
if (!outputDir.exists()) {
7884
if (!outputDir.mkdirs()) {
7985
throw new IllegalArgumentException("Couldn't create " + outputDir.getAbsolutePath());

core/runtime/src/main/java/io/quarkiverse/operatorsdk/runtime/CRDConfiguration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ public class CRDConfiguration {
4242
public List<String> versions;
4343

4444
/**
45-
* The directory where the CRDs will be generated, relative to the project's output directory.
45+
* The directory where the CRDs will be generated, defaults to the {@code kubernetes}
46+
* directory of the project's output directory.
4647
*/
47-
@ConfigItem(defaultValue = DEFAULT_OUTPUT_DIRECTORY)
48-
public String outputDirectory;
48+
@ConfigItem
49+
public Optional<String> outputDirectory;
4950

5051
/**
5152
* Whether the extension should generate all CRDs even if some are not tied to a Reconciler.

docs/modules/ROOT/pages/includes/quarkus-operator-sdk.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ a|icon:lock[title=Fixed at build time] [[quarkus-operator-sdk_quarkus.operator-s
7878

7979
[.description]
8080
--
81-
The directory where the CRDs will be generated, relative to the project's output directory.
81+
The directory where the CRDs will be generated, defaults to the `kubernetes` directory of the project's output directory.
8282

8383
ifdef::add-copy-button-to-env-var[]
8484
Environment variable: env_var_with_copy_button:+++QUARKUS_OPERATOR_SDK_CRD_OUTPUT_DIRECTORY+++[]
@@ -87,7 +87,7 @@ ifndef::add-copy-button-to-env-var[]
8787
Environment variable: `+++QUARKUS_OPERATOR_SDK_CRD_OUTPUT_DIRECTORY+++`
8888
endif::add-copy-button-to-env-var[]
8989
--|string
90-
|`kubernetes`
90+
|
9191

9292

9393
a|icon:lock[title=Fixed at build time] [[quarkus-operator-sdk_quarkus.operator-sdk.crd.generate-all]]`link:#quarkus-operator-sdk_quarkus.operator-sdk.crd.generate-all[quarkus.operator-sdk.crd.generate-all]`

0 commit comments

Comments
 (0)