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)
This commit is contained in:
Fidel Coria
2021-02-19 17:05:18 -06:00
parent 6f0ed05c2c
commit 272d960550
2 changed files with 19 additions and 12 deletions
+18 -10
View File
@@ -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 <MissingAnnotationEmptyState annotation={KUBERNETES_ANNOTATION} />;
const kubernetesLabelSelectorQueryAnnotationValue =
entity.metadata.annotations?.[KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION];
if (
kubernetesAnnotationValue ||
kubernetesLabelSelectorQueryAnnotationValue
) {
return (
<Routes>
<Route
path={`/${rootCatalogKubernetesRouteRef.path}`}
element={<KubernetesContent entity={entity} />}
/>
</Routes>
);
}
return (
<Routes>
<Route
path={`/${rootCatalogKubernetesRouteRef.path}`}
element={<KubernetesContent entity={entity} />}
/>
</Routes>
);
return <MissingAnnotationEmptyState annotation={KUBERNETES_ANNOTATION} />;
};
+1 -2
View File
@@ -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==