kubernetes-backend: Moves backend specific types back from common

Signed-off-by: Juan Lulkin <jmaiz@spotify.com>
This commit is contained in:
Juan Lulkin
2021-04-15 11:48:01 +02:00
parent a3b25f6c2e
commit 219313b29d
2 changed files with 113 additions and 116 deletions
+108 -10
View File
@@ -14,18 +14,116 @@
* limitations under the License.
*/
export type {
ClusterDetails,
CustomResource,
import type {
FetchResponse,
KubernetesFetchError,
} from '@backstage/plugin-kubernetes-common';
export type {
FetchResponse,
FetchResponseWrapper,
KubernetesClustersSupplier,
KubernetesErrorTypes,
KubernetesFetchError,
KubernetesFetcher,
KubernetesObjectTypes,
KubernetesRequestBody,
KubernetesServiceLocator,
ObjectFetchParams,
ServiceLocatorMethod,
} from '@backstage/plugin-kubernetes-common';
export type ClusterLocatorMethod =
| ConfigClusterLocatorMethod
| GKEClusterLocatorMethod;
export interface ConfigClusterLocatorMethod {
/**
* @visibility frontend
*/
type: 'config';
clusters: {
/**
* @visibility frontend
*/
url: string;
/**
* @visibility frontend
*/
name: string;
/**
* @visibility secret
*/
serviceAccountToken: string | undefined;
/**
* @visibility frontend
*/
authProvider: 'aws' | 'google' | 'serviceAccount';
}[];
}
export interface GKEClusterLocatorMethod {
/**
* @visibility frontend
*/
type: 'gke';
/**
* @visibility frontend
*/
projectId: string;
/**
* @visibility frontend
*/
region?: string;
}
export interface CustomResource {
group: string;
apiVersion: string;
plural: string;
}
export interface ObjectFetchParams {
serviceId: string;
clusterDetails: ClusterDetails;
objectTypesToFetch: Set<KubernetesObjectTypes>;
labelSelector: string;
customResources: CustomResource[];
}
// Fetches information from a kubernetes cluster using the cluster details object
// to target a specific cluster
export interface KubernetesFetcher {
fetchObjectsForService(
params: ObjectFetchParams,
): Promise<FetchResponseWrapper>;
}
export interface FetchResponseWrapper {
errors: KubernetesFetchError[];
responses: FetchResponse[];
}
// TODO fairly sure there's a easier way to do this
export type KubernetesObjectTypes =
| 'pods'
| 'services'
| 'configmaps'
| 'deployments'
| 'replicasets'
| 'horizontalpodautoscalers'
| 'ingresses'
| 'customresources';
// Used to load cluster details from different sources
export interface KubernetesClustersSupplier {
getClusters(): Promise<ClusterDetails[]>;
}
// Used to locate which cluster(s) a service is running on
export interface KubernetesServiceLocator {
getClustersByServiceId(serviceId: string): Promise<ClusterDetails[]>;
}
export type ServiceLocatorMethod = 'multiTenant' | 'http'; // TODO implement http
export interface ClusterDetails {
name: string;
url: string;
authProvider: string;
serviceAccountToken?: string | undefined;
}