diff --git a/core/src/main/java/io/dekorate/kubernetes/decorator/AddToMatchingLabelsDecorator.java b/core/src/main/java/io/dekorate/kubernetes/decorator/AddToMatchingLabelsDecorator.java index bade175b6..2602a228b 100644 --- a/core/src/main/java/io/dekorate/kubernetes/decorator/AddToMatchingLabelsDecorator.java +++ b/core/src/main/java/io/dekorate/kubernetes/decorator/AddToMatchingLabelsDecorator.java @@ -8,6 +8,10 @@ public class AddToMatchingLabelsDecorator extends NamedResourceDecorator selector, ObjectMeta resourceMeta) { + @Override + public void andThenVisit(LabelSelectorFluent selector, ObjectMeta resourceMeta) { selector.addToMatchLabels(key, value); - } + } @Override public Class[] after() { diff --git a/core/src/main/java/io/dekorate/kubernetes/decorator/AddToSelectorDecorator.java b/core/src/main/java/io/dekorate/kubernetes/decorator/AddToSelectorDecorator.java index 213e3e81f..2fa668137 100644 --- a/core/src/main/java/io/dekorate/kubernetes/decorator/AddToSelectorDecorator.java +++ b/core/src/main/java/io/dekorate/kubernetes/decorator/AddToSelectorDecorator.java @@ -22,6 +22,7 @@ import io.dekorate.SelectorDecoratorFactories; import io.dekorate.SelectorDecoratorFactory; import io.fabric8.kubernetes.api.builder.VisitableBuilder; +import io.fabric8.kubernetes.api.builder.Visitor; import io.fabric8.kubernetes.api.model.ObjectMeta; public class AddToSelectorDecorator extends NamedResourceDecorator { @@ -51,11 +52,17 @@ public AddToSelectorDecorator(String kind, String name, String key, String value @Override public void andThenVisit(VisitableBuilder builder ,String kind, ObjectMeta resourceMeta) { Optional factory = SelectorDecoratorFactories.find(kind); - factory.ifPresent(f -> f.createAddToSelectorDecorator(resourceMeta.getName(), key, value)); + factory.map(f -> f.createAddToSelectorDecorator(resourceMeta.getName(), key, value)).ifPresent(m -> builder.accept((Visitor) m)); } - @Override + @Override public void andThenVisit(VisitableBuilder item, ObjectMeta resourceMeta) { //Not needed } + + @Override + public Class[] before() { + return new Class[] {AddToSelectorDecorator.class}; + } + } diff --git a/core/src/main/java/io/dekorate/kubernetes/decorator/RemoveFromMatchingLabelsDecorator.java b/core/src/main/java/io/dekorate/kubernetes/decorator/RemoveFromMatchingLabelsDecorator.java index 1057be6ec..d875c56a8 100644 --- a/core/src/main/java/io/dekorate/kubernetes/decorator/RemoveFromMatchingLabelsDecorator.java +++ b/core/src/main/java/io/dekorate/kubernetes/decorator/RemoveFromMatchingLabelsDecorator.java @@ -7,6 +7,10 @@ public class RemoveFromMatchingLabelsDecorator extends NamedResourceDecorator { private final String key; + public RemoveFromSelectorDecorator(String key) { + this(ANY, key); + } + public RemoveFromSelectorDecorator(String name, String key) { super(name); this.key = key; @@ -42,11 +47,16 @@ public RemoveFromSelectorDecorator(String kind, String name, String key) { @Override public void andThenVisit(VisitableBuilder builder ,String kind, ObjectMeta resourceMeta) { Optional factory = SelectorDecoratorFactories.find(kind); - factory.ifPresent(f -> f.createRemoveFromSelectorDecorator(resourceMeta.getName(), key)); + factory.map(f -> f.createRemoveFromSelectorDecorator(resourceMeta.getName(), key)).ifPresent(m -> builder.accept((Visitor) m)); } @Override public void andThenVisit(VisitableBuilder item, ObjectMeta resourceMeta) { //Not needed } + + @Override + public Class[] after() { + return new Class[] {ResourceProvidingDecorator.class, AddToSelectorDecorator.class}; + } }