diff --git a/.changeset/afraid-weeks-sort.md b/.changeset/afraid-weeks-sort.md new file mode 100644 index 0000000000..c5ec608daf --- /dev/null +++ b/.changeset/afraid-weeks-sort.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-kubernetes': patch +--- + +k8s plugin now surfaces k8s components with only label selector query annotation. +Previously backstage.io/kubernetes-label-selector catalog entity annotation would only work if you also included backstage.io/kubernetes-id. +But backstage.io/kubernetes-id value was ignored diff --git a/plugins/kubernetes/src/Router.tsx b/plugins/kubernetes/src/Router.tsx index 36851b3c46..838bfef60a 100644 --- a/plugins/kubernetes/src/Router.tsx +++ b/plugins/kubernetes/src/Router.tsx @@ -21,8 +21,11 @@ import { Route, Routes } from 'react-router-dom'; import { rootCatalogKubernetesRouteRef } from './plugin'; import { KubernetesContent } from './components/KubernetesContent'; import { MissingAnnotationEmptyState } from '@backstage/core'; +import { Button } from '@material-ui/core'; const KUBERNETES_ANNOTATION = 'backstage.io/kubernetes-id'; +const KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION = + 'backstage.io/kubernetes-label-selector'; type Props = { /** @deprecated The entity is now grabbed from context instead */ @@ -35,16 +38,37 @@ export const Router = (_props: Props) => { const kubernetesAnnotationValue = entity.metadata.annotations?.[KUBERNETES_ANNOTATION]; - if (!kubernetesAnnotationValue) { - return ; + const kubernetesLabelSelectorQueryAnnotationValue = + entity.metadata.annotations?.[KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION]; + + if ( + kubernetesAnnotationValue || + kubernetesLabelSelectorQueryAnnotationValue + ) { + return ( + + } + /> + + ); } return ( - - } - /> - + <> + +

+ Or use a label selector query, which takes precedence over the previous + annotation. +

+ + ); };