/src/kuberesources.ts

https://github.com/Azure/vscode-kubernetes-tools · TypeScript · 64 lines · 57 code · 7 blank · 0 comment · 4 complexity · 452cf14b42e41e4da0a60082c467f97b MD5 · raw file

  1. import * as vscode from 'vscode';
  2. import { Dictionary } from './utils/dictionary';
  3. export class ResourceKind implements vscode.QuickPickItem {
  4. constructor(readonly displayName: string, readonly pluralDisplayName: string, readonly manifestKind: string, readonly abbreviation: string, readonly apiName?: string) {
  5. }
  6. get label() { return this.displayName; }
  7. get description() { return ''; }
  8. }
  9. export const allKinds: Dictionary<ResourceKind> = {
  10. endpoint: new ResourceKind("Endpoint", "Endpoints", "Endpoint", "endpoints", "endpoints"),
  11. namespace: new ResourceKind("Namespace", "Namespaces", "Namespace", "namespace" , "namespaces"),
  12. node: new ResourceKind("Node", "Nodes", "Node", "node", "nodes"),
  13. deployment: new ResourceKind("Deployment", "Deployments", "Deployment", "deployment", "deployments"),
  14. daemonSet: new ResourceKind("DaemonSet", "DaemonSets", "DaemonSet", "daemonset", "daemonsets"),
  15. replicaSet: new ResourceKind("ReplicaSet", "ReplicaSets", "ReplicaSet", "rs", "replicasets"),
  16. replicationController: new ResourceKind("Replication Controller", "Replication Controllers", "ReplicationController", "rc", "replicationcontrollers"),
  17. job: new ResourceKind("Job", "Jobs", "Job", "job", "jobs"),
  18. cronjob: new ResourceKind("CronJob", "CronJobs", "CronJob", "cronjob", "cronjobs"),
  19. pod: new ResourceKind("Pod", "Pods", "Pod", "pod", "pods"),
  20. crd: new ResourceKind("Custom Resource", "Custom Resources", "CustomResourceDefinition", "crd", "customresources"),
  21. service: new ResourceKind("Service", "Services", "Service", "service", "services"),
  22. configMap: new ResourceKind("ConfigMap", "Config Maps", "ConfigMap", "configmap", "configmaps"),
  23. secret: new ResourceKind("Secret", "Secrets", "Secret", "secret", "secrets"),
  24. ingress: new ResourceKind("Ingress", "Ingress", "Ingress", "ingress", "ingress"),
  25. persistentVolume: new ResourceKind("Persistent Volume", "Persistent Volumes", "PersistentVolume", "pv", "persistentvolumes"),
  26. persistentVolumeClaim: new ResourceKind("Persistent Volume Claim", "Persistent Volume Claims", "PersistentVolumeClaim", "pvc", "persistentvolumeclaims"),
  27. storageClass: new ResourceKind("Storage Class", "Storage Classes", "StorageClass", "sc", "storageclasses"),
  28. statefulSet: new ResourceKind("StatefulSet", "StatefulSets", "StatefulSet", "statefulset", "statefulsets")
  29. };
  30. export const commonKinds = [
  31. allKinds.deployment,
  32. allKinds.job,
  33. allKinds.pod,
  34. allKinds.service,
  35. ];
  36. export const scaleableKinds = [
  37. allKinds.deployment,
  38. allKinds.replicaSet,
  39. allKinds.replicationController,
  40. allKinds.job,
  41. allKinds.statefulSet,
  42. ];
  43. export const exposableKinds = [
  44. allKinds.deployment,
  45. allKinds.pod,
  46. allKinds.replicationController,
  47. allKinds.replicaSet,
  48. allKinds.service,
  49. ];
  50. export function findKind(manifestKind: string): ResourceKind | undefined {
  51. for (const k in allKinds) {
  52. if (allKinds[k].manifestKind === manifestKind) {
  53. return allKinds[k];
  54. }
  55. }
  56. return undefined;
  57. }