Skip to content

Commit

Permalink
refactor: (4) inline functions into class methods
Browse files Browse the repository at this point in the history
  • Loading branch information
vvagaytsev committed Nov 8, 2023
1 parent 7d05f5a commit 30d0401
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 111 deletions.
78 changes: 38 additions & 40 deletions core/src/plugins/kubernetes/nginx/nginx-helm-ephemeral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,45 @@ import { HelmGardenIngressController } from "./nginx-helm.js"

export class EphemeralHelmGardenIngressController extends HelmGardenIngressController {
helmValuesGetter(): NginxHelmValuesGetter {
return getEphemeralNginxHelmValues
}
}

export const getEphemeralNginxHelmValues: NginxHelmValuesGetter = (systemVars: SystemVars) => {
return {
name: "ingress-controller",
controller: {
kind: "Deployment",
updateStrategy: {
type: "RollingUpdate",
rollingUpdate: {
maxUnavailable: 1,
return (systemVars: SystemVars) => {
return {
name: "ingress-controller",
controller: {
kind: "Deployment",
updateStrategy: {
type: "RollingUpdate",
rollingUpdate: {
maxUnavailable: 1,
},
},
extraArgs: {
"default-backend-service": `${systemVars.namespace}/default-backend`,
},
minReadySeconds: 1,
tolerations: systemVars["system-tolerations"],
nodeSelector: systemVars["system-node-selector"],
admissionWebhooks: {
enabled: false,
},
ingressClassResource: {
name: "nginx",
enabled: true,
default: true,
},
replicaCount: 1,
service: {
annotations: {
"kubernetes.namespace.so/expose": "true",
"kubernetes.namespace.so/exposed-port-80": "wildcard",
"kubernetes.namespace.so/exposed-port-443": "wildcard",
},
type: "LoadBalancer",
},
},
},
extraArgs: {
"default-backend-service": `${systemVars.namespace}/default-backend`,
},
minReadySeconds: 1,
tolerations: systemVars["system-tolerations"],
nodeSelector: systemVars["system-node-selector"],
admissionWebhooks: {
enabled: false,
},
ingressClassResource: {
name: "nginx",
enabled: true,
default: true,
},
replicaCount: 1,
service: {
annotations: {
"kubernetes.namespace.so/expose": "true",
"kubernetes.namespace.so/exposed-port-80": "wildcard",
"kubernetes.namespace.so/exposed-port-443": "wildcard",
defaultBackend: {
enabled: false,
},
type: "LoadBalancer",
},
},
defaultBackend: {
enabled: false,
},
}
}
}
}
74 changes: 36 additions & 38 deletions core/src/plugins/kubernetes/nginx/nginx-helm-generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,43 @@ import { HelmGardenIngressController } from "./nginx-helm.js"

export class GenericHelmGardenIngressController extends HelmGardenIngressController {
helmValuesGetter(): NginxHelmValuesGetter {
return getGenericNginxHelmValues
}
}

export const getGenericNginxHelmValues: NginxHelmValuesGetter = (systemVars: SystemVars) => {
return {
name: "ingress-controller",
controller: {
kind: "DaemonSet",
updateStrategy: {
type: "RollingUpdate",
rollingUpdate: {
maxUnavailable: 1,
return (systemVars: SystemVars) => {
return {
name: "ingress-controller",
controller: {
kind: "DaemonSet",
updateStrategy: {
type: "RollingUpdate",
rollingUpdate: {
maxUnavailable: 1,
},
},
extraArgs: {
"default-backend-service": `${systemVars.namespace}/default-backend`,
},
minReadySeconds: 1,
tolerations: systemVars["system-tolerations"],
nodeSelector: systemVars["system-node-selector"],
admissionWebhooks: {
enabled: false,
},
ingressClassResource: {
name: "nginx",
enabled: true,
default: true,
},
hostPort: {
enabled: true,
ports: {
http: systemVars["ingress-http-port"],
https: systemVars["ingress-https-port"],
},
},
},
},
extraArgs: {
"default-backend-service": `${systemVars.namespace}/default-backend`,
},
minReadySeconds: 1,
tolerations: systemVars["system-tolerations"],
nodeSelector: systemVars["system-node-selector"],
admissionWebhooks: {
enabled: false,
},
ingressClassResource: {
name: "nginx",
enabled: true,
default: true,
},
hostPort: {
enabled: true,
ports: {
http: systemVars["ingress-http-port"],
https: systemVars["ingress-https-port"],
defaultBackend: {
enabled: false,
},
},
},
defaultBackend: {
enabled: false,
},
}
}
}
}
64 changes: 31 additions & 33 deletions core/src/plugins/kubernetes/nginx/nginx-helm-k3s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,37 @@ import { HelmGardenIngressController } from "./nginx-helm.js"

export class K3sHelmGardenIngressController extends HelmGardenIngressController {
helmValuesGetter(): NginxHelmValuesGetter {
return getK3sNginxHelmValues
}
}

export const getK3sNginxHelmValues: NginxHelmValuesGetter = (systemVars: SystemVars) => {
return {
name: "ingress-controller",
controller: {
kind: "Deployment",
updateStrategy: {
type: "RollingUpdate",
rollingUpdate: {
maxUnavailable: 1,
return (systemVars: SystemVars) => {
return {
name: "ingress-controller",
controller: {
kind: "Deployment",
updateStrategy: {
type: "RollingUpdate",
rollingUpdate: {
maxUnavailable: 1,
},
},
extraArgs: {
"default-backend-service": `${systemVars.namespace}/default-backend`,
},
minReadySeconds: 1,
tolerations: systemVars["system-tolerations"],
nodeSelector: systemVars["system-node-selector"],
admissionWebhooks: {
enabled: false,
},
ingressClassResource: {
name: "nginx",
enabled: true,
default: true,
},
replicaCount: 1,
},
defaultBackend: {
enabled: false,
},
},
extraArgs: {
"default-backend-service": `${systemVars.namespace}/default-backend`,
},
minReadySeconds: 1,
tolerations: systemVars["system-tolerations"],
nodeSelector: systemVars["system-node-selector"],
admissionWebhooks: {
enabled: false,
},
ingressClassResource: {
name: "nginx",
enabled: true,
default: true,
},
replicaCount: 1,
},
defaultBackend: {
enabled: false,
},
}
}
}
}

0 comments on commit 30d0401

Please sign in to comment.