mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-04-04 11:32:15 +08:00
* Added ScaledJob support * Fixed getReplicaCount error * Fixed file length error in fileUtils.test.ts * Adjust scaledJob spec path * Made updateImagesInK8sObj more concise
84 lines
2.2 KiB
TypeScript
84 lines
2.2 KiB
TypeScript
export class KubernetesWorkload {
|
|
public static POD: string = 'Pod'
|
|
public static REPLICASET: string = 'Replicaset'
|
|
public static DEPLOYMENT: string = 'Deployment'
|
|
public static STATEFUL_SET: string = 'StatefulSet'
|
|
public static DAEMON_SET: string = 'DaemonSet'
|
|
public static JOB: string = 'job'
|
|
public static CRON_JOB: string = 'cronjob'
|
|
public static SCALED_JOB: string = 'scaledjob'
|
|
}
|
|
|
|
export class DiscoveryAndLoadBalancerResource {
|
|
public static SERVICE: string = 'service'
|
|
public static INGRESS: string = 'ingress'
|
|
}
|
|
|
|
export class ServiceTypes {
|
|
public static LOAD_BALANCER: string = 'LoadBalancer'
|
|
public static NODE_PORT: string = 'NodePort'
|
|
public static CLUSTER_IP: string = 'ClusterIP'
|
|
}
|
|
|
|
export const DEPLOYMENT_TYPES: string[] = [
|
|
'deployment',
|
|
'replicaset',
|
|
'daemonset',
|
|
'pod',
|
|
'statefulset'
|
|
]
|
|
|
|
export const WORKLOAD_TYPES: string[] = [
|
|
'deployment',
|
|
'replicaset',
|
|
'daemonset',
|
|
'pod',
|
|
'statefulset',
|
|
'job',
|
|
'cronjob',
|
|
'scaledjob'
|
|
]
|
|
|
|
export const WORKLOAD_TYPES_WITH_ROLLOUT_STATUS: string[] = [
|
|
'deployment',
|
|
'daemonset',
|
|
'statefulset'
|
|
]
|
|
|
|
export function isDeploymentEntity(kind: string): boolean {
|
|
if (!kind) throw ResourceKindNotDefinedError
|
|
|
|
return DEPLOYMENT_TYPES.some((type: string) => {
|
|
return type.toLowerCase() === kind.toLowerCase()
|
|
})
|
|
}
|
|
|
|
export function isWorkloadEntity(kind: string): boolean {
|
|
if (!kind) throw ResourceKindNotDefinedError
|
|
|
|
return WORKLOAD_TYPES.some(
|
|
(type: string) => type.toLowerCase() === kind.toLowerCase()
|
|
)
|
|
}
|
|
|
|
export function isServiceEntity(kind: string): boolean {
|
|
if (!kind) throw ResourceKindNotDefinedError
|
|
|
|
return 'service' === kind.toLowerCase()
|
|
}
|
|
|
|
export function isIngressEntity(kind: string): boolean {
|
|
if (!kind) throw ResourceKindNotDefinedError
|
|
|
|
return 'ingress' === kind.toLowerCase()
|
|
}
|
|
|
|
export const ResourceKindNotDefinedError = Error('Resource kind not defined')
|
|
export const NullInputObjectError = Error('Null inputObject')
|
|
export const InputObjectKindNotDefinedError = Error(
|
|
'Input object kind not defined'
|
|
)
|
|
export const InputObjectMetadataNotDefinedError = Error(
|
|
'Input object metatada not defined'
|
|
)
|