diff --git a/plugins/argo-workflows/src/api/index.ts b/plugins/argo-workflows/src/api/index.ts index 680f509..464a035 100644 --- a/plugins/argo-workflows/src/api/index.ts +++ b/plugins/argo-workflows/src/api/index.ts @@ -1,24 +1,24 @@ -import { createApiRef } from "@backstage/core-plugin-api"; +import { createApiRef } from '@backstage/core-plugin-api'; import { IoArgoprojWorkflowV1alpha1WorkflowList, IoArgoprojWorkflowV1alpha1WorkflowTemplateList, -} from "./generated/api"; +} from './generated/api'; -export { ArgoWorkflows } from "./ArgoWorkflows"; +export { ArgoWorkflows } from './ArgoWorkflows'; export const argoWorkflowsApiRef = createApiRef({ - id: "plugin.argoworkflows", + id: 'plugin.argoworkflows', }); export interface ArgoWorkflowsApi { getWorkflows( clusterName: string | undefined, namespace: string | undefined, - labels: string | undefined + labels: string | undefined, ): Promise; getWorkflowTemplates( clusterName: string | undefined, - namespace: string, - labels: string | undefined + namespace: string | undefined, + labels: string | undefined, ): Promise; -} +} \ No newline at end of file diff --git a/plugins/argo-workflows/src/components/utils.ts b/plugins/argo-workflows/src/components/utils.ts index 761a128..acf8698 100644 --- a/plugins/argo-workflows/src/components/utils.ts +++ b/plugins/argo-workflows/src/components/utils.ts @@ -2,6 +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'; @@ -19,7 +20,14 @@ export type getAnnotationValuesOutput = { }; export function getAnnotationValues(entity: Entity): getAnnotationValuesOutput { - const ns = entity.metadata.annotations?.[ARGO_WORKFLOWS_NAMESPACE_ANNOTATION]; + let ns = entity.metadata.annotations?.[ARGO_WORKFLOWS_NAMESPACE_ANNOTATION]; + if ( + entity.metadata.annotations?.[ARGO_WORKFLOWS_NAMESPACE_ANNOTATION] === + undefined && + entity.metadata.annotations?.[K8S_NAMESPACE_ANNOTATION] !== undefined + ) { + ns = entity.metadata.annotations?.[K8S_NAMESPACE_ANNOTATION]; + } const clusterName = entity.metadata.annotations?.[CLUSTER_NAME_ANNOTATION]; const labelSelector = entity.metadata?.annotations?.[ARGO_WORKFLOWS_LABEL_SELECTOR_ANNOTATION]; diff --git a/plugins/argo-workflows/src/plugin.ts b/plugins/argo-workflows/src/plugin.ts index 3c48ee0..5ef38c0 100644 --- a/plugins/argo-workflows/src/plugin.ts +++ b/plugins/argo-workflows/src/plugin.ts @@ -12,6 +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_WORKFLOWS_NAMESPACE_ANNOTATION = 'argo-workflows.cnoe.io/namespace'; export const ARGO_WORKFLOWS_LABEL_SELECTOR_ANNOTATION =