Provide backstage.io/kubernetes-id and backstage.io/kubernetes-label-selector annotations as exported constants (#28710)

* export default kubernetes annotations

Signed-off-by: Kurt King <kurtaking@gmail.com>

* replace deprecations

Signed-off-by: Kurt King <kurtaking@gmail.com>

* Add changesets

Signed-off-by: Kurt King <kurtaking@gmail.com>

* regenerate api reports

Signed-off-by: Kurt King <kurtaking@gmail.com>

* Update additional references

Signed-off-by: Kurt King <kurtaking@gmail.com>

* fix api reports

Signed-off-by: Kurt King <kurtaking@gmail.com>

---------

Signed-off-by: Kurt King <kurtaking@gmail.com>
This commit is contained in:
Kurt King
2025-02-21 06:41:39 -07:00
committed by GitHub
parent d9bc8b6bab
commit d517d13f74
7 changed files with 55 additions and 12 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-kubernetes-backend': patch
'@backstage/plugin-kubernetes': patch
---
refactor: use `KUBERNETES_ANNOTATION` and `KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION` annotations from `kubernetes-common`
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-kubernetes-common': patch
---
Export `backstage.io/kubernetes-id` and `backstage.io/kubernetes-label-selector` annotations as constants
+1 -1
View File
@@ -99,7 +99,7 @@ export type CustomResource = k8sAuthTypes.CustomResource;
export type CustomResourcesByEntity = k8sAuthTypes.CustomResourcesByEntity;
// @public (undocumented)
export const DEFAULT_OBJECTS: ObjectToFetch[];
export const DEFAULT_OBJECTS: ObjectToFetch_2[];
// @public
export class DispatchStrategy implements AuthenticationStrategy_2 {
@@ -16,13 +16,8 @@
import { Entity } from '@backstage/catalog-model';
import {
CustomResource,
FetchResponseWrapper,
KubernetesFetcher,
KubernetesObjectsProviderOptions,
KubernetesServiceLocator,
ObjectsByEntityRequest,
ObjectToFetch,
} from '../types/types';
import {
ClientContainerStatus,
@@ -31,6 +26,8 @@ import {
ClusterObjects,
CustomResourceMatcher,
FetchResponse,
KUBERNETES_ANNOTATION,
KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION,
KubernetesRequestAuth,
ObjectsByEntityResponse,
PodFetchResponse,
@@ -44,10 +41,15 @@ import {
import {
AuthenticationStrategy,
ClusterDetails,
CustomResource,
CustomResourcesByEntity,
FetchResponseWrapper,
KubernetesCredential,
KubernetesFetcher,
KubernetesObjectsByEntity,
KubernetesObjectsProvider,
KubernetesServiceLocator,
ObjectToFetch,
} from '@backstage/plugin-kubernetes-node';
import {
BackstageCredentials,
@@ -285,8 +287,8 @@ export class KubernetesFanOutHandler implements KubernetesObjectsProvider {
const labelSelector: string =
entity.metadata?.annotations?.[
'backstage.io/kubernetes-label-selector'
] || `backstage.io/kubernetes-id=${entityName}`;
KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION
] || `${KUBERNETES_ANNOTATION}=${entityName}`;
const namespace =
entity.metadata?.annotations?.['backstage.io/kubernetes-namespace'];
+7
View File
@@ -317,6 +317,13 @@ export interface JobsFetchResponse {
type: 'jobs';
}
// @public
export const KUBERNETES_ANNOTATION = 'backstage.io/kubernetes-id';
// @public
export const KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION =
'backstage.io/kubernetes-label-selector';
// @public
export const kubernetesClustersReadPermission: BasicPermission;
@@ -14,6 +14,29 @@
* limitations under the License.
*/
/**
* The annotation key used to identify Kubernetes resources in Backstage.
* This constant represents the standard annotation 'backstage.io/kubernetes-id'
* which links catalog entities to their corresponding Kubernetes resources.
*
* @public
*/
export const KUBERNETES_ANNOTATION = 'backstage.io/kubernetes-id';
/**
* Annotation used to specify a Kubernetes label selector query for filtering resources.
* When this annotation is added to a catalog entity, it defines criteria for selecting
* Kubernetes resources based on their labels.
*
* @public
*
* @remarks
* The value of this annotation should be a valid Kubernetes label selector query string.
* For example: 'app=my-app,environment=production'
*/
export const KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION =
'backstage.io/kubernetes-label-selector';
/**
* Annotation for specifying the API server of a Kubernetes cluster
*
+4 -4
View File
@@ -23,10 +23,10 @@ import {
import { Route, Routes } from 'react-router-dom';
import { KubernetesContent } from './KubernetesContent';
import Button from '@material-ui/core/Button';
const KUBERNETES_ANNOTATION = 'backstage.io/kubernetes-id';
const KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION =
'backstage.io/kubernetes-label-selector';
import {
KUBERNETES_ANNOTATION,
KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION,
} from '@backstage/plugin-kubernetes-common';
export const isKubernetesAvailable = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[KUBERNETES_ANNOTATION]) ||