From 272d96055077f1cee2420a35d61a6df2b32a8eb3 Mon Sep 17 00:00:00 2001 From: Fidel Coria Date: Fri, 19 Feb 2021 17:05:18 -0600 Subject: [PATCH] load k8s info with only label selector query [Docs](https://backstage.io/docs/features/kubernetes/configuration#surfacing-your-kubernetes-components-as-part-of-an-entity) say `label selector takes precedence over the annotation/service id.` but ``` annotations: 'backstage.io/kubernetes-id': dice-roller ``` is always required. updated logic to allow for only label selector (without backstage.io/kubernetes-id) --- plugins/kubernetes/src/Router.tsx | 28 ++++++++++++++++++---------- yarn.lock | 3 +-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/plugins/kubernetes/src/Router.tsx b/plugins/kubernetes/src/Router.tsx index 36851b3c46..5197e4811d 100644 --- a/plugins/kubernetes/src/Router.tsx +++ b/plugins/kubernetes/src/Router.tsx @@ -23,6 +23,8 @@ import { KubernetesContent } from './components/KubernetesContent'; import { MissingAnnotationEmptyState } from '@backstage/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 +37,22 @@ 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 ( - - } - /> - - ); + return ; }; diff --git a/yarn.lock b/yarn.lock index c32766faa3..90e7e8bb14 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1874,7 +1874,6 @@ "@backstage/catalog-model" "^0.7.1" "@backstage/core" "^0.6.2" "@backstage/plugin-catalog-react" "^0.0.4" - "@backstage/plugin-scaffolder" "^0.5.1" "@backstage/theme" "^0.2.3" "@material-ui/core" "^4.11.0" "@material-ui/icons" "^4.9.1" @@ -18238,7 +18237,7 @@ modify-values@^1.0.0: resolved "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw== -moment@^2.19.3, moment@^2.25.3, moment@^2.26.0, moment@^2.27.0: +moment@^2.19.3, moment@^2.25.3, moment@^2.27.0: version "2.29.1" resolved "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3" integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==