generated from quarkiverse/quarkiverse-template
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow loading external CRDs from specified locations
Locations are specified as comma-separated strings using the quarkus.operator-sdk.bundle.external-crd-locations property. Fixes #985 Signed-off-by: Chris Laprun <claprun@redhat.com>
- Loading branch information
Showing
10 changed files
with
217 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
bundle-generator/deployment/src/test/external-crds/external.crd.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: externals.halkyon.io | ||
spec: | ||
conversion: | ||
strategy: None | ||
group: halkyon.io | ||
names: | ||
kind: External | ||
listKind: ExternalList | ||
plural: externals | ||
singular: external | ||
scope: Namespaced | ||
versions: | ||
- name: v1 | ||
schema: | ||
openAPIV3Schema: | ||
properties: | ||
spec: | ||
type: object | ||
status: | ||
type: object | ||
type: object | ||
served: true | ||
storage: true |
27 changes: 27 additions & 0 deletions
27
bundle-generator/deployment/src/test/external-crds/v1beta1spec.crd.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Fabric8 CRDGenerator, manual edits might get overwritten! | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: v1beta1s.test.com | ||
spec: | ||
group: test.com | ||
names: | ||
kind: V1Beta1 | ||
plural: v1beta1s | ||
singular: v1beta1 | ||
scope: Namespaced | ||
subresources: | ||
status: { } | ||
validation: | ||
openAPIV3Schema: | ||
properties: | ||
spec: | ||
properties: | ||
value: | ||
type: string | ||
type: object | ||
type: object | ||
versions: | ||
- name: v1 | ||
served: true | ||
storage: true |
53 changes: 53 additions & 0 deletions
53
...enerator/deployment/src/test/java/io/quarkiverse/operatorsdk/bundle/ExternalCRDsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.quarkiverse.operatorsdk.bundle; | ||
|
||
import static io.quarkiverse.operatorsdk.bundle.Utils.*; | ||
import static io.quarkiverse.operatorsdk.bundle.Utils.getCRDNameFor; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.quarkiverse.operatorsdk.bundle.sources.External; | ||
import io.quarkiverse.operatorsdk.bundle.sources.ExternalDependentResource; | ||
import io.quarkiverse.operatorsdk.bundle.sources.First; | ||
import io.quarkiverse.operatorsdk.bundle.sources.ReconcilerWithExternalCR; | ||
import io.quarkiverse.operatorsdk.bundle.sources.V1Beta1CRD; | ||
import io.quarkus.test.ProdBuildResults; | ||
import io.quarkus.test.ProdModeTestResults; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class ExternalCRDsTest { | ||
|
||
private static final String APP = "reconciler-with-external-crds"; | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.setApplicationName(APP) | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(First.class, External.class, ExternalDependentResource.class, | ||
ReconcilerWithExternalCR.class)) | ||
.overrideConfigKey("quarkus.operator-sdk.bundle.external-crd-locations", | ||
"src/test/external-crds/v1beta1spec.crd.yml, src/test/external-crds/external.crd.yml"); | ||
|
||
@ProdBuildResults | ||
private ProdModeTestResults prodModeTestResults; | ||
|
||
@Test | ||
public void shouldProcessExternalCRDsWhenPresentAndOutputWarningsAsNeeded() throws IOException { | ||
final var bundle = prodModeTestResults.getBuildDir().resolve(BUNDLE); | ||
assertTrue(Files.exists(bundle.resolve(APP))); | ||
final var manifests = bundle.resolve(APP).resolve("manifests"); | ||
assertFileExistsIn(manifests.resolve(getCRDNameFor(External.class)), manifests); | ||
assertFileExistsIn(manifests.resolve(getCRDNameFor(V1Beta1CRD.class)), manifests); | ||
|
||
final var csv = getCSVFor(bundle, APP); | ||
final var externalCRD = csv.getSpec().getCustomresourcedefinitions().getRequired().get(0); | ||
assertEquals(HasMetadata.getFullResourceName(External.class), externalCRD.getName()); | ||
final var v1beta1 = csv.getSpec().getCustomresourcedefinitions().getRequired().get(1); | ||
assertEquals(HasMetadata.getFullResourceName(V1Beta1CRD.class), v1beta1.getName()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...ent/src/test/java/io/quarkiverse/operatorsdk/bundle/sources/ReconcilerWithExternalCR.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.quarkiverse.operatorsdk.bundle.sources; | ||
|
||
import io.javaoperatorsdk.operator.api.reconciler.Context; | ||
import io.javaoperatorsdk.operator.api.reconciler.ControllerConfiguration; | ||
import io.javaoperatorsdk.operator.api.reconciler.Reconciler; | ||
import io.javaoperatorsdk.operator.api.reconciler.UpdateControl; | ||
import io.javaoperatorsdk.operator.api.reconciler.dependent.Dependent; | ||
import io.quarkiverse.operatorsdk.annotations.CSVMetadata; | ||
|
||
@ControllerConfiguration(dependents = @Dependent(type = ExternalDependentResource.class)) | ||
@CSVMetadata(requiredCRDs = @CSVMetadata.RequiredCRD(kind = V1Beta1CRD.KIND, name = V1Beta1CRD.CR_NAME, version = V1Beta1CRD.VERSION)) | ||
public class ReconcilerWithExternalCR implements Reconciler<First> { | ||
@Override | ||
public UpdateControl<First> reconcile(First first, Context<First> context) throws Exception { | ||
return null; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...erator/deployment/src/test/java/io/quarkiverse/operatorsdk/bundle/sources/V1Beta1CRD.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.quarkiverse.operatorsdk.bundle.sources; | ||
|
||
import io.fabric8.kubernetes.client.CustomResource; | ||
import io.fabric8.kubernetes.model.annotation.Group; | ||
import io.fabric8.kubernetes.model.annotation.Kind; | ||
import io.fabric8.kubernetes.model.annotation.Version; | ||
|
||
@Group(V1Beta1CRD.GROUP) | ||
@Version(V1Beta1CRD.VERSION) | ||
@Kind(V1Beta1CRD.KIND) | ||
public class V1Beta1CRD extends CustomResource<V1Beta1CRD.Spec, Void> { | ||
|
||
public static final String GROUP = "test.com"; | ||
public static final String VERSION = "v2"; | ||
public static final String KIND = "V1Beta1"; | ||
public static final String CR_NAME = "v1beta1s." + GROUP; | ||
|
||
public record Spec(String value) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.