refactor code in order to support multiple dashboard link formatters
Signed-off-by: Morgan Martinet <morgan.martinet@montreal.ca>
This commit is contained in:
@@ -27,9 +27,8 @@ export interface AWSClusterDetails extends ClusterDetails {
|
||||
export interface ClusterDetails {
|
||||
// (undocumented)
|
||||
authProvider: string;
|
||||
// (undocumented)
|
||||
dashboardApp?: string;
|
||||
dashboardUrl?: string;
|
||||
// (undocumented)
|
||||
name: string;
|
||||
// (undocumented)
|
||||
serviceAccountToken?: string | undefined;
|
||||
|
||||
@@ -41,6 +41,10 @@ export class ConfigClusterLocator implements KubernetesClustersSupplier {
|
||||
if (dashboardUrl) {
|
||||
clusterDetails.dashboardUrl = dashboardUrl;
|
||||
}
|
||||
const dashboardApp = c.getOptionalString('dashboardApp');
|
||||
if (dashboardApp) {
|
||||
clusterDetails.dashboardApp = dashboardApp;
|
||||
}
|
||||
|
||||
switch (authProvider) {
|
||||
case 'google': {
|
||||
|
||||
@@ -124,6 +124,9 @@ export class KubernetesFanOutHandler {
|
||||
if (clusterDetailsItem.dashboardUrl) {
|
||||
objects.cluster.dashboardUrl = clusterDetailsItem.dashboardUrl;
|
||||
}
|
||||
if (clusterDetailsItem.dashboardApp) {
|
||||
objects.cluster.dashboardApp = clusterDetailsItem.dashboardApp;
|
||||
}
|
||||
return objects;
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -75,12 +75,39 @@ export interface KubernetesServiceLocator {
|
||||
export type ServiceLocatorMethod = 'multiTenant' | 'http'; // TODO implement http
|
||||
|
||||
export interface ClusterDetails {
|
||||
/**
|
||||
* Specifies the name of the Kubernetes cluster.
|
||||
*/
|
||||
name: string;
|
||||
url: string;
|
||||
authProvider: string;
|
||||
serviceAccountToken?: string | undefined;
|
||||
skipTLSVerify?: boolean;
|
||||
/**
|
||||
* Specifies the link to the Kubernetes dashboard managing this cluster.
|
||||
* @remarks
|
||||
* Note that you need to specify the app used for the dashboard
|
||||
* using the dashboardApp property, in order to properly format
|
||||
* links to kubernetes resources.
|
||||
* @see dashboardApp
|
||||
*/
|
||||
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 formatters dictionary.
|
||||
* @defaultValue standard
|
||||
* @see dashboardUrl
|
||||
* @example
|
||||
* ```ts
|
||||
* import { clusterLinksFormatters } from '@backstage/plugin-kubernetes';
|
||||
* clusterLinksFormatters.myDashboard = (options) => ...;
|
||||
* ```
|
||||
*/
|
||||
dashboardApp?: string;
|
||||
}
|
||||
|
||||
export interface GKEClusterDetails extends ClusterDetails {}
|
||||
|
||||
Reference in New Issue
Block a user