frontend/src/lib/kubernetes.ts
import {
GetClusters,
GetDeployments,
GetPods,
GetPod,
GetStatefulSets,
GetNamespace,
RestartDeployment,
RestartStatefulSet,
DeletePod,
DescribePod,
GetConfigMaps,
DescribeConfigMap,
DescribeDeployment,
DescribeStatefulSet,
GetIngresses,
DescribeIngress,
DescribeNamespace,
DeleteIngress,
DeleteNamespace,
CreatePod,
CreatePodYAML,
CreateNamespace,
CreateNamespaceYAML,
UpdatePodFromYaml,
UpdateNamespaceFromYaml,
GetNamespaces
} from '../../wailsjs/go/services/clusterService';
import {
Get as GetSecret,
List as ListSecrets,
Describe as DescribeSecret,
Create as CreateSecret,
Delete as DeleteSecret,
Update as UpdateSecret
} from '../../wailsjs/go/services/secretsService';
import {
List as ListPersistentVolumeClaims,
Describe as DescribePersistentVolumeClaim,
Create as CreatePersistentVolumeClaim,
Delete as DeletePersistentVolumeClaim,
} from '../../wailsjs/go/services/persistentVolumeClaimsService';
import {
List as ListPersistentVolumes,
Describe as DescribePersistentVolume,
Create as CreatePersistentVolume,
Delete as DeletePersistentVolume,
} from '../../wailsjs/go/services/persistentVolumesService';
import {
ApiResponse,
KubernetesCluster,
KubernetesConfigMap,
KubernetesDeployment,
KubernetesIngress,
KubernetesNamespace
} from '../types/kubernetes';
export interface KubernetesService {
getClusters(): Promise<ApiResponse<KubernetesCluster[]>>;
getDeployments(contextName: string, namespace?: string): Promise<ApiResponse<any[]>>;
getStatefulSets(contextName: string, namespace?: string): Promise<ApiResponse<KubernetesDeployment[]>>;
getPods(clusterName: string, namespace?: string): Promise<ApiResponse<any[]>>;
getPod(context: string, namespace: string, name: string): Promise<ApiResponse<any>>;
getConfigMaps(contextName: string, namespace: string): Promise<ApiResponse<KubernetesConfigMap[]>>;
getIngresses(context: string, namespace: string): Promise<ApiResponse<KubernetesIngress[]>>;
getNamespaces(context: string): Promise<ApiResponse<KubernetesNamespace[]>>;
getNamespace(context: string, name: string): Promise<ApiResponse<any>>;
getSecret(context: string, namespace: string, name: string): Promise<ApiResponse<any>>;
listSecrets(context: string, namespace: string): Promise<ApiResponse<any>>;
listPersistentVolumeClaims(context: string, namespace: string): Promise<ApiResponse<any>>;
listPersistentVolumes(context: string, namespace: string): Promise<ApiResponse<any>>;
restartDeployment(clusterName: string, namespace: string, name: string): Promise<ApiResponse<any>>;
restartStatefulSet(clusterName: string, namespace: string, name: string): Promise<ApiResponse<any>>;
describePod(clusterName: string, namespace: string, name: string): Promise<ApiResponse<string>>;
describeDeployment(context: string, namespace: string, name: string): Promise<ApiResponse<string>>;
describeConfigMap(context: string, namespace: string, name: string): Promise<ApiResponse<string>>;
describeStatefulSet(context: string, namespace: string, name: string): Promise<ApiResponse<string>>;
describeIngress(context: string, namespace: string, name: string): Promise<ApiResponse<string>>;
describeNamespace(context: string, namespace: string): Promise<ApiResponse<string>>;
describeSecret(context: string, namespace: string, name: string): Promise<ApiResponse<string>>;
describePersistentVolumeClaim(context: string, namespace: string, name: string): Promise<ApiResponse<string>>;
describePersistentVolume(context: string, namespace: string, name: string): Promise<ApiResponse<string>>;
deletePod(clusterName: string, namespace: string, name: string): Promise<ApiResponse<any>>;
deleteIngress(context: string, namespace: string, name: string): Promise<ApiResponse<string>>;
deleteNamespace(context: string, name: string): Promise<ApiResponse<any>>;
deleteSecret(context: string, namespace: string, name: string): Promise<ApiResponse<any>>;
deletePersistentVolume(context: string, name: string): Promise<ApiResponse<any>>;
deletePersistentVolumeClaim(context: string, namespace: string, name: string): Promise<ApiResponse<any>>;
createPod(context: string, podDefinition: any): Promise<ApiResponse<any>>;
createPodYAML(context: string, s: string): Promise<ApiResponse<any>>;
createNamespace(context: string, definition: any): Promise<ApiResponse<KubernetesNamespace>>;
createNamespaceYAML(context: string, definition: any): Promise<ApiResponse<any>>;
createSecret(context: string, definition: any): Promise<ApiResponse<any>>;
createPersistentVolume(context: string, definition: any): Promise<ApiResponse<any>>;
createPersistentVolumeClaim(context: string, definition: any): Promise<ApiResponse<any>>;
updatePod(context: string, s: string, originalPodname: string, originalNamespace: string): Promise<ApiResponse<any>>;
updateNamespace(context: string, s: string, originalName: string): Promise<ApiResponse<any>>;
updateSecret(context: string, input: string, originalNamespace: string, originalName: string): Promise<ApiResponse<any>>;
}
class KubernetesServiceImpl implements KubernetesService {
async getClusters(): Promise<ApiResponse<KubernetesCluster[]>> {
return GetClusters();
}
async getDeployments(contextName: string, namespace?: string): Promise<ApiResponse<any[]>> {
return GetDeployments(contextName, namespace || '');
}
async getPods(clusterName: string, namespace?: string): Promise<ApiResponse<any[]>> {
return GetPods(clusterName, namespace || '');
}
async getPod(context: string, namespace: string, name: string): Promise<ApiResponse<any>> {
return GetPod(context, namespace, name);
}
async getIngresses(context: string, namespace?: string): Promise<ApiResponse<KubernetesIngress[]>> {
return GetIngresses(context, namespace || '');
}
async getNamespaces(context: string): Promise<ApiResponse<any>> {
return GetNamespaces(context);
}
async getNamespace(context: string, name: string): Promise<ApiResponse<any>> {
return GetNamespace(context, name);
}
async getSecret(context: string, namespace: string, name: string): Promise<ApiResponse<any>> {
return GetSecret(context, namespace, name);
}
async describePod(clusterName: string, namespace: string, name: string): Promise<ApiResponse<any>> {
return DescribePod(clusterName, namespace, name);
}
async describeDeployment(context: string, namespace: string, name: string): Promise<ApiResponse<string>> {
return DescribeDeployment(context, namespace, name);
}
async describeConfigMap(context: string, namespace: string, name: string): Promise<ApiResponse<string>> {
return DescribeConfigMap(context, namespace, name);
}
async describeStatefulSet(context: string, namespace: string, name: string): Promise<ApiResponse<string>> {
return DescribeStatefulSet(context, namespace, name);
}
async describeIngress(context: string, namespace: string, name: string): Promise<ApiResponse<string>> {
return DescribeIngress(context, namespace, name);
}
async describeNamespace(context: string, namespace: string): Promise<ApiResponse<string>> {
return DescribeNamespace(context, namespace);
}
async describeSecret(context: string, namespace: string, name: string): Promise<ApiResponse<string>> {
return DescribeSecret(context, namespace, name);
}
async describePersistentVolumeClaim(context: string, namespace: string, name: string): Promise<ApiResponse<string>> {
return DescribePersistentVolumeClaim(context, namespace, name);
}
async describePersistentVolume(context: string, namespace: string, name: string): Promise<ApiResponse<string>> {
return DescribePersistentVolume(context, namespace, name);
}
async getStatefulSets(contextName: string, namespace?: string): Promise<ApiResponse<any[]>> {
return GetStatefulSets(contextName, namespace || '');
}
async restartDeployment(clusterName: string, namespace: string, name: string): Promise<ApiResponse<any>> {
return RestartDeployment(clusterName, namespace, name);
}
async restartStatefulSet(clusterName: string, namespace: string, name: string): Promise<ApiResponse<any>> {
return RestartStatefulSet(clusterName, namespace, name);
}
async getConfigMaps(contextName: string, namespace?: string): Promise<ApiResponse<KubernetesConfigMap[]>> {
return GetConfigMaps(contextName, namespace || '');
}
async deletePod(clusterName: string, namespace: string, name: string): Promise<ApiResponse<any>> {
return DeletePod(clusterName, namespace, name);
}
async deleteIngress(context: string, namespace: string, name: string): Promise<ApiResponse<string>> {
return DeleteIngress(context, namespace, name);
}
async deleteNamespace(context: string, name: string): Promise<ApiResponse<string>> {
return DeleteNamespace(context, name);
}
async deleteSecret(context: string, namespace: string, name: string): Promise<ApiResponse<string>> {
return DeleteSecret(context, namespace, name);
}
async deletePersistentVolume(context: string, name: string): Promise<ApiResponse<any>> {
return DeletePersistentVolume(context, name);
}
async deletePersistentVolumeClaim(context: string, namespace: string, name: string): Promise<ApiResponse<any>> {
return DeletePersistentVolumeClaim(context, namespace, name);
}
async createPod(context: string, podDefinition: any): Promise<ApiResponse<string>> {
return CreatePod(context, podDefinition);
}
async createPodYAML(context: string, s: string): Promise<ApiResponse<string>> {
return CreatePodYAML(context, s);
}
async createNamespace(context: string, definition: any): Promise<ApiResponse<any>> {
return CreateNamespace(context, definition);
}
async createNamespaceYAML(context: string, s: string): Promise<ApiResponse<any>> {
return CreateNamespaceYAML(context, s);
}
async createSecret(context: string, input: any): Promise<ApiResponse<any>> {
return CreateSecret(context, input);
}
async createPersistentVolume(context: string, definition: any): Promise<ApiResponse<any>> {
return CreatePersistentVolume(context, definition);
}
async createPersistentVolumeClaim(context: string, definition: any): Promise<ApiResponse<any>> {
return CreatePersistentVolumeClaim(context, definition);
}
async updatePod(context: string, s: string, originalPodname: string, originalNamespace: string): Promise<ApiResponse<any>> {
return UpdatePodFromYaml(context, s, originalPodname, originalNamespace);
}
async updateNamespace(context: string, s: string, originalName: string): Promise<ApiResponse<any>> {
return UpdateNamespaceFromYaml(context, s, originalName);
}
async updateSecret(context: string, input: string, originalNamespace: string, originalName: string): Promise<ApiResponse<any>> {
return UpdateSecret(context, input, originalNamespace, originalName);
}
async listSecrets(context: string, namespace?: string): Promise<ApiResponse<any>> {
return ListSecrets(context, namespace || '');
}
async listPersistentVolumeClaims(context: string, namespace?: string): Promise<ApiResponse<any>> {
return ListPersistentVolumeClaims(context, namespace || '');
}
async listPersistentVolumes(context: string): Promise<ApiResponse<any>> {
return ListPersistentVolumes(context);
}
}
export const kubernetesService: KubernetesService = new KubernetesServiceImpl();