From fe832ac53d63232e62b0e885650bdcec35d85dab Mon Sep 17 00:00:00 2001 From: Mani Marothu Date: Mon, 16 Sep 2024 16:10:26 -0700 Subject: [PATCH 1/2] Added argo workflows namespace annotation Signed-off-by: Mani Marothu --- README.md | 25 +++++++++++++++++++++---- src/components/utils.ts | 7 ++----- src/plugin.ts | 2 +- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d70b8da..af4bf1f 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ kind: Component metadata: name: backstage annotations: - backstage.io/kubernetes-namespace: default + argo-workflows.cnoe.io/namespace: default argo-workflows.cnoe.io/label-selector: env=dev,my=label spec: type: service @@ -172,7 +172,7 @@ kubernetes: caData: LS0t ``` -For this configuration, the `argo-workflows/cluster-name` annotaton value must be `my-cluster-1` +For this configuration, the `argo-workflows.cnoe.io/cluster-name` annotaton value must be `my-cluster-1` ```yaml apiVersion: backstage.io/v1alpha1 @@ -180,12 +180,29 @@ kind: Component metadata: name: backstage annotations: - backstage.io/kubernetes-namespace: default + argo-workflows.cnoe.io/namespace: default argo-workflows.cnoe.io/label-selector: env=dev,my=label - argo-workflows/cluster-name: my-cluster-1 + argo-workflows.cnoe.io/cluster-name: my-cluster-1 spec: type: service lifecycle: experimental owner: user1 system: system1 ``` + +If we remove the `argo-workflows.cnoe.io/namespace` annotation, it will show all label matched workflows across all namespaces. + +```yaml +apiVersion: backstage.io/v1alpha1 +kind: Component +metadata: + name: backstage + annotations: + argo-workflows.cnoe.io/label-selector: env=dev,my=label + argo-workflows.cnoe.io/cluster-name: my-cluster-1 +spec: + type: service + lifecycle: experimental + owner: user1 + system: system1 +``` \ No newline at end of file diff --git a/src/components/utils.ts b/src/components/utils.ts index 9bd75e3..757ac21 100644 --- a/src/components/utils.ts +++ b/src/components/utils.ts @@ -2,7 +2,7 @@ import {Entity} from "@backstage/catalog-model"; import { ARGO_WORKFLOWS_LABEL_SELECTOR_ANNOTATION, CLUSTER_NAME_ANNOTATION, - K8S_NAMESPACE_ANNOTATION, + ARGO_WORKFLOWS_NAMESPACE_ANNOTATION, } from "../plugin"; export function trimBaseUrl(argoWorkflowsBaseUrl: string | undefined) { @@ -19,10 +19,7 @@ export type getAnnotationValuesOutput = { }; export function getAnnotationValues(entity: Entity): getAnnotationValuesOutput { - const ns = - entity.metadata.annotations?.[K8S_NAMESPACE_ANNOTATION] !== undefined - ? entity.metadata.annotations?.[K8S_NAMESPACE_ANNOTATION] - : "default"; + const ns = entity.metadata.annotations?.[ARGO_WORKFLOWS_NAMESPACE_ANNOTATION]; const clusterName = entity.metadata.annotations?.[CLUSTER_NAME_ANNOTATION]; const labelSelector = entity.metadata?.annotations?.[ARGO_WORKFLOWS_LABEL_SELECTOR_ANNOTATION] return { diff --git a/src/plugin.ts b/src/plugin.ts index 595a2cf..523815d 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -12,7 +12,7 @@ import {ArgoWorkflows, argoWorkflowsApiRef} from "./api"; import {kubernetesApiRef} from "@backstage/plugin-kubernetes"; export const CLUSTER_NAME_ANNOTATION = "argo-workflows.cnoe.io/cluster-name"; -export const K8S_NAMESPACE_ANNOTATION = "backstage.io/kubernetes-namespace"; +export const ARGO_WORKFLOW_NAMESPACE_ANNOTATION = "argo-workflows.cnoe.io/namespace"; export const ARGO_WORKFLOWS_LABEL_SELECTOR_ANNOTATION = "argo-workflows.cnoe.io/label-selector"; From eab4941de11a0107cc7ea82d77a49204e73830c3 Mon Sep 17 00:00:00 2001 From: Mani Marothu Date: Mon, 16 Sep 2024 16:11:20 -0700 Subject: [PATCH 2/2] Added argo workflows namespace annotation Signed-off-by: Mani Marothu --- src/plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.ts b/src/plugin.ts index 523815d..b80bc15 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -12,7 +12,7 @@ import {ArgoWorkflows, argoWorkflowsApiRef} from "./api"; import {kubernetesApiRef} from "@backstage/plugin-kubernetes"; export const CLUSTER_NAME_ANNOTATION = "argo-workflows.cnoe.io/cluster-name"; -export const ARGO_WORKFLOW_NAMESPACE_ANNOTATION = "argo-workflows.cnoe.io/namespace"; +export const ARGO_WORKFLOWS_NAMESPACE_ANNOTATION = "argo-workflows.cnoe.io/namespace"; export const ARGO_WORKFLOWS_LABEL_SELECTOR_ANNOTATION = "argo-workflows.cnoe.io/label-selector";