Skip to content

Commit a3c2dd7

Browse files
authored
feat: unified samples label usage (#1234)
1 parent dc97645 commit a3c2dd7

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageReconciler.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@
3030
import io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource;
3131

3232
import static io.javaoperatorsdk.operator.sample.Utils.*;
33+
import static io.javaoperatorsdk.operator.sample.WebPageManagedDependentsReconciler.SELECTOR;
3334

3435
/** Shows how to implement reconciler using the low level api directly. */
35-
@ControllerConfiguration(
36-
labelSelector = WebPageReconciler.LOW_LEVEL_LABEL_KEY)
36+
@ControllerConfiguration
3737
public class WebPageReconciler
3838
implements Reconciler<WebPage>, ErrorStatusHandler<WebPage>, EventSourceInitializer<WebPage> {
3939

40-
public static final String LOW_LEVEL_LABEL_KEY = "low-level";
4140
public static final String INDEX_HTML = "index.html";
4241

4342
private static final Logger log = LoggerFactory.getLogger(WebPageReconciler.class);
@@ -52,19 +51,19 @@ public WebPageReconciler(KubernetesClient kubernetesClient) {
5251
public Map<String, EventSource> prepareEventSources(EventSourceContext<WebPage> context) {
5352
var configMapEventSource =
5453
new InformerEventSource<>(InformerConfiguration.from(ConfigMap.class, context)
55-
.withLabelSelector(LOW_LEVEL_LABEL_KEY)
54+
.withLabelSelector(SELECTOR)
5655
.build(), context);
5756
var deploymentEventSource =
5857
new InformerEventSource<>(InformerConfiguration.from(Deployment.class, context)
59-
.withLabelSelector(LOW_LEVEL_LABEL_KEY)
58+
.withLabelSelector(SELECTOR)
6059
.build(), context);
6160
var serviceEventSource =
6261
new InformerEventSource<>(InformerConfiguration.from(Service.class, context)
63-
.withLabelSelector(LOW_LEVEL_LABEL_KEY)
62+
.withLabelSelector(SELECTOR)
6463
.build(), context);
6564
var ingressEventSource =
6665
new InformerEventSource<>(InformerConfiguration.from(Ingress.class, context)
67-
.withLabelSelector(LOW_LEVEL_LABEL_KEY)
66+
.withLabelSelector(SELECTOR)
6867
.build(), context);
6968
return EventSourceInitializer.nameEventSources(configMapEventSource, deploymentEventSource,
7069
serviceEventSource, ingressEventSource);
@@ -224,7 +223,7 @@ private ConfigMap makeDesiredHtmlConfigMap(String ns, String configMapName, WebP
224223

225224
public static Map<String, String> lowLevelLabel() {
226225
Map<String, String> labels = new HashMap<>();
227-
labels.put(LOW_LEVEL_LABEL_KEY, "true");
226+
labels.put(SELECTOR, "true");
228227
return labels;
229228
}
230229

sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageStandaloneDependentsReconciler.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@
2222
/**
2323
* Shows how to implement reconciler using standalone dependent resources.
2424
*/
25-
@ControllerConfiguration(
26-
labelSelector = WebPageStandaloneDependentsReconciler.DEPENDENT_RESOURCE_LABEL_SELECTOR)
25+
@ControllerConfiguration
2726
public class WebPageStandaloneDependentsReconciler
2827
implements Reconciler<WebPage>, ErrorStatusHandler<WebPage>, EventSourceInitializer<WebPage> {
2928

30-
public static final String DEPENDENT_RESOURCE_LABEL_SELECTOR = "!low-level";
31-
3229
private static final Logger log =
3330
LoggerFactory.getLogger(WebPageStandaloneDependentsReconciler.class);
3431

0 commit comments

Comments
 (0)