Skip to content

Commit

Permalink
Allow adding labels to routes
Browse files Browse the repository at this point in the history
  • Loading branch information
xstefank authored and holly-cummins committed Jul 31, 2024
1 parent a2f992f commit 39c3f9f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<kotlin.coroutine.version>1.8.1</kotlin.coroutine.version>
<azure.toolkit-lib.version>0.27.0</azure.toolkit-lib.version>
<kotlin-serialization.version>1.7.1</kotlin-serialization.version>
<dekorate.version>4.1.3</dekorate.version> <!-- Please check with Java Operator SDK team before updating -->
<dekorate.version>4.1.4</dekorate.version> <!-- Please check with Java Operator SDK team before updating -->
<maven-invoker.version>3.2.0</maven-invoker.version>
<awaitility.version>4.2.1</awaitility.version>
<jboss-logmanager.version>3.0.6.Final</jboss-logmanager.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic
result.add(new DecoratorBuildItem(OPENSHIFT,
new AddAnnotationDecorator(name, annotation.getKey(), annotation.getValue(), ROUTE)));
}

for (Map.Entry<String, String> label : config.route.labels.entrySet()) {
result.add(new DecoratorBuildItem(OPENSHIFT,
new AddLabelDecorator(name, label.getKey(), label.getValue(), ROUTE)));
}
}

if (config.getReplicas() != 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public class RouteConfig {
@ConfigDocMapKey("annotation-name")
Map<String, String> annotations;

/**
* Custom labels to add to exposition (route or ingress) resources
*/
@ConfigItem
@ConfigDocMapKey("label-name")
Map<String, String> labels;

/**
* The TLS configuration for the route.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void assertGeneratedResources() throws IOException {
assertThat(m.getLabels()).contains(entry("foo", "bar"));
assertThat(m.getAnnotations()).contains(entry("bar", "baz"));
assertThat(m.getAnnotations()).contains(entry("kubernetes.io/tls-acme", "true"));
assertThat(m.getLabels()).contains(entry("test-label", "test-value"));
});
assertThat(r.getSpec().getPort().getTargetPort().getStrVal()).isEqualTo("http");
assertThat(r.getSpec().getTo().getKind()).isEqualTo("Service");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ quarkus.openshift.labels.foo=bar
quarkus.openshift.annotations.bar=baz

quarkus.openshift.route.annotations."kubernetes.io/tls-acme"=true
quarkus.openshift.route.labels."test-label"=test-value

0 comments on commit 39c3f9f

Please sign in to comment.