Skip to content

feat: unified samples label usage #1234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
import io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource;

import static io.javaoperatorsdk.operator.sample.Utils.*;
import static io.javaoperatorsdk.operator.sample.WebPageManagedDependentsReconciler.SELECTOR;

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

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

private static final Logger log = LoggerFactory.getLogger(WebPageReconciler.class);
Expand All @@ -52,19 +51,19 @@ public WebPageReconciler(KubernetesClient kubernetesClient) {
public Map<String, EventSource> prepareEventSources(EventSourceContext<WebPage> context) {
var configMapEventSource =
new InformerEventSource<>(InformerConfiguration.from(ConfigMap.class, context)
.withLabelSelector(LOW_LEVEL_LABEL_KEY)
.withLabelSelector(SELECTOR)
.build(), context);
var deploymentEventSource =
new InformerEventSource<>(InformerConfiguration.from(Deployment.class, context)
.withLabelSelector(LOW_LEVEL_LABEL_KEY)
.withLabelSelector(SELECTOR)
.build(), context);
var serviceEventSource =
new InformerEventSource<>(InformerConfiguration.from(Service.class, context)
.withLabelSelector(LOW_LEVEL_LABEL_KEY)
.withLabelSelector(SELECTOR)
.build(), context);
var ingressEventSource =
new InformerEventSource<>(InformerConfiguration.from(Ingress.class, context)
.withLabelSelector(LOW_LEVEL_LABEL_KEY)
.withLabelSelector(SELECTOR)
.build(), context);
return EventSourceInitializer.nameEventSources(configMapEventSource, deploymentEventSource,
serviceEventSource, ingressEventSource);
Expand Down Expand Up @@ -224,7 +223,7 @@ private ConfigMap makeDesiredHtmlConfigMap(String ns, String configMapName, WebP

public static Map<String, String> lowLevelLabel() {
Map<String, String> labels = new HashMap<>();
labels.put(LOW_LEVEL_LABEL_KEY, "true");
labels.put(SELECTOR, "true");
return labels;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
/**
* Shows how to implement reconciler using standalone dependent resources.
*/
@ControllerConfiguration(
labelSelector = WebPageStandaloneDependentsReconciler.DEPENDENT_RESOURCE_LABEL_SELECTOR)
@ControllerConfiguration
public class WebPageStandaloneDependentsReconciler
implements Reconciler<WebPage>, ErrorStatusHandler<WebPage>, EventSourceInitializer<WebPage> {

public static final String DEPENDENT_RESOURCE_LABEL_SELECTOR = "!low-level";

private static final Logger log =
LoggerFactory.getLogger(WebPageStandaloneDependentsReconciler.class);

Expand Down