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:
@@ -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} />;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user