diff --git a/docs/reference.md b/docs/reference.md index 2e5cf72..7af1a4f 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -53,6 +53,7 @@ See sample usage within `Glue` [here](https://github.com/csviri/kubernetes-glue- The following attributes can be defined for a related resource: - **`name`** - same as for child resource, unique identifier, used to reference the resource. +- **`clusterScoped`** - if the related resource is cluster scoped. Default is `false`. - **`apiVersion`** - Kubernetes resource API Version of the resource - **`kind`** - Kubernetes kind property of the resource - **`resourceNames`** - list of string of the resource names within the same namespace as `Glue`. diff --git a/src/test/java/io/csviri/operator/glue/GlueTest.java b/src/test/java/io/csviri/operator/glue/GlueTest.java index 19f3198..a5ef637 100644 --- a/src/test/java/io/csviri/operator/glue/GlueTest.java +++ b/src/test/java/io/csviri/operator/glue/GlueTest.java @@ -308,7 +308,19 @@ void relatedResourceFromDifferentNamespace() { @Test void clusterScopedRelatedResource() { + var glue = create(TestUtils.loadGlue("/glue/ClusterScopedRelatedResource.yaml")); + await().untilAsserted(() -> { + var cm = get(ConfigMap.class, "configmap1"); + assertThat(cm).isNotNull(); + assertThat(cm.getData()).containsEntry("phase", "Active"); + }); + + delete(glue); + await().timeout(TestUtils.GC_WAIT_TIMEOUT).untilAsserted(() -> { + var cm = get(ConfigMap.class, "configmap1"); + assertThat(cm).isNull(); + }); } private List testWorkflowList(int num) { diff --git a/src/test/resources/glue/ClusterScopedRelatedResource.yaml b/src/test/resources/glue/ClusterScopedRelatedResource.yaml new file mode 100644 index 0000000..e4eb109 --- /dev/null +++ b/src/test/resources/glue/ClusterScopedRelatedResource.yaml @@ -0,0 +1,22 @@ +apiVersion: io.csviri.operator.glue/v1beta1 +kind: Glue +metadata: + name: "testglue" +spec: + childResources: + - name: configMap + resource: + apiVersion: v1 + kind: ConfigMap + metadata: + name: "configmap1" + data: + phase: "{related.status.phase}" + relatedResources: + - name: related + apiVersion: v1 + kind: Namespace + clusterScoped: true + resourceNames: ["default"] + +