Merge pull request #7329 from awanlin/topic/add-is-kubernetes-available

Add check for Kubernetes annotation on entity
This commit is contained in:
Patrik Oldsberg
2021-09-27 11:21:45 +02:00
committed by GitHub
4 changed files with 17 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-kubernetes': patch
---
Added a check for the Kubernetes annotation on the entity
+5
View File
@@ -33,6 +33,11 @@ export function formatClusterLink(
options: FormatClusterLinkOptions,
): string | undefined;
// Warning: (ae-missing-release-tag) "isKubernetesAvailable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const isKubernetesAvailable: (entity: Entity) => boolean;
// Warning: (ae-forgotten-export) The symbol "KubernetesAuthProvidersApi" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "KubernetesAuthProviders" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
+6
View File
@@ -27,6 +27,12 @@ const KUBERNETES_ANNOTATION = 'backstage.io/kubernetes-id';
const KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION =
'backstage.io/kubernetes-label-selector';
export const isKubernetesAvailable = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[KUBERNETES_ANNOTATION]) ||
Boolean(
entity.metadata.annotations?.[KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION],
);
type Props = {
/** @deprecated The entity is now grabbed from context instead */
entity?: Entity;
+1 -1
View File
@@ -25,6 +25,6 @@ export {
kubernetesPlugin as plugin,
EntityKubernetesContent,
} from './plugin';
export { Router } from './Router';
export { Router, isKubernetesAvailable } from './Router';
export * from './kubernetes-auth-provider';
export * from './utils/clusterLinks';