k8ts 0.4.19 → 0.4.21
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/file/exports.d.ts +4 -5
- package/dist/file/exports.d.ts.map +1 -1
- package/dist/file/exports.js +1 -0
- package/dist/file/exports.js.map +1 -1
- package/dist/file/factory.d.ts +1 -2
- package/dist/file/factory.d.ts.map +1 -1
- package/dist/file/factory.js +6 -4
- package/dist/file/factory.js.map +1 -1
- package/dist/file/file.d.ts +6 -7
- package/dist/file/file.d.ts.map +1 -1
- package/dist/file/file.js.map +1 -1
- package/dist/file/origin.d.ts +3 -3
- package/dist/file/origin.d.ts.map +1 -1
- package/dist/file/origin.js.map +1 -1
- package/dist/kind-map.d.ts +4 -3
- package/dist/kind-map.d.ts.map +1 -1
- package/dist/kind-map.js +2 -1
- package/dist/kind-map.js.map +1 -1
- package/dist/kinds.d.ts +91 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +71 -0
- package/dist/kinds.js.map +1 -0
- package/dist/node/abs-resource.d.ts +6 -6
- package/dist/node/abs-resource.d.ts.map +1 -1
- package/dist/node/abs-resource.js.map +1 -1
- package/dist/node/equiv-cdk8s.d.ts +4 -5
- package/dist/node/equiv-cdk8s.d.ts.map +1 -1
- package/dist/node/equiv-cdk8s.js.map +1 -1
- package/dist/node/manifest-resource.d.ts +4 -0
- package/dist/node/manifest-resource.d.ts.map +1 -1
- package/dist/node/manifest-resource.js.map +1 -1
- package/dist/node/sub-resource.d.ts +2 -2
- package/dist/node/sub-resource.d.ts.map +1 -1
- package/dist/node/sub-resource.js.map +1 -1
- package/dist/resources/configmap/configmap.d.ts.map +1 -1
- package/dist/resources/configmap/configmap.js +3 -4
- package/dist/resources/configmap/configmap.js.map +1 -1
- package/dist/resources/deployment/deployment.d.ts +6 -1
- package/dist/resources/deployment/deployment.d.ts.map +1 -1
- package/dist/resources/deployment/deployment.js +4 -4
- package/dist/resources/deployment/deployment.js.map +1 -1
- package/dist/resources/http-route/http-route.d.ts +4 -5
- package/dist/resources/http-route/http-route.d.ts.map +1 -1
- package/dist/resources/http-route/http-route.js +3 -5
- package/dist/resources/http-route/http-route.js.map +1 -1
- package/dist/resources/namespace/namespace.d.ts.map +1 -1
- package/dist/resources/namespace/namespace.js +3 -4
- package/dist/resources/namespace/namespace.js.map +1 -1
- package/dist/resources/persistent/claim/pvc.d.ts +3 -2
- package/dist/resources/persistent/claim/pvc.d.ts.map +1 -1
- package/dist/resources/persistent/claim/pvc.js +7 -5
- package/dist/resources/persistent/claim/pvc.js.map +1 -1
- package/dist/resources/persistent/volume/pv.d.ts +10 -7
- package/dist/resources/persistent/volume/pv.d.ts.map +1 -1
- package/dist/resources/persistent/volume/pv.js +4 -3
- package/dist/resources/persistent/volume/pv.js.map +1 -1
- package/dist/resources/pod/container/container.d.ts +15 -11
- package/dist/resources/pod/container/container.d.ts.map +1 -1
- package/dist/resources/pod/container/container.js +10 -8
- package/dist/resources/pod/container/container.js.map +1 -1
- package/dist/resources/pod/container/mounts.d.ts +14 -9
- package/dist/resources/pod/container/mounts.d.ts.map +1 -1
- package/dist/resources/pod/container/mounts.js +14 -13
- package/dist/resources/pod/container/mounts.js.map +1 -1
- package/dist/resources/pod/pod-template.d.ts +29 -14
- package/dist/resources/pod/pod-template.d.ts.map +1 -1
- package/dist/resources/pod/pod-template.js +10 -7
- 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 +7 -5
- package/dist/resources/pod/volume/devices.js.map +1 -1
- package/dist/resources/pod/volume/volumes.d.ts +2 -2
- package/dist/resources/pod/volume/volumes.d.ts.map +1 -1
- package/dist/resources/pod/volume/volumes.js +8 -5
- package/dist/resources/pod/volume/volumes.js.map +1 -1
- package/dist/resources/secret/secret.d.ts +1 -1
- package/dist/resources/secret/secret.d.ts.map +1 -1
- package/dist/resources/secret/secret.js +3 -4
- package/dist/resources/secret/secret.js.map +1 -1
- package/dist/resources/service/service-port.d.ts +6 -6
- package/dist/resources/service/service-port.d.ts.map +1 -1
- package/dist/resources/service/service-port.js +10 -8
- package/dist/resources/service/service-port.js.map +1 -1
- package/dist/resources/service/service.d.ts +12 -6
- package/dist/resources/service/service.d.ts.map +1 -1
- package/dist/resources/service/service.js +14 -8
- package/dist/resources/service/service.js.map +1 -1
- package/dist/resources/utils/adapters.d.ts.map +1 -1
- package/dist/resources/utils/adapters.js +3 -1
- package/dist/resources/utils/adapters.js.map +1 -1
- package/dist/runner/exporter/serializer.js +1 -1
- package/dist/runner/exporter/serializer.js.map +1 -1
- package/dist/src.tsbuildinfo +1 -1
- package/dist/world/world.d.ts +2 -3
- package/dist/world/world.d.ts.map +1 -1
- package/dist/world/world.js.map +1 -1
- package/package.json +11 -10
- package/src/file/exports.ts +6 -5
- package/src/file/factory.ts +25 -19
- package/src/file/file.ts +6 -7
- package/src/file/origin.ts +3 -3
- package/src/kind-map.ts +6 -3
- package/src/kinds.ts +127 -0
- package/src/node/abs-resource.ts +7 -6
- package/src/node/equiv-cdk8s.ts +4 -5
- package/src/node/manifest-resource.ts +4 -0
- package/src/node/sub-resource.ts +2 -2
- package/src/resources/configmap/configmap.ts +3 -4
- package/src/resources/deployment/deployment.ts +9 -5
- package/src/resources/http-route/http-route.ts +4 -6
- package/src/resources/namespace/namespace.ts +3 -4
- package/src/resources/persistent/claim/pvc.ts +9 -6
- package/src/resources/persistent/volume/pv.ts +8 -7
- package/src/resources/pod/container/container.ts +21 -12
- package/src/resources/pod/container/mounts.ts +20 -15
- package/src/resources/pod/pod-template.ts +30 -20
- package/src/resources/pod/volume/devices.ts +7 -4
- package/src/resources/pod/volume/volumes.ts +10 -5
- package/src/resources/secret/secret.ts +3 -4
- package/src/resources/service/service-port.ts +12 -8
- package/src/resources/service/service.ts +30 -20
- package/src/resources/utils/adapters.ts +3 -1
- package/src/runner/exporter/serializer.ts +1 -1
- package/src/world/world.ts +4 -5
- package/dist/api-versions.d.ts +0 -5
- package/dist/api-versions.d.ts.map +0 -1
- package/dist/api-versions.js +0 -8
- package/dist/api-versions.js.map +0 -1
- package/src/api-versions.ts +0 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Env,
|
|
3
|
+
Kinded,
|
|
3
4
|
PortSet,
|
|
4
5
|
relations,
|
|
5
6
|
ResourcesSpec,
|
|
@@ -15,10 +16,12 @@ import { toContainerPorts, toEnvVars } from "../../utils/adapters"
|
|
|
15
16
|
|
|
16
17
|
import { seq } from "doddle"
|
|
17
18
|
import { mapKeys, mapValues } from "lodash"
|
|
19
|
+
import { k8ts } from "../../../kind-map"
|
|
20
|
+
import { api } from "../../../kinds"
|
|
18
21
|
import type { ManifestResource } from "../../../node"
|
|
19
22
|
import { SubResource } from "../../../node/sub-resource"
|
|
20
23
|
import { Mount as Mount_ } from "./mounts"
|
|
21
|
-
export type Container<Ports extends string> = Container.Container<Ports>
|
|
24
|
+
export type Container<Ports extends string = string> = Container.Container<Ports>
|
|
22
25
|
export namespace Container {
|
|
23
26
|
export import Mount = Mount_
|
|
24
27
|
const container_ResourcesSpec = ResourcesSpec.make({
|
|
@@ -27,10 +30,12 @@ export namespace Container {
|
|
|
27
30
|
})
|
|
28
31
|
|
|
29
32
|
type Resources = (typeof container_ResourcesSpec)["__INPUT__"]
|
|
33
|
+
type SomeMount = Kinded<api.v1_.Pod_.DeviceMount | api.v1_.Pod_.VolumeMount>
|
|
30
34
|
export type Mounts = {
|
|
31
|
-
[key: string]:
|
|
35
|
+
[key: string]: SomeMount
|
|
32
36
|
}
|
|
33
|
-
|
|
37
|
+
|
|
38
|
+
export interface K8tsProps<Ports extends string = never> {
|
|
34
39
|
image: TaggedImage
|
|
35
40
|
ports?: InputPortSetRecord<Ports>
|
|
36
41
|
command?: CmdBuilder
|
|
@@ -39,19 +44,22 @@ export namespace Container {
|
|
|
39
44
|
securityContext?: CDK.SecurityContext
|
|
40
45
|
resources?: Resources
|
|
41
46
|
}
|
|
47
|
+
export type Props<Ports extends string = never> = K8tsProps<Ports> &
|
|
48
|
+
Omit<CDK.Container, keyof K8tsProps | "name">
|
|
49
|
+
|
|
50
|
+
@k8ts(api.v1_.Pod_.Container)
|
|
42
51
|
@relations({
|
|
43
52
|
needs: self => {
|
|
44
53
|
const a = self.mounts
|
|
45
54
|
return mapValues(
|
|
46
55
|
mapKeys(a, x => x.path),
|
|
47
|
-
x => x.mount.
|
|
56
|
+
x => x.mount.volume
|
|
48
57
|
)
|
|
49
58
|
}
|
|
50
59
|
})
|
|
51
|
-
export class Container<Ports extends string> extends SubResource<Props<Ports>> {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
60
|
+
export class Container<Ports extends string = string> extends SubResource<Props<Ports>> {
|
|
61
|
+
__PORTS__!: Ports
|
|
62
|
+
readonly kind = api.v1_.Pod_.Container
|
|
55
63
|
|
|
56
64
|
get mounts() {
|
|
57
65
|
return Map(this.props.mounts ?? {})
|
|
@@ -59,7 +67,7 @@ export namespace Container {
|
|
|
59
67
|
return [
|
|
60
68
|
mount,
|
|
61
69
|
{
|
|
62
|
-
mount,
|
|
70
|
+
mount: mount as Mount.ContainerVolumeMount | Mount.ContainerDeviceMount,
|
|
63
71
|
path: path as string
|
|
64
72
|
}
|
|
65
73
|
]
|
|
@@ -69,7 +77,7 @@ export namespace Container {
|
|
|
69
77
|
}
|
|
70
78
|
|
|
71
79
|
get volumes() {
|
|
72
|
-
return seq(this.mounts.map(x => x.mount.
|
|
80
|
+
return seq(this.mounts.map(x => x.mount.volume))
|
|
73
81
|
.uniq()
|
|
74
82
|
.toArray()
|
|
75
83
|
.pull()
|
|
@@ -96,7 +104,7 @@ export namespace Container {
|
|
|
96
104
|
parent: ManifestResource,
|
|
97
105
|
name: string,
|
|
98
106
|
readonly subtype: "init" | "main",
|
|
99
|
-
override readonly props:
|
|
107
|
+
override readonly props: K8tsProps<Ports>
|
|
100
108
|
) {
|
|
101
109
|
super(parent, name, props)
|
|
102
110
|
}
|
|
@@ -106,7 +114,8 @@ export namespace Container {
|
|
|
106
114
|
volumeMounts: [],
|
|
107
115
|
volumeDevices: []
|
|
108
116
|
} as Pick<CDK.Container, "volumeMounts" | "volumeDevices">
|
|
109
|
-
for (const
|
|
117
|
+
for (const mnt of this.mounts) {
|
|
118
|
+
const { mount, path } = mnt
|
|
110
119
|
if (mount instanceof Mount.ContainerDeviceMount) {
|
|
111
120
|
x.volumeDevices!.push(mount.submanifest(path))
|
|
112
121
|
} else {
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import type { CDK } from "../../../_imports"
|
|
2
|
+
import { api } from "../../../kinds"
|
|
3
|
+
import { Volume } from "../volume"
|
|
2
4
|
import type { Device } from "../volume/devices"
|
|
3
|
-
import type { Volume } from "../volume/volumes"
|
|
4
5
|
export type Mount = Mount.ContainerVolumeMount | Mount.ContainerDeviceMount
|
|
5
6
|
export namespace Mount {
|
|
6
7
|
type Path_Rooted = `/${string}`
|
|
7
8
|
export type Path = `${"" | "." | ".."}${Path_Rooted}`
|
|
8
9
|
|
|
9
|
-
export interface
|
|
10
|
+
export interface Props {
|
|
10
11
|
readOnly?: boolean
|
|
11
12
|
subPath?: string
|
|
13
|
+
volume: Volume
|
|
12
14
|
}
|
|
13
15
|
export class ContainerVolumeMount {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
constructor(
|
|
18
|
-
readonly parent: Volume.PodVolume,
|
|
19
|
-
readonly props: Options
|
|
20
|
-
) {}
|
|
16
|
+
readonly kind = api.v1_.Pod_.VolumeMount
|
|
17
|
+
|
|
18
|
+
constructor(readonly props: Props) {}
|
|
21
19
|
|
|
20
|
+
get volume() {
|
|
21
|
+
return this.props.volume
|
|
22
|
+
}
|
|
22
23
|
submanifest(mountPath: string): CDK.VolumeMount {
|
|
23
24
|
return {
|
|
24
|
-
name: this.
|
|
25
|
+
name: this.props.volume.name,
|
|
25
26
|
mountPath: mountPath,
|
|
26
27
|
readOnly: this.props.readOnly,
|
|
27
28
|
subPath: this.props.subPath
|
|
@@ -29,16 +30,20 @@ export namespace Mount {
|
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
export interface DeviceMountProps {
|
|
34
|
+
device: Device
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
export class ContainerDeviceMount {
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
kind = api.v1_.Pod_.DeviceMount
|
|
39
|
+
get volume() {
|
|
40
|
+
return this.props.device
|
|
35
41
|
}
|
|
36
|
-
constructor(readonly
|
|
37
|
-
|
|
42
|
+
constructor(readonly props: DeviceMountProps) {}
|
|
38
43
|
submanifest(devicePath: string): CDK.VolumeDevice {
|
|
39
44
|
return {
|
|
40
45
|
devicePath: devicePath,
|
|
41
|
-
name: this.
|
|
46
|
+
name: this.props.device.name
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
49
|
}
|
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
import { manifest, Producer, relations } from "@k8ts/instruments"
|
|
1
|
+
import { Kinded, manifest, Producer, relations } from "@k8ts/instruments"
|
|
2
2
|
import { seq } from "doddle"
|
|
3
3
|
import { omit } from "lodash"
|
|
4
4
|
import { CDK } from "../../_imports"
|
|
5
|
-
import { apps_v1 } from "../../api-versions"
|
|
6
5
|
import { k8ts } from "../../kind-map"
|
|
6
|
+
import { api } from "../../kinds"
|
|
7
7
|
import { ManifestResource } from "../../node/manifest-resource"
|
|
8
8
|
import { Container } from "./container"
|
|
9
9
|
import { Device, Volume } from "./volume"
|
|
10
|
-
export type PodTemplate<Ports extends string> = PodTemplate.PodTemplate<Ports>
|
|
10
|
+
export type PodTemplate<Ports extends string = string> = PodTemplate.PodTemplate<Ports>
|
|
11
11
|
export namespace PodTemplate {
|
|
12
12
|
export type PodProps = Omit<CDK.PodSpec, "containers" | "initContainers" | "volumes">
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
>
|
|
17
|
-
export type Props<Ports extends string
|
|
13
|
+
type AbsContainer<Ports extends string> = Kinded<api.v1_.Pod_.Container> & {
|
|
14
|
+
__PORTS__: Ports
|
|
15
|
+
}
|
|
16
|
+
export type PodContainerProducer<Ports extends string> = Producer<PodScope, AbsContainer<Ports>>
|
|
17
|
+
export type Props<Ports extends string> = PodProps & {
|
|
18
18
|
POD: PodContainerProducer<Ports>
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
export type HostPortSpec<Ports extends string> = {
|
|
21
|
+
[port in Ports]?: {
|
|
22
|
+
ip?: string
|
|
23
|
+
port?: number
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export interface HostNetInput<Ports extends string> {
|
|
27
|
+
hostNetwork?: boolean
|
|
28
|
+
ports: HostPortSpec<Ports>
|
|
29
|
+
}
|
|
30
|
+
@k8ts(api.v1_.PodTemplate)
|
|
22
31
|
@relations({
|
|
23
32
|
kids: s => [...s.containers, ...s.volumes]
|
|
24
33
|
})
|
|
@@ -47,8 +56,12 @@ export namespace PodTemplate {
|
|
|
47
56
|
}
|
|
48
57
|
})
|
|
49
58
|
export class PodTemplate<Ports extends string = string> extends ManifestResource<Props<Ports>> {
|
|
50
|
-
kind =
|
|
51
|
-
readonly containers = seq(() => this.props.POD(new PodScope(this)))
|
|
59
|
+
readonly kind = api.v1_.PodTemplate
|
|
60
|
+
readonly containers = seq(() => this.props.POD(new PodScope(this)))
|
|
61
|
+
.map(x => {
|
|
62
|
+
return x as Container<Ports>
|
|
63
|
+
})
|
|
64
|
+
.cache()
|
|
52
65
|
readonly mounts = seq(() => this.containers.concatMap(x => x.mounts)).cache()
|
|
53
66
|
readonly volumes = seq(() => this.containers.concatMap(x => x.volumes)).uniq()
|
|
54
67
|
readonly ports = seq(() => this.containers.map(x => x.ports)).reduce((a, b) => a.union(b))
|
|
@@ -56,19 +69,16 @@ export namespace PodTemplate {
|
|
|
56
69
|
|
|
57
70
|
export class PodScope {
|
|
58
71
|
constructor(private readonly _parent: PodTemplate) {}
|
|
59
|
-
Container<Ports extends string>(
|
|
60
|
-
name
|
|
61
|
-
options: Container.Props<Ports>
|
|
62
|
-
): Container<Ports> {
|
|
63
|
-
return Container.make(this._parent, name, "main", options)
|
|
72
|
+
Container<Ports extends string>(name: string, options: Container.Props<Ports>) {
|
|
73
|
+
return new Container.Container(this._parent, name, "main", options)
|
|
64
74
|
}
|
|
65
|
-
InitContainer(name: string, options: Container.
|
|
66
|
-
return Container.
|
|
75
|
+
InitContainer(name: string, options: Container.K8tsProps<never>) {
|
|
76
|
+
return new Container.Container(this._parent, name, "init", options)
|
|
67
77
|
}
|
|
68
78
|
Volume(name: string, options: Volume.Backend) {
|
|
69
79
|
return Volume.make(this._parent, name, options)
|
|
70
80
|
}
|
|
71
|
-
Device(name: string, options: Device.Backend)
|
|
81
|
+
Device(name: string, options: Device.Backend) {
|
|
72
82
|
return Device.make(this._parent, name, options)
|
|
73
83
|
}
|
|
74
84
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { relations } from "@k8ts/instruments"
|
|
2
2
|
import type { CDK } from "../../../_imports"
|
|
3
|
+
import { k8ts } from "../../../kind-map"
|
|
4
|
+
import { api } from "../../../kinds"
|
|
3
5
|
import type { ManifestResource } from "../../../node"
|
|
4
6
|
import { SubResource } from "../../../node/sub-resource"
|
|
5
7
|
import { Pvc } from "../../persistent"
|
|
@@ -12,15 +14,14 @@ export namespace Device {
|
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export type Backend = PodDevice_Backend_Pvc
|
|
17
|
+
@k8ts(api.v1_.Pod_.Device)
|
|
15
18
|
@relations({
|
|
16
19
|
needs: self => ({
|
|
17
20
|
backend: self.backend.backend
|
|
18
21
|
})
|
|
19
22
|
})
|
|
20
23
|
export class PodDevice extends SubResource<PodDevice_Backend_Pvc> {
|
|
21
|
-
|
|
22
|
-
return this.parent.kind.subkind("Device")
|
|
23
|
-
}
|
|
24
|
+
readonly kind = api.v1_.Pod_.Device
|
|
24
25
|
constructor(
|
|
25
26
|
parent: ManifestResource,
|
|
26
27
|
name: string,
|
|
@@ -40,7 +41,9 @@ export namespace Device {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
Mount() {
|
|
43
|
-
return new Mount.ContainerDeviceMount(
|
|
44
|
+
return new Mount.ContainerDeviceMount({
|
|
45
|
+
device: this
|
|
46
|
+
})
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CDK } from "../../../_imports"
|
|
2
2
|
|
|
3
3
|
import { relations } from "@k8ts/instruments"
|
|
4
|
+
import { k8ts } from "../../../kind-map"
|
|
5
|
+
import { api } from "../../../kinds"
|
|
4
6
|
import type { ManifestResource } from "../../../node"
|
|
5
7
|
import { SubResource } from "../../../node/sub-resource"
|
|
6
8
|
import type { ConfigMap } from "../../configmap"
|
|
@@ -24,20 +26,23 @@ export namespace Volume {
|
|
|
24
26
|
| PodVolume_Backend_Pvc
|
|
25
27
|
| PodVolume_Backend_ConfigMap
|
|
26
28
|
| PodVolume_Backend_Secret
|
|
29
|
+
|
|
30
|
+
@k8ts(api.v1_.Pod_.Volume)
|
|
27
31
|
@relations({
|
|
28
32
|
needs: self => ({
|
|
29
33
|
backend: self.props.backend
|
|
30
34
|
})
|
|
31
35
|
})
|
|
32
36
|
export abstract class PodVolume<Props extends Backend = Backend> extends SubResource<Props> {
|
|
33
|
-
|
|
34
|
-
return this.parent.kind.subkind("Volume")
|
|
35
|
-
}
|
|
37
|
+
readonly kind = api.v1_.Pod_.Volume
|
|
36
38
|
|
|
37
39
|
abstract submanifest(): CDK.Volume
|
|
38
40
|
|
|
39
|
-
Mount(options?: Mount.
|
|
40
|
-
return new Mount.ContainerVolumeMount(
|
|
41
|
+
Mount(options?: Omit<Mount.Props, "volume">) {
|
|
42
|
+
return new Mount.ContainerVolumeMount({
|
|
43
|
+
volume: this,
|
|
44
|
+
...options
|
|
45
|
+
})
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { manifest, relations } from "@k8ts/instruments"
|
|
2
2
|
import { CDK } from "../../_imports"
|
|
3
|
-
import { v1 } from "../../api-versions"
|
|
4
3
|
import { k8ts } from "../../kind-map"
|
|
4
|
+
import { api } from "../../kinds"
|
|
5
5
|
import { equiv_cdk8s } from "../../node/equiv-cdk8s"
|
|
6
6
|
import { ManifestResource } from "../../node/manifest-resource"
|
|
7
7
|
|
|
@@ -10,8 +10,7 @@ export interface Props {
|
|
|
10
10
|
stringData: Record<string, string>
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
@k8ts(ident)
|
|
13
|
+
@k8ts(api.v1_.Secret)
|
|
15
14
|
@equiv_cdk8s(CDK.KubeSecret)
|
|
16
15
|
@relations("none")
|
|
17
16
|
@manifest({
|
|
@@ -23,5 +22,5 @@ const ident = v1.kind("Secret")
|
|
|
23
22
|
}
|
|
24
23
|
})
|
|
25
24
|
export class Secret extends ManifestResource<Props> {
|
|
26
|
-
kind =
|
|
25
|
+
readonly kind = api.v1_.Secret
|
|
27
26
|
}
|
|
@@ -4,23 +4,27 @@ import type { Service } from "./service"
|
|
|
4
4
|
export type Port<Port extends string> = Port.Port<Port>
|
|
5
5
|
export namespace Port {
|
|
6
6
|
export interface Props<Port extends string> {
|
|
7
|
-
service: Service<Port
|
|
8
|
-
|
|
7
|
+
service: Service.AbsService<Port>
|
|
8
|
+
name: Port
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export class Port<Port extends string> {
|
|
12
|
-
constructor(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
constructor(readonly props: Props<Port>) {}
|
|
13
|
+
|
|
14
|
+
get service() {
|
|
15
|
+
return this.props.service as Service<Port>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get port() {
|
|
19
|
+
return this.props
|
|
20
|
+
}
|
|
17
21
|
|
|
18
22
|
ref(): CDK.HttpRouteSpecRulesBackendRefs {
|
|
19
23
|
return {
|
|
20
24
|
kind: "Service",
|
|
21
25
|
namespace: this.service.meta.tryGet("namespace"),
|
|
22
26
|
name: this.service.meta.get("name"),
|
|
23
|
-
port: this.
|
|
27
|
+
port: this.service.ports.get(this.props.name).frontend
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
}
|
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
manifest,
|
|
3
|
+
Refable,
|
|
4
|
+
relations,
|
|
5
|
+
ResourceEntity,
|
|
6
|
+
type InputPortMapping
|
|
7
|
+
} from "@k8ts/instruments"
|
|
2
8
|
import { Map } from "immutable"
|
|
3
9
|
import { CDK } from "../../_imports"
|
|
4
|
-
import { v1 } from "../../api-versions"
|
|
5
10
|
import { k8ts } from "../../kind-map"
|
|
11
|
+
import { api } from "../../kinds"
|
|
6
12
|
import { ManifestResource } from "../../node"
|
|
7
13
|
import { equiv_cdk8s } from "../../node/equiv-cdk8s"
|
|
8
|
-
import
|
|
14
|
+
import { Deployment } from "../deployment"
|
|
9
15
|
import { toServicePorts } from "../utils/adapters"
|
|
10
16
|
import { Frontend as Frontend_ } from "./frontend"
|
|
11
17
|
import { Port as Port_ } from "./service-port"
|
|
12
|
-
export type Service<
|
|
13
|
-
DeployPorts,
|
|
14
|
-
ExposedPorts
|
|
15
|
-
>
|
|
18
|
+
export type Service<ExposedPorts extends string = string> = Service.Service<ExposedPorts>
|
|
16
19
|
export namespace Service {
|
|
17
20
|
export import Port = Port_
|
|
18
21
|
export import Frontend = Frontend_
|
|
19
22
|
export interface Props<DeployPorts extends string, ExposedPorts extends DeployPorts> {
|
|
20
23
|
ports: InputPortMapping<ExposedPorts>
|
|
21
|
-
backend: Deployment.
|
|
24
|
+
backend: Deployment.AbsDeployment<DeployPorts>
|
|
22
25
|
frontend: Frontend
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
export type AbsService<ExposedPorts extends string> = Refable<api.v1_.Service> & {
|
|
28
|
+
__PORTS__: ExposedPorts
|
|
29
|
+
}
|
|
30
|
+
@k8ts(api.v1_.Service)
|
|
27
31
|
@relations({
|
|
28
32
|
needs: self => ({
|
|
29
|
-
backend: self.
|
|
33
|
+
backend: self.backend as ResourceEntity
|
|
30
34
|
})
|
|
31
35
|
})
|
|
32
36
|
@equiv_cdk8s(CDK.KubeService)
|
|
@@ -50,14 +54,17 @@ export namespace Service {
|
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
})
|
|
53
|
-
export class Service<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
kind =
|
|
57
|
+
export class Service<ExposedPorts extends string = string> extends ManifestResource<
|
|
58
|
+
Props<string, ExposedPorts>
|
|
59
|
+
> {
|
|
60
|
+
__PORTS__!: ExposedPorts
|
|
61
|
+
kind = api.v1_.Service
|
|
58
62
|
|
|
63
|
+
private get backend() {
|
|
64
|
+
return this.props.backend as Deployment<ExposedPorts>
|
|
65
|
+
}
|
|
59
66
|
get ports() {
|
|
60
|
-
const srcPorts = this.
|
|
67
|
+
const srcPorts = this.backend.ports.pull()
|
|
61
68
|
const knownPorts = Map(this.props.ports)
|
|
62
69
|
.filter(x => x !== undefined)
|
|
63
70
|
.keySeq()
|
|
@@ -66,8 +73,11 @@ export namespace Service {
|
|
|
66
73
|
return svcPorts
|
|
67
74
|
}
|
|
68
75
|
|
|
69
|
-
portRef(
|
|
70
|
-
return new Port.Port(
|
|
76
|
+
portRef(name: ExposedPorts) {
|
|
77
|
+
return new Port.Port({
|
|
78
|
+
service: this,
|
|
79
|
+
name: name
|
|
80
|
+
})
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
83
|
}
|
|
@@ -41,7 +41,7 @@ export class YamlSerializer extends Emittery<YamlSerializerEventsTable> {
|
|
|
41
41
|
return result
|
|
42
42
|
} catch (err) {
|
|
43
43
|
const resource = ManifestSourceEmbedder.get(input)
|
|
44
|
-
throw new MakeError(`Failed to serialize manifest ${resource
|
|
44
|
+
throw new MakeError(`Failed to serialize manifest ${resource}`, {
|
|
45
45
|
cause: err
|
|
46
46
|
})
|
|
47
47
|
}
|
package/src/world/world.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseOriginEntity, KindMap, Origin, type Kind } from "@k8ts/instruments"
|
|
1
|
+
import { BaseOriginEntity, KindMap, LiveRefable, Origin, type Kind } from "@k8ts/instruments"
|
|
2
2
|
import { Meta } from "@k8ts/metadata"
|
|
3
3
|
import { assign } from "lodash"
|
|
4
4
|
import { External } from "../external"
|
|
@@ -7,7 +7,6 @@ import { FileExports } from "../file/exports"
|
|
|
7
7
|
import { FileOrigin } from "../file/origin"
|
|
8
8
|
import { k8tsBuildKind } from "../k8ts-sys-kind"
|
|
9
9
|
import { K8tsRootOrigin } from "../kind-map"
|
|
10
|
-
import type { ManifestResource } from "../node"
|
|
11
10
|
export type ManifestFileName = `${string}.yaml`
|
|
12
11
|
export namespace World {
|
|
13
12
|
export interface Props {
|
|
@@ -19,7 +18,7 @@ export namespace World {
|
|
|
19
18
|
const ident = k8tsBuildKind.kind("World")
|
|
20
19
|
export type DefineScopedFile<Scope extends FileOrigin.Scope> = {
|
|
21
20
|
metadata(input: Meta.Input): DefineScopedFile<Scope>
|
|
22
|
-
Resources<const Produced extends
|
|
21
|
+
Resources<const Produced extends LiveRefable>(
|
|
23
22
|
producer: FileExports.Producer<Scope, Produced>
|
|
24
23
|
): File<Produced>
|
|
25
24
|
}
|
|
@@ -49,7 +48,7 @@ export namespace World {
|
|
|
49
48
|
})
|
|
50
49
|
return self
|
|
51
50
|
},
|
|
52
|
-
Resources<const Produced extends
|
|
51
|
+
Resources<const Produced extends LiveRefable>(
|
|
53
52
|
producer: FileExports.Producer<Scope, Produced>
|
|
54
53
|
): File<Produced> {
|
|
55
54
|
return builder._File(name, {
|
|
@@ -64,7 +63,7 @@ export namespace World {
|
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
private _File<T extends
|
|
66
|
+
private _File<T extends LiveRefable>(
|
|
68
67
|
name: ManifestFileName,
|
|
69
68
|
props: File.Props<any, T>
|
|
70
69
|
): File<T> {
|
package/dist/api-versions.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Kind } from "@k8ts/instruments";
|
|
2
|
-
export declare const v1: Kind.Version<"v1", Kind.Group<"">>;
|
|
3
|
-
export declare const apps_v1: Kind.Version<"v1", Kind.Group<"apps">>;
|
|
4
|
-
export declare const gateway_v1: Kind.Version<"v1", Kind.Group<"gateway.networking.k8s.io">>;
|
|
5
|
-
//# sourceMappingURL=api-versions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-versions.d.ts","sourceRoot":"","sources":["../src/api-versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAExC,eAAO,MAAM,EAAE,oCAA+B,CAAA;AAC9C,eAAO,MAAM,OAAO,wCAAmC,CAAA;AACvD,eAAO,MAAM,UAAU,6DAAwD,CAAA"}
|
package/dist/api-versions.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gateway_v1 = exports.apps_v1 = exports.v1 = void 0;
|
|
4
|
-
const instruments_1 = require("@k8ts/instruments");
|
|
5
|
-
exports.v1 = instruments_1.Kind.group("").version("v1");
|
|
6
|
-
exports.apps_v1 = instruments_1.Kind.group("apps").version("v1");
|
|
7
|
-
exports.gateway_v1 = instruments_1.Kind.group("gateway.networking.k8s.io").version("v1");
|
|
8
|
-
//# sourceMappingURL=api-versions.js.map
|
package/dist/api-versions.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-versions.js","sourceRoot":"","sources":["../src/api-versions.ts"],"names":[],"mappings":";;;AAAA,mDAAwC;AAE3B,QAAA,EAAE,GAAG,kBAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AACjC,QAAA,OAAO,GAAG,kBAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAC1C,QAAA,UAAU,GAAG,kBAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA"}
|