Creating extension point for kubernetesClusterSupplier
Signed-off-by: Andres Mauricio Gomez P <andmagom@outlook.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createExtensionPoint } from '@backstage/backend-plugin-api';
|
||||
import { KubernetesClustersSupplier } from '@backstage/plugin-kubernetes-node';
|
||||
import { KubernetesObjectsProvider } from '@backstage/plugin-kubernetes-node';
|
||||
|
||||
/**
|
||||
@@ -34,3 +35,22 @@ export const kubernetesObjectsProviderExtensionPoint =
|
||||
createExtensionPoint<KubernetesObjectsProviderExtensionPoint>({
|
||||
id: 'kubernetes.objects-provider',
|
||||
});
|
||||
|
||||
/**
|
||||
* The interface for {@link kubernetesClusterSupplierExtensionPoint}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface KubernetesClusterSupplierExtensionPoint {
|
||||
addClusterSupplier(clusterSupplier: KubernetesClustersSupplier): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* An extension point the exposes the ability to configure a cluster supplier.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const kubernetesClusterSupplierExtensionPoint =
|
||||
createExtensionPoint<KubernetesClusterSupplierExtensionPoint>({
|
||||
id: 'kubernetes.cluster-supplier',
|
||||
});
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
export {
|
||||
kubernetesObjectsProviderExtensionPoint,
|
||||
type KubernetesObjectsProviderExtensionPoint,
|
||||
kubernetesClusterSupplierExtensionPoint,
|
||||
type KubernetesClusterSupplierExtensionPoint,
|
||||
} from './extensions';
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
KubernetesRequestAuth,
|
||||
ObjectsByEntityResponse,
|
||||
} from '@backstage/plugin-kubernetes-common';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -51,3 +52,81 @@ export interface KubernetesObjectsByEntity {
|
||||
export interface CustomResourcesByEntity extends KubernetesObjectsByEntity {
|
||||
customResources: CustomResourceMatcher[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider-specific authentication configuration
|
||||
* @public
|
||||
*/
|
||||
export type AuthMetadata = Record<string, string>;
|
||||
|
||||
/**
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ClusterDetails {
|
||||
/**
|
||||
* Specifies the name of the Kubernetes cluster.
|
||||
*/
|
||||
name: string;
|
||||
url: string;
|
||||
authMetadata: AuthMetadata;
|
||||
skipTLSVerify?: boolean;
|
||||
/**
|
||||
* Whether to skip the lookup to the metrics server to retrieve pod resource usage.
|
||||
* It is not guaranteed that the Kubernetes distro has the metrics server installed.
|
||||
*/
|
||||
skipMetricsLookup?: boolean;
|
||||
caData?: string | undefined;
|
||||
caFile?: string | undefined;
|
||||
/**
|
||||
* Specifies the link to the Kubernetes dashboard managing this cluster.
|
||||
* @remarks
|
||||
* Note that you should specify the app used for the dashboard
|
||||
* using the dashboardApp property, in order to properly format
|
||||
* links to kubernetes resources, otherwise it will assume that you're running the standard one.
|
||||
* @see dashboardApp
|
||||
* @see dashboardParameters
|
||||
*/
|
||||
dashboardUrl?: string;
|
||||
/**
|
||||
* Specifies the app that provides the Kubernetes dashboard.
|
||||
* This will be used for formatting links to kubernetes objects inside the dashboard.
|
||||
* @remarks
|
||||
* The existing apps are: standard, rancher, openshift, gke, aks, eks
|
||||
* Note that it will default to the regular dashboard provided by the Kubernetes project (standard).
|
||||
* Note that you can add your own formatter by registering it to the clusterLinksFormatters dictionary.
|
||||
* @defaultValue standard
|
||||
* @see dashboardUrl
|
||||
* @example
|
||||
* ```ts
|
||||
* import { clusterLinksFormatters } from '@backstage/plugin-kubernetes';
|
||||
* clusterLinksFormatters.myDashboard = (options) => ...;
|
||||
* ```
|
||||
*/
|
||||
dashboardApp?: string;
|
||||
/**
|
||||
* Specifies specific parameters used by some dashboard URL formatters.
|
||||
* This is used by the GKE formatter which requires the project, region and cluster name.
|
||||
* @see dashboardApp
|
||||
*/
|
||||
dashboardParameters?: JsonObject;
|
||||
/**
|
||||
* Specifies which custom resources to look for when returning an entity's
|
||||
* Kubernetes resources.
|
||||
*/
|
||||
customResources?: CustomResourceMatcher[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to load cluster details from different sources
|
||||
* @public
|
||||
*/
|
||||
export interface KubernetesClustersSupplier {
|
||||
/**
|
||||
* Returns the cached list of clusters.
|
||||
*
|
||||
* Implementations _should_ cache the clusters and refresh them periodically,
|
||||
* as getClusters is called whenever the list of clusters is needed.
|
||||
*/
|
||||
getClusters(): Promise<ClusterDetails[]>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user