|
| 1 | +package io.javaoperatorsdk.operator.processing.dependent.kubernetes; |
| 2 | + |
| 3 | +import java.util.Set; |
| 4 | + |
| 5 | +import io.javaoperatorsdk.operator.api.reconciler.ResourceDiscriminator; |
| 6 | +import io.javaoperatorsdk.operator.processing.event.source.filter.GenericFilter; |
| 7 | +import io.javaoperatorsdk.operator.processing.event.source.filter.OnAddFilter; |
| 8 | +import io.javaoperatorsdk.operator.processing.event.source.filter.OnDeleteFilter; |
| 9 | +import io.javaoperatorsdk.operator.processing.event.source.filter.OnUpdateFilter; |
| 10 | + |
| 11 | +public final class KubernetesDependentResourceConfigBuilder<R> { |
| 12 | + |
| 13 | + private Set<String> namespaces; |
| 14 | + private String labelSelector; |
| 15 | + private boolean createResourceOnlyIfNotExistingWithSSA; |
| 16 | + private ResourceDiscriminator<R, ?> resourceDiscriminator; |
| 17 | + private Boolean useSSA; |
| 18 | + private OnAddFilter<R> onAddFilter; |
| 19 | + private OnUpdateFilter<R> onUpdateFilter; |
| 20 | + private OnDeleteFilter<R> onDeleteFilter; |
| 21 | + private GenericFilter<R> genericFilter; |
| 22 | + |
| 23 | + public KubernetesDependentResourceConfigBuilder() {} |
| 24 | + |
| 25 | + public static <R> KubernetesDependentResourceConfigBuilder<R> aKubernetesDependentResourceConfig() { |
| 26 | + return new KubernetesDependentResourceConfigBuilder<>(); |
| 27 | + } |
| 28 | + |
| 29 | + public KubernetesDependentResourceConfigBuilder<R> withNamespaces(Set<String> namespaces) { |
| 30 | + this.namespaces = namespaces; |
| 31 | + return this; |
| 32 | + } |
| 33 | + |
| 34 | + public KubernetesDependentResourceConfigBuilder<R> withLabelSelector(String labelSelector) { |
| 35 | + this.labelSelector = labelSelector; |
| 36 | + return this; |
| 37 | + } |
| 38 | + |
| 39 | + public KubernetesDependentResourceConfigBuilder<R> withCreateResourceOnlyIfNotExistingWithSSA( |
| 40 | + boolean createResourceOnlyIfNotExistingWithSSA) { |
| 41 | + this.createResourceOnlyIfNotExistingWithSSA = createResourceOnlyIfNotExistingWithSSA; |
| 42 | + return this; |
| 43 | + } |
| 44 | + |
| 45 | + public KubernetesDependentResourceConfigBuilder<R> withResourceDiscriminator( |
| 46 | + ResourceDiscriminator<R, ?> resourceDiscriminator) { |
| 47 | + this.resourceDiscriminator = resourceDiscriminator; |
| 48 | + return this; |
| 49 | + } |
| 50 | + |
| 51 | + public KubernetesDependentResourceConfigBuilder<R> withUseSSA(Boolean useSSA) { |
| 52 | + this.useSSA = useSSA; |
| 53 | + return this; |
| 54 | + } |
| 55 | + |
| 56 | + public KubernetesDependentResourceConfigBuilder<R> withOnAddFilter(OnAddFilter<R> onAddFilter) { |
| 57 | + this.onAddFilter = onAddFilter; |
| 58 | + return this; |
| 59 | + } |
| 60 | + |
| 61 | + public KubernetesDependentResourceConfigBuilder<R> withOnUpdateFilter( |
| 62 | + OnUpdateFilter<R> onUpdateFilter) { |
| 63 | + this.onUpdateFilter = onUpdateFilter; |
| 64 | + return this; |
| 65 | + } |
| 66 | + |
| 67 | + public KubernetesDependentResourceConfigBuilder<R> withOnDeleteFilter( |
| 68 | + OnDeleteFilter<R> onDeleteFilter) { |
| 69 | + this.onDeleteFilter = onDeleteFilter; |
| 70 | + return this; |
| 71 | + } |
| 72 | + |
| 73 | + public KubernetesDependentResourceConfigBuilder<R> withGenericFilter( |
| 74 | + GenericFilter<R> genericFilter) { |
| 75 | + this.genericFilter = genericFilter; |
| 76 | + return this; |
| 77 | + } |
| 78 | + |
| 79 | + public KubernetesDependentResourceConfig<R> build() { |
| 80 | + return new KubernetesDependentResourceConfig<>(namespaces, labelSelector, false, |
| 81 | + createResourceOnlyIfNotExistingWithSSA, resourceDiscriminator, useSSA, onAddFilter, |
| 82 | + onUpdateFilter, onDeleteFilter, genericFilter); |
| 83 | + } |
| 84 | +} |
0 commit comments