Skip to content
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

feat(cli,webserver): hidden labels #5600

Merged
merged 3 commits into from
Oct 23, 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
5 changes: 5 additions & 0 deletions cli/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,8 @@ kestra:
uri: https://api.kestra.io/v1/reports/usages
initial-delay: 5m
fixed-delay: 1h

hidden-labels:
prefixes:
- system_
- internal_
16 changes: 14 additions & 2 deletions ui/src/components/executions/Executions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@

<el-table-column v-if="displayColumn('labels')" :label="$t('labels')">
<template #default="scope">
<labels :labels="scope.row.labels" />
<labels :labels="filteredLabels(scope.row.labels)" />
</template>
</el-table-column>

Expand Down Expand Up @@ -438,7 +438,7 @@
</script>

<script>
import {mapState} from "vuex";
import {mapState, mapGetters} from "vuex";
import DataTable from "../layout/DataTable.vue";
import TextSearch from "vue-material-design-icons/TextSearch.vue";
import Status from "../Status.vue";
Expand Down Expand Up @@ -629,6 +629,7 @@
...mapState("stat", ["daily"]),
...mapState("auth", ["user"]),
...mapState("flow", ["flow"]),
...mapGetters("misc", ["configs"]),
routeInfo() {
return {
title: this.$t("executions")
Expand Down Expand Up @@ -709,6 +710,17 @@
});
},
methods: {
filteredLabels(labels) {
const toIgnore = this.configs.hiddenLabelsPrefixes || [];

// Extract only the keys from the route query labels
const allowedLabels = this.$route.query.labels ? this.$route.query.labels.map(label => label.split(":")[0]) : [];

return labels?.filter(label => {
// Check if the label key matches any prefix but allow it if it's in the query
return !toIgnore.some(prefix => label.key.startsWith(prefix)) || allowedLabels.includes(label.key);
});
},
executionParams(row) {
return {
namespace: row.namespace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ public static ExecutionResponse fromExecution(Execution execution, URI url) {
}

protected Pair<List<Label>, List<Label>> parseLabels(List<String> labels) {
// We allow passing the correlation id from the API but only this one, other system labels will go throught and fail at execution creation.
// We allow passing the correlation id from the API but only this one, other system labels will go through and fail at execution creation.
List<Label> parsedLabels = labels == null ? Collections.emptyList() : RequestUtils.toMap(labels).entrySet().stream()
.map(entry -> new Label(entry.getKey(), entry.getValue()))
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import lombok.extern.slf4j.Slf4j;

import java.time.ZonedDateTime;
import java.util.List;
import java.util.Optional;

@Slf4j
Expand Down Expand Up @@ -69,6 +70,9 @@ public class MiscController {
@io.micronaut.context.annotation.Value("${kestra.server.preview.max-rows:5000}")
private Integer maxPreviewRows;

@io.micronaut.context.annotation.Value("${kestra.hidden-labels.prefixes:}")
private List<String> hiddenLabelsPrefixes;


@Get("{/tenant}/configs")
@ExecuteOn(TaskExecutors.IO)
Expand All @@ -88,7 +92,8 @@ public Configuration configuration() throws JsonProcessingException {
.max(this.maxPreviewRows)
.build()
).isBasicAuthEnabled(basicAuthService.isEnabled())
.systemNamespace(namespaceUtils.getSystemFlowNamespace());
.systemNamespace(namespaceUtils.getSystemFlowNamespace())
.hiddenLabelsPrefixes(hiddenLabelsPrefixes);

if (this.environmentName != null || this.environmentColor != null) {
builder.environment(
Expand Down Expand Up @@ -148,6 +153,8 @@ public static class Configuration {
Boolean isBasicAuthEnabled;

String systemNamespace;

List<String> hiddenLabelsPrefixes;
}

@Value
Expand Down