Skip to content

Commit 3b86da9

Browse files
committed
wip
Signed-off-by: Attila Mészáros <[email protected]>
1 parent e580b7c commit 3b86da9

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

src/main/java/io/csviri/operator/glue/customresource/operator/Parent.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ public class Parent {
66

77
private String apiVersion;
88
private String kind;
9+
private boolean clusterScoped = false;
910
private String labelSelector;
1011

12+
1113
public Parent() {}
1214

1315
public Parent(String apiVersion, String kind) {
@@ -41,19 +43,27 @@ public void setLabelSelector(String labelSelector) {
4143
this.labelSelector = labelSelector;
4244
}
4345

46+
public boolean isClusterScoped() {
47+
return clusterScoped;
48+
}
49+
50+
public void setClusterScoped(boolean clusterScoped) {
51+
this.clusterScoped = clusterScoped;
52+
}
53+
4454
@Override
4555
public boolean equals(Object o) {
4656
if (this == o)
4757
return true;
4858
if (o == null || getClass() != o.getClass())
4959
return false;
5060
Parent parent = (Parent) o;
51-
return Objects.equals(apiVersion, parent.apiVersion) && Objects.equals(kind, parent.kind)
52-
&& Objects.equals(labelSelector, parent.labelSelector);
61+
return clusterScoped == parent.clusterScoped && Objects.equals(apiVersion, parent.apiVersion)
62+
&& Objects.equals(kind, parent.kind) && Objects.equals(labelSelector, parent.labelSelector);
5363
}
5464

5565
@Override
5666
public int hashCode() {
57-
return Objects.hash(apiVersion, kind, labelSelector);
67+
return Objects.hash(apiVersion, kind, clusterScoped, labelSelector);
5868
}
5969
}

src/main/java/io/csviri/operator/glue/reconciler/operator/GlueOperatorReconciler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ private Glue createGlue(GenericKubernetesResource targetParentResource,
118118
parentRelatedSpec.setKind(parent.getKind());
119119
parentRelatedSpec.setResourceNames(List.of(targetParentResource.getMetadata().getName()));
120120
parentRelatedSpec.setNamespace(targetParentResource.getMetadata().getNamespace());
121+
parentRelatedSpec.setClusterScoped(glueOperator.getSpec().getParent().isClusterScoped());
121122

122123
glue.getSpec().getRelatedResources().add(parentRelatedSpec);
123-
124124
glue.addOwnerReference(targetParentResource);
125125
return glue;
126126
}

src/test/java/io/csviri/operator/glue/GlueOperatorTest.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.stream.IntStream;
66

77
import org.junit.jupiter.api.BeforeEach;
8-
import org.junit.jupiter.api.Disabled;
98
import org.junit.jupiter.api.Test;
109

1110
import io.csviri.operator.glue.customresource.TestCustomResource;
@@ -191,8 +190,6 @@ void parentWithLabelSelector() {
191190
});
192191
}
193192

194-
195-
@Disabled
196193
@Test
197194
void secretCopySample() {
198195
var secret = TestUtils.load("/sample/secretcopy/secret-to-copy.yaml", Secret.class);
@@ -205,12 +202,23 @@ void secretCopySample() {
205202
var namespaces = client.namespaces().list().getItems();
206203
namespaces.forEach(ns -> {
207204
var copiedSecret =
208-
client.secrets().inNamespace(ns.getMetadata().getName()).withName("copied-secret");
205+
client.secrets().inNamespace(ns.getMetadata().getName()).withName("copied-secret")
206+
.get();
209207
assertThat(copiedSecret).isNotNull();
208+
assertThat(copiedSecret.getData().get("shared-password"))
209+
.isEqualTo(secret.getData().get("password"));
210210
});
211211
});
212212

213-
213+
delete(go);
214+
await().untilAsserted(() -> {
215+
var namespaces = client.namespaces().list().getItems();
216+
namespaces.forEach(ns -> {
217+
var copiedSecret =
218+
client.secrets().inNamespace(ns.getMetadata().getName()).withName("copied-secret");
219+
assertThat(copiedSecret).isNull();
220+
});
221+
});
214222
}
215223

216224

src/test/resources/sample/secretcopy/secret-copy.operator.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ spec:
88
kind: Namespace
99
glueMetadata:
1010
name: copied-secret-glue
11-
namespace: {parent.metadata.name}
11+
namespace: "{parent.metadata.name}"
1212
childResources:
1313
- name: secret
1414
resource:
@@ -23,4 +23,5 @@ spec:
2323
- name: sharedsecret
2424
apiVersion: v1
2525
kind: Secret
26+
namespace: default
2627
resourceNames: [ "secret-to-copy" ]

0 commit comments

Comments
 (0)