Creating extension point for kubernetesFetcher
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 { KubernetesFetcher } from '@backstage/plugin-kubernetes-backend';
|
||||
import { AuthenticationStrategy } from '@backstage/plugin-kubernetes-node';
|
||||
import { KubernetesClustersSupplier } from '@backstage/plugin-kubernetes-node';
|
||||
import { KubernetesObjectsProvider } from '@backstage/plugin-kubernetes-node';
|
||||
@@ -74,3 +75,22 @@ export const kubernetesAuthStrategyExtensionPoint =
|
||||
createExtensionPoint<KubernetesAuthStrategyExtensionPoint>({
|
||||
id: 'kubernetes.auth-strategy',
|
||||
});
|
||||
|
||||
/**
|
||||
* The interface for {@link kubernetesFetcherExtensionPoint}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface KubernetesFetcherExtensionPoint {
|
||||
addFetcher(fetcher: KubernetesFetcher): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* An extension point the exposes the ability to configure a kubernetes fetcher.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const kubernetesFetcherExtensionPoint =
|
||||
createExtensionPoint<KubernetesFetcherExtensionPoint>({
|
||||
id: 'kubernetes.fetcher',
|
||||
});
|
||||
|
||||
@@ -29,13 +29,5 @@
|
||||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
export {
|
||||
kubernetesObjectsProviderExtensionPoint,
|
||||
type KubernetesObjectsProviderExtensionPoint,
|
||||
kubernetesClusterSupplierExtensionPoint,
|
||||
type KubernetesClusterSupplierExtensionPoint,
|
||||
kubernetesAuthStrategyExtensionPoint,
|
||||
type KubernetesAuthStrategyExtensionPoint,
|
||||
} from './extensions';
|
||||
|
||||
export * from './extensions';
|
||||
export * from './types';
|
||||
|
||||
@@ -14,8 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { KubernetesObjectTypes } from '@backstage/plugin-kubernetes-backend';
|
||||
import {
|
||||
CustomResourceMatcher,
|
||||
FetchResponse,
|
||||
KubernetesFetchError,
|
||||
KubernetesRequestAuth,
|
||||
ObjectsByEntityResponse,
|
||||
} from '@backstage/plugin-kubernetes-common';
|
||||
@@ -150,3 +153,62 @@ export interface AuthenticationStrategy {
|
||||
): Promise<KubernetesCredential>;
|
||||
validateCluster(authMetadata: AuthMetadata): Error[];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ObjectToFetch {
|
||||
objectType: KubernetesObjectTypes; // TODO - Review
|
||||
group: string;
|
||||
apiVersion: string;
|
||||
plural: string;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface CustomResource extends ObjectToFetch {
|
||||
objectType: 'customresources';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ObjectFetchParams {
|
||||
serviceId: string;
|
||||
clusterDetails: ClusterDetails;
|
||||
credential: KubernetesCredential;
|
||||
objectTypesToFetch: Set<ObjectToFetch>;
|
||||
labelSelector?: string;
|
||||
customResources: CustomResource[];
|
||||
namespace?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface FetchResponseWrapper {
|
||||
errors: KubernetesFetchError[];
|
||||
responses: FetchResponse[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches information from a kubernetes cluster using the cluster details object to target a specific cluster
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface KubernetesFetcher {
|
||||
fetchObjectsForService(
|
||||
params: ObjectFetchParams,
|
||||
): Promise<FetchResponseWrapper>;
|
||||
fetchPodMetricsByNamespaces(
|
||||
clusterDetails: ClusterDetails,
|
||||
credential: KubernetesCredential,
|
||||
namespaces: Set<string>,
|
||||
labelSelector?: string,
|
||||
): Promise<FetchResponseWrapper>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user