Skip to content

improve: glue label naming #89

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
Apr 27, 2024
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
6 changes: 3 additions & 3 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ custom resource tracked, so if there is a label selector defined for `Glue` it n
to the `Glue` resource when it is created. Since it is not trivial to parse label selectors, in more
complex forms of label selectors (other the ones mentioned above), the labels to add to the `Glue` resources
by a `GlueOperator` needs to be specified explicitly using
[`glue.operator.glue-operator-managed-glue-labels`](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/main/java/io/csviri/operator/glue/ControllerConfig.java#L10-L10)
[`glue.operator.glue-operator-managed-glue-label`](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/main/java/io/csviri/operator/glue/ControllerConfig.java#L10-L10)
config key (which is a type of map). Therefore, for a label selector that specified two values for a glue:

`quarkus.operator-sdk.controllers.glue.selector=mylabel1=value1,mylabel2=value2`

you need to add the following configuration params:

`glue.operator.glue-operator-managed-glue-labels.mylabel1=value1`
`glue.operator.glue-operator-managed-glue-label.mylabel1=value1`

`glue.operator.glue-operator-managed-glue-labels.mylabel2=value2`
`glue.operator.glue-operator-managed-glue-label.mylabel2=value2`

This will ensure that the labels are added correctly to the `Glue`. See the related
[integration test](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/java/io/csviri/operator/glue/GlueOperatorComplexLabelSelectorTest.java#L23-L23).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
@ConfigMapping(prefix = "glue.operator")
public interface ControllerConfig {

Map<String, String> glueOperatorManagedGlueLabels();
Map<String, String> glueOperatorManagedGlueLabel();

}
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ public static String glueName(String name, String kind) {

private Map<String, String> initDefaultLabelsToAddToGlue() {
Map<String, String> res = new HashMap<>();
if (!controllerConfig.glueOperatorManagedGlueLabels().isEmpty()) {
res.putAll(controllerConfig.glueOperatorManagedGlueLabels());
if (!controllerConfig.glueOperatorManagedGlueLabel().isEmpty()) {
res.putAll(controllerConfig.glueOperatorManagedGlueLabel());
} else {
glueLabelSelector.ifPresent(ls -> {
if (ls.contains(",") || ls.contains("(")) {
throw new GlueException(
"Glue reconciler label selector contains non-simple label selector: " + ls +
". Specify Glue label selector in simple form ('key=value' or 'key') " +
"or configure 'glue.operator.glue-operator-managed-glue-labels'");
"or configure 'glue.operator.glue-operator-managed-glue-label'");
}
String[] labelSelectorParts = ls.split("=");
if (labelSelectorParts.length > 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public Map<String, String> getConfigOverrides() {
// complex label selector with 2 values checked
GLUE_LABEL_KEY1 + "=" + LABEL_VALUE + "," + GLUE_LABEL_KEY2 + "=" + LABEL_VALUE,
// explicit labels added to glue
"glue.operator.glue-operator-managed-glue-labels." + GLUE_LABEL_KEY1, LABEL_VALUE,
"glue.operator.glue-operator-managed-glue-labels." + GLUE_LABEL_KEY2, LABEL_VALUE);
"glue.operator.glue-operator-managed-glue-label." + GLUE_LABEL_KEY1, LABEL_VALUE,
"glue.operator.glue-operator-managed-glue-label." + GLUE_LABEL_KEY2, LABEL_VALUE);
}
}

Expand Down
Loading