k8ts 0.4.23 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.imports.tsbuildinfo +1 -1
- package/dist/_imports/k8s.d.ts +1 -1
- package/dist/_imports/k8s.js +1 -1
- package/dist/_type/prefix$.d.ts +4 -0
- package/dist/_type/prefix$.d.ts.map +1 -0
- package/dist/_type/prefix$.js +3 -0
- package/dist/_type/prefix$.js.map +1 -0
- package/dist/file/factory.d.ts +1 -1
- package/dist/file/factory.d.ts.map +1 -1
- package/dist/file/factory.js +3 -3
- package/dist/file/factory.js.map +1 -1
- package/dist/resources/deployment/deployment.d.ts +2 -2
- package/dist/resources/deployment/deployment.d.ts.map +1 -1
- package/dist/resources/deployment/deployment.js +3 -3
- package/dist/resources/deployment/deployment.js.map +1 -1
- package/dist/resources/http-route/http-route.d.ts +3 -3
- package/dist/resources/http-route/http-route.d.ts.map +1 -1
- package/dist/resources/http-route/http-route.js +5 -5
- package/dist/resources/http-route/http-route.js.map +1 -1
- package/dist/resources/persistent/claim/pvc.d.ts +5 -4
- package/dist/resources/persistent/claim/pvc.d.ts.map +1 -1
- package/dist/resources/persistent/claim/pvc.js +6 -6
- package/dist/resources/persistent/claim/pvc.js.map +1 -1
- package/dist/resources/persistent/volume/pv.d.ts +4 -4
- package/dist/resources/persistent/volume/pv.d.ts.map +1 -1
- package/dist/resources/persistent/volume/pv.js +6 -6
- package/dist/resources/persistent/volume/pv.js.map +1 -1
- package/dist/resources/pod/container/container.d.ts +7 -5
- package/dist/resources/pod/container/container.d.ts.map +1 -1
- package/dist/resources/pod/container/container.js +11 -10
- package/dist/resources/pod/container/container.js.map +1 -1
- package/dist/resources/pod/pod-template.d.ts +1 -5
- package/dist/resources/pod/pod-template.d.ts.map +1 -1
- package/dist/resources/pod/pod-template.js +2 -2
- package/dist/resources/pod/pod-template.js.map +1 -1
- package/dist/resources/pod/volume/devices.d.ts +1 -1
- package/dist/resources/pod/volume/devices.d.ts.map +1 -1
- package/dist/resources/pod/volume/devices.js +2 -2
- package/dist/resources/pod/volume/devices.js.map +1 -1
- package/dist/resources/pod/volume/volumes.d.ts +3 -3
- package/dist/resources/pod/volume/volumes.d.ts.map +1 -1
- package/dist/resources/pod/volume/volumes.js +6 -6
- package/dist/resources/pod/volume/volumes.js.map +1 -1
- package/dist/resources/service/service.d.ts +3 -3
- package/dist/resources/service/service.d.ts.map +1 -1
- package/dist/resources/service/service.js +6 -6
- package/dist/resources/service/service.js.map +1 -1
- package/dist/src.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/_imports/k8s.ts +2 -2
- package/src/_type/prefix$.ts +3 -0
- package/src/file/factory.ts +4 -4
- package/src/resources/deployment/deployment.ts +6 -6
- package/src/resources/http-route/http-route.ts +8 -8
- package/src/resources/persistent/claim/pvc.ts +11 -10
- package/src/resources/persistent/volume/pv.ts +10 -10
- package/src/resources/pod/container/container.ts +18 -15
- package/src/resources/pod/pod-template.ts +5 -8
- package/src/resources/pod/volume/devices.ts +3 -3
- package/src/resources/pod/volume/volumes.ts +9 -9
- package/src/resources/service/service.ts +9 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { manifest, Origin, Refable, relations, WritableDeep } from "@k8ts/instruments"
|
|
2
2
|
import { Meta, MutableMeta } from "@k8ts/metadata"
|
|
3
|
-
import { omit } from "lodash"
|
|
3
|
+
import { omit, omitBy } from "lodash"
|
|
4
4
|
import { CDK } from "../../_imports"
|
|
5
5
|
import { MakeError } from "../../error"
|
|
6
6
|
import { k8ts } from "../../kind-map"
|
|
@@ -20,8 +20,8 @@ export namespace Deployment {
|
|
|
20
20
|
Omit<CDK.DeploymentSpec, "selector" | "template" | "strategy">
|
|
21
21
|
>
|
|
22
22
|
export type Props<Ports extends string> = NormalProps & {
|
|
23
|
-
template: PodTemplate.Props<Ports>
|
|
24
|
-
strategy?: DeploymentStrategy
|
|
23
|
+
$template: PodTemplate.Props<Ports>
|
|
24
|
+
$strategy?: DeploymentStrategy
|
|
25
25
|
}
|
|
26
26
|
export type AbsDeployment<Ports extends string> = Refable<api.apps_.v1_.Deployment> & {
|
|
27
27
|
__PORTS__: Ports
|
|
@@ -38,7 +38,7 @@ export namespace Deployment {
|
|
|
38
38
|
const noKindFields = omit(template, ["kind", "apiVersion"])
|
|
39
39
|
return {
|
|
40
40
|
spec: {
|
|
41
|
-
...
|
|
41
|
+
...omitBy(self.props, (x, k) => k.startsWith("$")),
|
|
42
42
|
selector: {
|
|
43
43
|
matchLabels: {
|
|
44
44
|
app: self.name
|
|
@@ -56,7 +56,7 @@ export namespace Deployment {
|
|
|
56
56
|
template: PodTemplate<Ports>
|
|
57
57
|
|
|
58
58
|
private get _strategy() {
|
|
59
|
-
const strat = this.props
|
|
59
|
+
const strat = this.props.$strategy
|
|
60
60
|
if (!strat) {
|
|
61
61
|
return undefined
|
|
62
62
|
}
|
|
@@ -79,7 +79,7 @@ export namespace Deployment {
|
|
|
79
79
|
name: this.name,
|
|
80
80
|
"%app": this.name
|
|
81
81
|
}),
|
|
82
|
-
props
|
|
82
|
+
props.$template
|
|
83
83
|
)
|
|
84
84
|
}
|
|
85
85
|
get ports() {
|
|
@@ -11,16 +11,16 @@ export type HttpRoute<Ports extends string> = HttpRoute.HttpRoute<Ports>
|
|
|
11
11
|
|
|
12
12
|
export namespace HttpRoute {
|
|
13
13
|
export interface Props<Ports extends string> {
|
|
14
|
-
gateway: External<api.gateway_.v1_.Gateway>
|
|
15
|
-
hostname: string
|
|
16
|
-
backend: Service.Port<Ports>
|
|
14
|
+
$gateway: External<api.gateway_.v1_.Gateway>
|
|
15
|
+
$hostname: string
|
|
16
|
+
$backend: Service.Port<Ports>
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
@k8ts(api.gateway_.v1_.HttpRoute)
|
|
20
20
|
@relations({
|
|
21
21
|
needs: self => ({
|
|
22
|
-
gateway: self.props
|
|
23
|
-
service: self.props
|
|
22
|
+
gateway: self.props.$gateway,
|
|
23
|
+
service: self.props.$backend.service
|
|
24
24
|
})
|
|
25
25
|
})
|
|
26
26
|
@equiv_cdk8s(CDK.HttpRoute)
|
|
@@ -28,11 +28,11 @@ export namespace HttpRoute {
|
|
|
28
28
|
body(self): CDK.HttpRouteProps {
|
|
29
29
|
return {
|
|
30
30
|
spec: {
|
|
31
|
-
parentRefs: [self.props
|
|
32
|
-
hostnames: [self.props
|
|
31
|
+
parentRefs: [self.props.$gateway.ref()],
|
|
32
|
+
hostnames: [self.props.$hostname],
|
|
33
33
|
rules: [
|
|
34
34
|
{
|
|
35
|
-
backendRefs: [self.props
|
|
35
|
+
backendRefs: [self.props.$backend.ref()]
|
|
36
36
|
}
|
|
37
37
|
]
|
|
38
38
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { manifest, relations, ResourcesSpec, Unit } from "@k8ts/instruments"
|
|
2
2
|
import { CDK } from "../../../_imports"
|
|
3
|
+
import { Prefix$ } from "../../../_type/prefix$"
|
|
3
4
|
import { k8ts } from "../../../kind-map"
|
|
4
5
|
import { api } from "../../../kinds"
|
|
5
6
|
import { ManifestResource } from "../../../node"
|
|
@@ -14,11 +15,11 @@ export namespace Pvc {
|
|
|
14
15
|
storage: Unit.Data
|
|
15
16
|
})
|
|
16
17
|
type PvcResourceSpec = typeof pvc_ResourcesSpec
|
|
17
|
-
type PvcResources = PvcResourceSpec["__INPUT__"]
|
|
18
|
+
type PvcResources = Prefix$<PvcResourceSpec["__INPUT__"]>
|
|
18
19
|
export interface Props<Mode extends DataMode> extends PvcResources {
|
|
19
|
-
accessModes: Access
|
|
20
|
-
mode?: Mode
|
|
21
|
-
bind: Pv.AbsPv<Mode>
|
|
20
|
+
$accessModes: Access
|
|
21
|
+
$mode?: Mode
|
|
22
|
+
$bind: Pv.AbsPv<Mode>
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
@k8ts(api.v1_.PersistentVolumeClaim)
|
|
@@ -30,16 +31,16 @@ export namespace Pvc {
|
|
|
30
31
|
})
|
|
31
32
|
@manifest({
|
|
32
33
|
body(self): CDK.KubePersistentVolumeClaimProps {
|
|
33
|
-
const { storage, accessModes, mode } = self.props
|
|
34
|
-
const nAccessModes = Access.parse(accessModes)
|
|
34
|
+
const { $storage, $accessModes, $mode } = self.props
|
|
35
|
+
const nAccessModes = Access.parse($accessModes)
|
|
35
36
|
return {
|
|
36
37
|
spec: {
|
|
37
38
|
accessModes: nAccessModes,
|
|
38
|
-
volumeName: self.props
|
|
39
|
-
volumeMode: mode,
|
|
39
|
+
volumeName: self.props.$bind!.name,
|
|
40
|
+
volumeMode: $mode,
|
|
40
41
|
resources: pvc_ResourcesSpec
|
|
41
42
|
.parse({
|
|
42
|
-
storage
|
|
43
|
+
storage: $storage
|
|
43
44
|
})
|
|
44
45
|
.toObject(),
|
|
45
46
|
storageClassName: "standard"
|
|
@@ -51,7 +52,7 @@ export namespace Pvc {
|
|
|
51
52
|
kind = api.v1_.PersistentVolumeClaim
|
|
52
53
|
|
|
53
54
|
get bound() {
|
|
54
|
-
return this.props
|
|
55
|
+
return this.props.$bind as Pv<Mode>
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -14,12 +14,12 @@ export type Pv<T extends DataMode = DataMode> = Pv.Pv<T>
|
|
|
14
14
|
export namespace Pv {
|
|
15
15
|
export import Backend = Backend_
|
|
16
16
|
export interface Props<Mode extends DataMode = DataMode> {
|
|
17
|
-
accessModes: Access
|
|
17
|
+
$accessModes: Access
|
|
18
18
|
storageClassName?: string
|
|
19
|
-
mode?: Mode
|
|
19
|
+
$mode?: Mode
|
|
20
20
|
reclaimPolicy?: Reclaim
|
|
21
|
-
capacity: Unit.Data
|
|
22
|
-
backend: Backend
|
|
21
|
+
$capacity: Unit.Data
|
|
22
|
+
$backend: Backend
|
|
23
23
|
nodeAffinity?: CDK.VolumeNodeAffinity
|
|
24
24
|
}
|
|
25
25
|
export type Reclaim = "Retain" | "Delete" | "Recycle"
|
|
@@ -30,8 +30,8 @@ export namespace Pv {
|
|
|
30
30
|
@manifest({
|
|
31
31
|
body(self) {
|
|
32
32
|
const pvProps = self.props
|
|
33
|
-
const accessModes = Access.parse(pvProps
|
|
34
|
-
if (self.props
|
|
33
|
+
const accessModes = Access.parse(pvProps.$accessModes)
|
|
34
|
+
if (self.props.$backend.type === "Local") {
|
|
35
35
|
if (!pvProps.nodeAffinity) {
|
|
36
36
|
throw new MakeError(
|
|
37
37
|
`While manifesting ${self.node.format("source")}, PV with Local backend must have nodeAffinity.`
|
|
@@ -41,18 +41,18 @@ export namespace Pv {
|
|
|
41
41
|
let base: CDK.PersistentVolumeSpec = {
|
|
42
42
|
accessModes,
|
|
43
43
|
storageClassName: pvProps.storageClassName ?? "standard",
|
|
44
|
-
capacity: pvProps
|
|
44
|
+
capacity: pvProps.$capacity
|
|
45
45
|
? {
|
|
46
|
-
storage: CDK.Quantity.fromString(pvProps
|
|
46
|
+
storage: CDK.Quantity.fromString(pvProps.$capacity)
|
|
47
47
|
}
|
|
48
48
|
: undefined,
|
|
49
|
-
volumeMode: pvProps
|
|
49
|
+
volumeMode: pvProps.$mode ?? "Filesystem",
|
|
50
50
|
persistentVolumeReclaimPolicy: pvProps.reclaimPolicy ?? "Retain",
|
|
51
51
|
nodeAffinity: pvProps.nodeAffinity
|
|
52
52
|
}
|
|
53
53
|
base = {
|
|
54
54
|
...base,
|
|
55
|
-
...parseBackend(pvProps
|
|
55
|
+
...parseBackend(pvProps.$backend)
|
|
56
56
|
}
|
|
57
57
|
return {
|
|
58
58
|
spec: base
|
|
@@ -16,7 +16,7 @@ import type { CDK } from "../../../_imports"
|
|
|
16
16
|
import { toContainerPorts, toEnvVars } from "../../utils/adapters"
|
|
17
17
|
|
|
18
18
|
import { seq } from "doddle"
|
|
19
|
-
import { mapKeys, mapValues } from "lodash"
|
|
19
|
+
import { mapKeys, mapValues, omitBy } from "lodash"
|
|
20
20
|
import { k8ts } from "../../../kind-map"
|
|
21
21
|
import { api } from "../../../kinds"
|
|
22
22
|
import type { ManifestResource } from "../../../node"
|
|
@@ -36,17 +36,19 @@ export namespace Container {
|
|
|
36
36
|
[key: string]: SomeMount
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
interface K8tsPropsClean<Ports extends string = never> {
|
|
40
40
|
image: TaggedImage
|
|
41
41
|
ports?: InputPortSetRecord<Ports>
|
|
42
42
|
command?: CmdBuilder
|
|
43
43
|
mounts?: Mounts
|
|
44
44
|
env?: InputEnvMapping
|
|
45
|
-
securityContext?: CDK.SecurityContext
|
|
46
45
|
resources?: Resources
|
|
47
46
|
}
|
|
47
|
+
export type K8tsProps<Ports extends string = never> = {
|
|
48
|
+
[key in keyof K8tsPropsClean<Ports> as `$${key}`]: K8tsPropsClean<Ports>[key]
|
|
49
|
+
}
|
|
48
50
|
export type Props<Ports extends string = never> = K8tsProps<Ports> &
|
|
49
|
-
WritableDeep<Omit<CDK.Container, keyof
|
|
51
|
+
WritableDeep<Omit<CDK.Container, keyof K8tsPropsClean | "name">>
|
|
50
52
|
|
|
51
53
|
@k8ts(api.v1_.Pod_.Container)
|
|
52
54
|
@relations({
|
|
@@ -63,7 +65,7 @@ export namespace Container {
|
|
|
63
65
|
readonly kind = api.v1_.Pod_.Container
|
|
64
66
|
|
|
65
67
|
get mounts() {
|
|
66
|
-
return Map(this.props
|
|
68
|
+
return Map(this.props.$mounts ?? {})
|
|
67
69
|
.mapEntries(([path, mount]) => {
|
|
68
70
|
return [
|
|
69
71
|
mount,
|
|
@@ -84,19 +86,20 @@ export namespace Container {
|
|
|
84
86
|
.pull()
|
|
85
87
|
}
|
|
86
88
|
get ports() {
|
|
87
|
-
return PortSet.make(this.props
|
|
89
|
+
return PortSet.make(this.props.$ports)
|
|
88
90
|
}
|
|
89
91
|
submanifest(): CDK.Container {
|
|
90
92
|
const self = this
|
|
91
|
-
const { image, ports, command, env
|
|
93
|
+
const { $image, $ports, $command, $env } = self.props
|
|
94
|
+
const untaggedProps = omitBy(self.props, (_, k) => k.startsWith("$"))
|
|
92
95
|
const container: CDK.Container = {
|
|
96
|
+
...untaggedProps,
|
|
93
97
|
name: self.name,
|
|
94
|
-
image: image.toString(),
|
|
95
|
-
ports: ports && toContainerPorts(PortSet.make(ports)).valueSeq().toArray(),
|
|
98
|
+
image: $image.toString(),
|
|
99
|
+
ports: $ports && toContainerPorts(PortSet.make($ports)).valueSeq().toArray(),
|
|
96
100
|
resources: self._resources()?.toObject(),
|
|
97
|
-
command: command?.toArray(),
|
|
98
|
-
env: toEnvVars(Env(env)).valueSeq().toArray(),
|
|
99
|
-
securityContext,
|
|
101
|
+
command: $command?.toArray(),
|
|
102
|
+
env: toEnvVars(Env($env)).valueSeq().toArray(),
|
|
100
103
|
...self._groupedMounts()
|
|
101
104
|
}
|
|
102
105
|
return container
|
|
@@ -105,7 +108,7 @@ export namespace Container {
|
|
|
105
108
|
parent: ManifestResource,
|
|
106
109
|
name: string,
|
|
107
110
|
readonly subtype: "init" | "main",
|
|
108
|
-
override readonly props:
|
|
111
|
+
override readonly props: Props<Ports>
|
|
109
112
|
) {
|
|
110
113
|
super(parent, name, props)
|
|
111
114
|
}
|
|
@@ -126,10 +129,10 @@ export namespace Container {
|
|
|
126
129
|
return x
|
|
127
130
|
}
|
|
128
131
|
private _resources() {
|
|
129
|
-
if (!this.props
|
|
132
|
+
if (!this.props.$resources) {
|
|
130
133
|
return undefined
|
|
131
134
|
}
|
|
132
|
-
const { cpu, memory } = this.props
|
|
135
|
+
const { cpu, memory } = this.props.$resources
|
|
133
136
|
return container_ResourcesSpec.parse({
|
|
134
137
|
cpu: cpu,
|
|
135
138
|
memory: memory
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Kinded, manifest, Producer, relations } from "@k8ts/instruments"
|
|
2
2
|
import { seq } from "doddle"
|
|
3
|
-
import {
|
|
3
|
+
import { omitBy } from "lodash"
|
|
4
4
|
import { CDK } from "../../_imports"
|
|
5
5
|
import { k8ts } from "../../kind-map"
|
|
6
6
|
import { api } from "../../kinds"
|
|
@@ -15,7 +15,7 @@ export namespace PodTemplate {
|
|
|
15
15
|
}
|
|
16
16
|
export type PodContainerProducer<Ports extends string> = Producer<PodScope, AbsContainer<Ports>>
|
|
17
17
|
export type Props<Ports extends string> = PodProps & {
|
|
18
|
-
POD: PodContainerProducer<Ports>
|
|
18
|
+
$POD: PodContainerProducer<Ports>
|
|
19
19
|
}
|
|
20
20
|
export type HostPortSpec<Ports extends string> = {
|
|
21
21
|
[port in Ports]?: {
|
|
@@ -23,10 +23,7 @@ export namespace PodTemplate {
|
|
|
23
23
|
port?: number
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
hostNetwork?: boolean
|
|
28
|
-
ports: HostPortSpec<Ports>
|
|
29
|
-
}
|
|
26
|
+
|
|
30
27
|
@k8ts(api.v1_.PodTemplate)
|
|
31
28
|
@relations({
|
|
32
29
|
kids: s => [...s.containers, ...s.volumes]
|
|
@@ -47,7 +44,7 @@ export namespace PodTemplate {
|
|
|
47
44
|
const volumes = self.volumes.map(x => x.submanifest()).toArray()
|
|
48
45
|
return {
|
|
49
46
|
spec: {
|
|
50
|
-
...
|
|
47
|
+
...omitBy(props, (x, k) => k.startsWith("$")),
|
|
51
48
|
containers: mainContainers.pull(),
|
|
52
49
|
initContainers: initContainers.pull(),
|
|
53
50
|
volumes: volumes.pull()
|
|
@@ -57,7 +54,7 @@ export namespace PodTemplate {
|
|
|
57
54
|
})
|
|
58
55
|
export class PodTemplate<Ports extends string = string> extends ManifestResource<Props<Ports>> {
|
|
59
56
|
readonly kind = api.v1_.PodTemplate
|
|
60
|
-
readonly containers = seq(() => this.props
|
|
57
|
+
readonly containers = seq(() => this.props.$POD(new PodScope(this)))
|
|
61
58
|
.map(x => {
|
|
62
59
|
return x as Container<Ports>
|
|
63
60
|
})
|
|
@@ -9,7 +9,7 @@ import { Mount } from "../container/mounts"
|
|
|
9
9
|
export type Device = Device.PodDevice
|
|
10
10
|
export namespace Device {
|
|
11
11
|
interface PodDevice_Backend_Pvc {
|
|
12
|
-
backend: Pvc.Pvc<"Block">
|
|
12
|
+
$backend: Pvc.Pvc<"Block">
|
|
13
13
|
readOnly?: boolean
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -17,7 +17,7 @@ export namespace Device {
|
|
|
17
17
|
@k8ts(api.v1_.Pod_.Device)
|
|
18
18
|
@relations({
|
|
19
19
|
needs: self => ({
|
|
20
|
-
backend: self.backend
|
|
20
|
+
backend: self.backend.$backend
|
|
21
21
|
})
|
|
22
22
|
})
|
|
23
23
|
export class PodDevice extends SubResource<PodDevice_Backend_Pvc> {
|
|
@@ -34,7 +34,7 @@ export namespace Device {
|
|
|
34
34
|
return {
|
|
35
35
|
name: this.name,
|
|
36
36
|
persistentVolumeClaim: {
|
|
37
|
-
claimName: this.backend
|
|
37
|
+
claimName: this.backend.$backend.name,
|
|
38
38
|
readOnly: this.backend.readOnly
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -12,15 +12,15 @@ import { Mount } from "../container/mounts"
|
|
|
12
12
|
export type Volume<Props extends Volume.Backend = Volume.Backend> = Volume.PodVolume<Props>
|
|
13
13
|
export namespace Volume {
|
|
14
14
|
interface PodVolume_Backend_Pvc {
|
|
15
|
-
backend: Pvc.Pvc<"Filesystem">
|
|
15
|
+
$backend: Pvc.Pvc<"Filesystem">
|
|
16
16
|
readOnly?: boolean
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
interface PodVolume_Backend_ConfigMap {
|
|
20
|
-
backend: ConfigMap
|
|
20
|
+
$backend: ConfigMap
|
|
21
21
|
}
|
|
22
22
|
interface PodVolume_Backend_Secret {
|
|
23
|
-
backend: Secret
|
|
23
|
+
$backend: Secret
|
|
24
24
|
}
|
|
25
25
|
export type Backend =
|
|
26
26
|
| PodVolume_Backend_Pvc
|
|
@@ -30,7 +30,7 @@ export namespace Volume {
|
|
|
30
30
|
@k8ts(api.v1_.Pod_.Volume)
|
|
31
31
|
@relations({
|
|
32
32
|
needs: self => ({
|
|
33
|
-
backend: self.props
|
|
33
|
+
backend: self.props.$backend
|
|
34
34
|
})
|
|
35
35
|
})
|
|
36
36
|
export abstract class PodVolume<Props extends Backend = Backend> extends SubResource<Props> {
|
|
@@ -51,7 +51,7 @@ export namespace Volume {
|
|
|
51
51
|
return {
|
|
52
52
|
name: this.name,
|
|
53
53
|
persistentVolumeClaim: {
|
|
54
|
-
claimName: this.props
|
|
54
|
+
claimName: this.props.$backend.name,
|
|
55
55
|
readOnly: this.props.readOnly
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -63,7 +63,7 @@ export namespace Volume {
|
|
|
63
63
|
return {
|
|
64
64
|
name: this.name,
|
|
65
65
|
configMap: {
|
|
66
|
-
name: this.props
|
|
66
|
+
name: this.props.$backend.name
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -74,15 +74,15 @@ export namespace Volume {
|
|
|
74
74
|
return {
|
|
75
75
|
name: this.name,
|
|
76
76
|
secret: {
|
|
77
|
-
secretName: this.props
|
|
77
|
+
secretName: this.props.$backend.name
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export function make(parent: ManifestResource, name: string, input: Backend): PodVolume {
|
|
84
|
-
const { backend } = input
|
|
85
|
-
switch (backend.kind.name) {
|
|
84
|
+
const { $backend } = input
|
|
85
|
+
switch ($backend.kind.name) {
|
|
86
86
|
case "PersistentVolumeClaim":
|
|
87
87
|
return new PvcPodVolume(parent, name, input as PodVolume_Backend_Pvc)
|
|
88
88
|
case "ConfigMap":
|
|
@@ -20,9 +20,9 @@ export namespace Service {
|
|
|
20
20
|
export import Port = Port_
|
|
21
21
|
export import Frontend = Frontend_
|
|
22
22
|
export interface Props<DeployPorts extends string, ExposedPorts extends DeployPorts> {
|
|
23
|
-
ports: InputPortMapping<ExposedPorts>
|
|
24
|
-
backend: Deployment.AbsDeployment<DeployPorts>
|
|
25
|
-
frontend: Frontend
|
|
23
|
+
$ports: InputPortMapping<ExposedPorts>
|
|
24
|
+
$backend: Deployment.AbsDeployment<DeployPorts>
|
|
25
|
+
$frontend: Frontend
|
|
26
26
|
}
|
|
27
27
|
export type AbsService<ExposedPorts extends string> = Refable<api.v1_.Service> & {
|
|
28
28
|
__PORTS__: ExposedPorts
|
|
@@ -39,12 +39,12 @@ export namespace Service {
|
|
|
39
39
|
const svcPorts = self.ports
|
|
40
40
|
return {
|
|
41
41
|
spec: {
|
|
42
|
-
...self.props
|
|
42
|
+
...self.props.$frontend,
|
|
43
43
|
ports: toServicePorts(svcPorts).toArray(),
|
|
44
44
|
selector: {
|
|
45
|
-
app: self.props
|
|
45
|
+
app: self.props.$backend.name
|
|
46
46
|
},
|
|
47
|
-
...(self.props
|
|
47
|
+
...(self.props.$frontend.type === "LoadBalancer"
|
|
48
48
|
? {
|
|
49
49
|
allocateLoadBalancerNodePorts: false,
|
|
50
50
|
externalTrafficPolicy: "Local"
|
|
@@ -61,15 +61,15 @@ export namespace Service {
|
|
|
61
61
|
kind = api.v1_.Service
|
|
62
62
|
|
|
63
63
|
private get backend() {
|
|
64
|
-
return this.props
|
|
64
|
+
return this.props.$backend as Deployment<ExposedPorts>
|
|
65
65
|
}
|
|
66
66
|
get ports() {
|
|
67
67
|
const srcPorts = this.backend.ports.pull()
|
|
68
|
-
const knownPorts = Map(this.props
|
|
68
|
+
const knownPorts = Map(this.props.$ports)
|
|
69
69
|
.filter(x => x !== undefined)
|
|
70
70
|
.keySeq()
|
|
71
71
|
.toArray() as ExposedPorts[]
|
|
72
|
-
const svcPorts = srcPorts.pick(...knownPorts).map(this.props
|
|
72
|
+
const svcPorts = srcPorts.pick(...knownPorts).map(this.props.$ports as any)
|
|
73
73
|
return svcPorts
|
|
74
74
|
}
|
|
75
75
|
|