k8ts 0.4.18 → 0.4.20
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 -1
- package/dist/file/factory.d.ts.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 +19 -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/runner/exporter/serializer.js +1 -1
- package/dist/runner/exporter/serializer.js.map +1 -1
- package/dist/runner/exporter/validator.d.ts.map +1 -1
- package/dist/runner/exporter/validator.js +1 -2
- package/dist/runner/exporter/validator.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 +10 -10
- package/src/file/exports.ts +6 -5
- package/src/file/factory.ts +1 -1
- 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 -6
- 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 +20 -12
- package/src/resources/pod/container/mounts.ts +20 -15
- package/src/resources/pod/pod-template.ts +20 -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/runner/exporter/serializer.ts +1 -1
- package/src/runner/exporter/validator.ts +1 -2
- 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
package/src/file/exports.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FutureExports, Producer } from "@k8ts/instruments"
|
|
1
|
+
import { FutureExports, LiveRefable, Producer } from "@k8ts/instruments"
|
|
2
2
|
import { seq, type Seq } from "doddle"
|
|
3
|
-
import
|
|
3
|
+
import { ManifestResource } from "../node"
|
|
4
4
|
import { k8ts_namespace } from "../runner/exporter/meta"
|
|
5
5
|
import { Factory } from "./factory"
|
|
6
6
|
import type { FileOrigin } from "./origin"
|
|
@@ -12,7 +12,7 @@ export namespace FileExports {
|
|
|
12
12
|
> = Producer.Producer<Factory.FromScope<Scope>, Produced>
|
|
13
13
|
export interface Props<
|
|
14
14
|
Scope extends FileOrigin.Scope = FileOrigin.Scope,
|
|
15
|
-
Produced extends
|
|
15
|
+
Produced extends LiveRefable = LiveRefable
|
|
16
16
|
> {
|
|
17
17
|
origin: FileOrigin<Scope>
|
|
18
18
|
FILE: Producer<Scope, Produced>
|
|
@@ -20,7 +20,7 @@ export namespace FileExports {
|
|
|
20
20
|
|
|
21
21
|
export class Core {
|
|
22
22
|
#props: Props
|
|
23
|
-
#produced: Seq<
|
|
23
|
+
#produced: Seq<LiveRefable>
|
|
24
24
|
constructor(props: Props) {
|
|
25
25
|
this.#props = props
|
|
26
26
|
const producer = Producer.map(props.FILE, () => {
|
|
@@ -31,6 +31,7 @@ export namespace FileExports {
|
|
|
31
31
|
}
|
|
32
32
|
})
|
|
33
33
|
this.#produced = seq(() => producer(props.origin))
|
|
34
|
+
.as<ManifestResource>()
|
|
34
35
|
.each(x => {
|
|
35
36
|
x.meta.add(k8ts_namespace, {
|
|
36
37
|
"#is-exported": "true"
|
|
@@ -52,7 +53,7 @@ export namespace FileExports {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
export function make<Scope extends FileOrigin.Scope, Produced extends
|
|
56
|
+
export function make<Scope extends FileOrigin.Scope, Produced extends LiveRefable>(
|
|
56
57
|
props: Props<Scope, Produced>
|
|
57
58
|
): Core & FutureExports<Produced> {
|
|
58
59
|
const core = new Core(props as any)
|
package/src/file/factory.ts
CHANGED
package/src/file/file.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { FutureExports, Origin } from "@k8ts/instruments"
|
|
2
|
-
import type { ManifestResource } from "../node"
|
|
1
|
+
import type { FutureExports, LiveRefable, Origin } from "@k8ts/instruments"
|
|
3
2
|
import { FileExports as Exports_ } from "./exports"
|
|
4
3
|
import { Factory as Factory_ } from "./factory"
|
|
5
4
|
import { FileOrigin } from "./origin"
|
|
6
|
-
export type File<T extends
|
|
5
|
+
export type File<T extends LiveRefable = LiveRefable> = File.File<T>
|
|
7
6
|
export namespace File {
|
|
8
7
|
export import Factory = Factory_
|
|
9
8
|
|
|
@@ -11,15 +10,15 @@ export namespace File {
|
|
|
11
10
|
|
|
12
11
|
export interface Props<
|
|
13
12
|
Scope extends FileOrigin.Scope = FileOrigin.Scope,
|
|
14
|
-
Produced extends
|
|
13
|
+
Produced extends LiveRefable = LiveRefable
|
|
15
14
|
> extends FileOrigin.Props<Scope> {
|
|
16
15
|
FILE: Exports.Producer<Scope, Produced>
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
export type Input = Exports.Core & Iterable<
|
|
20
|
-
export type File<T extends
|
|
18
|
+
export type Input = Exports.Core & Iterable<LiveRefable>
|
|
19
|
+
export type File<T extends LiveRefable> = Exports.Core & FutureExports<T>
|
|
21
20
|
|
|
22
|
-
export function make<Scope extends FileOrigin.Scope, Produced extends
|
|
21
|
+
export function make<Scope extends FileOrigin.Scope, Produced extends LiveRefable>(
|
|
23
22
|
name: string,
|
|
24
23
|
props: Props<Scope, Produced>,
|
|
25
24
|
parent: Origin
|
package/src/file/origin.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BaseOriginEntity, Origin, OriginEntityProps } from "@k8ts/instruments"
|
|
1
|
+
import { BaseOriginEntity, Origin, OriginEntityProps, Refable } from "@k8ts/instruments"
|
|
2
2
|
import { Meta } from "@k8ts/metadata"
|
|
3
3
|
import { k8tsBuildKind } from "../k8ts-sys-kind"
|
|
4
|
-
import
|
|
4
|
+
import { api } from "../kinds"
|
|
5
5
|
export type FileOrigin<FScope extends FileOrigin.Scope = FileOrigin.Scope> =
|
|
6
6
|
FileOrigin.FileEntity<FScope>
|
|
7
7
|
export namespace FileOrigin {
|
|
8
|
-
export type Scope = Namespace | "cluster"
|
|
8
|
+
export type Scope = Refable<api.v1_.Namespace> | "cluster"
|
|
9
9
|
|
|
10
10
|
export interface SmallerProps extends OriginEntityProps {
|
|
11
11
|
meta?: Meta.Input
|
package/src/kind-map.ts
CHANGED
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
BaseOriginEntity,
|
|
3
3
|
Kind,
|
|
4
4
|
kinded,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
OriginEntityProps,
|
|
6
|
+
ResourceEntity
|
|
7
7
|
} from "@k8ts/instruments"
|
|
8
8
|
import { k8tsBuildKind } from "./k8ts-sys-kind"
|
|
9
9
|
const ident = k8tsBuildKind.kind("World")
|
|
@@ -23,7 +23,9 @@ class K8tsRootOriginEntity extends BaseOriginEntity<OriginEntityProps> {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
get decorator() {
|
|
26
|
-
return <Target extends new (...args: any[]) =>
|
|
26
|
+
return <Target extends abstract new (...args: any[]) => ResourceEntity>(
|
|
27
|
+
kind: Kind.Identifier
|
|
28
|
+
) => {
|
|
27
29
|
return (ctor: Target) => {
|
|
28
30
|
this.node.resourceKinds.add(kind, ctor)
|
|
29
31
|
kinded(kind)(ctor)
|
|
@@ -37,3 +39,4 @@ export const K8tsRootOrigin = new K8tsRootOriginEntity()
|
|
|
37
39
|
export const K8tsResources = K8tsRootOrigin.node.resourceKinds
|
|
38
40
|
|
|
39
41
|
export const k8ts = K8tsRootOrigin.decorator
|
|
42
|
+
export const REF_TYPE = Symbol.for("k8ts:ref")
|
package/src/kinds.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Kind } from "@k8ts/instruments"
|
|
2
|
+
export namespace api {
|
|
3
|
+
export const v1 = Kind.version("v1")
|
|
4
|
+
export type v1 = typeof v1
|
|
5
|
+
|
|
6
|
+
export namespace v1_ {
|
|
7
|
+
export function kind_<Name extends string>(name: Name): Kind<Name, typeof v1> {
|
|
8
|
+
return v1.kind(name)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const ConfigMap = v1.kind("ConfigMap")
|
|
12
|
+
export type ConfigMap = typeof ConfigMap
|
|
13
|
+
|
|
14
|
+
export const Secret = v1.kind("Secret")
|
|
15
|
+
export type Secret = typeof Secret
|
|
16
|
+
|
|
17
|
+
export const Service = v1.kind("Service")
|
|
18
|
+
export type Service = typeof Service
|
|
19
|
+
|
|
20
|
+
export const Pod = v1.kind("Pod")
|
|
21
|
+
export type Pod = typeof Pod
|
|
22
|
+
|
|
23
|
+
export namespace Pod_ {
|
|
24
|
+
export const Container = Pod.subkind("Container")
|
|
25
|
+
export type Container = typeof Container
|
|
26
|
+
|
|
27
|
+
export const Port = Container.subkind("Port")
|
|
28
|
+
export type Port = typeof Port
|
|
29
|
+
|
|
30
|
+
export const EnvVar = Container.subkind("EnvVar")
|
|
31
|
+
export type EnvVar = typeof EnvVar
|
|
32
|
+
|
|
33
|
+
export const VolumeMount = Container.subkind("VolumeMount")
|
|
34
|
+
export type VolumeMount = typeof VolumeMount
|
|
35
|
+
|
|
36
|
+
export const DeviceMount = Container.subkind("DeviceMount")
|
|
37
|
+
export type DeviceMount = typeof DeviceMount
|
|
38
|
+
|
|
39
|
+
export const Volume = Pod.subkind("Volume")
|
|
40
|
+
export type Volume = typeof Volume
|
|
41
|
+
|
|
42
|
+
export const Device = Volume.subkind("Device")
|
|
43
|
+
export type Device = typeof Device
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const Node = v1.kind("Node")
|
|
47
|
+
export type Node = typeof Node
|
|
48
|
+
|
|
49
|
+
export const Namespace = v1.kind("Namespace")
|
|
50
|
+
export type Namespace = typeof Namespace
|
|
51
|
+
|
|
52
|
+
export const ServiceAccount = v1.kind("ServiceAccount")
|
|
53
|
+
export type ServiceAccount = typeof ServiceAccount
|
|
54
|
+
|
|
55
|
+
export const PersistentVolume = v1.kind("PersistentVolume")
|
|
56
|
+
export type PersistentVolume = typeof PersistentVolume
|
|
57
|
+
|
|
58
|
+
export const PersistentVolumeClaim = v1.kind("PersistentVolumeClaim")
|
|
59
|
+
export type PersistentVolumeClaim = typeof PersistentVolumeClaim
|
|
60
|
+
|
|
61
|
+
export const PodTemplate = v1.kind("PodTemplate")
|
|
62
|
+
export type PodTemplate = typeof PodTemplate
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const apps = Kind.group("apps")
|
|
66
|
+
export type apps = typeof apps
|
|
67
|
+
|
|
68
|
+
export namespace apps_ {
|
|
69
|
+
export const v1 = apps.version("v1")
|
|
70
|
+
export type v1 = typeof v1
|
|
71
|
+
|
|
72
|
+
export namespace v1_ {
|
|
73
|
+
export const Deployment = v1.kind("Deployment")
|
|
74
|
+
export type Deployment = typeof Deployment
|
|
75
|
+
|
|
76
|
+
export const StatefulSet = v1.kind("StatefulSet")
|
|
77
|
+
export type StatefulSet = typeof StatefulSet
|
|
78
|
+
|
|
79
|
+
export const DaemonSet = v1.kind("DaemonSet")
|
|
80
|
+
export type DaemonSet = typeof DaemonSet
|
|
81
|
+
|
|
82
|
+
export const ReplicaSet = v1.kind("ReplicaSet")
|
|
83
|
+
export type ReplicaSet = typeof ReplicaSet
|
|
84
|
+
|
|
85
|
+
export const ControllerRevision = v1.kind("ControllerRevision")
|
|
86
|
+
export type ControllerRevision = typeof ControllerRevision
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const networking = Kind.group("networking.k8s.io")
|
|
91
|
+
export type networking = typeof networking
|
|
92
|
+
|
|
93
|
+
export namespace networking_ {
|
|
94
|
+
export const v1 = networking.version("v1")
|
|
95
|
+
export type v1 = typeof v1
|
|
96
|
+
|
|
97
|
+
export namespace v1_ {
|
|
98
|
+
export const NetworkPolicy = v1.kind("NetworkPolicy")
|
|
99
|
+
export type NetworkPolicy = typeof NetworkPolicy
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const gateway = Kind.group("gateway.networking.k8s.io")
|
|
104
|
+
export type gateway = typeof gateway
|
|
105
|
+
|
|
106
|
+
export namespace gateway_ {
|
|
107
|
+
export const v1 = gateway.version("v1")
|
|
108
|
+
export type v1 = typeof v1
|
|
109
|
+
|
|
110
|
+
export namespace v1_ {
|
|
111
|
+
export const Gateway = v1.kind("Gateway")
|
|
112
|
+
export type Gateway = typeof Gateway
|
|
113
|
+
|
|
114
|
+
export const GatewayClass = v1.kind("GatewayClass")
|
|
115
|
+
export type GatewayClass = typeof GatewayClass
|
|
116
|
+
|
|
117
|
+
export const HttpRoute = v1.kind("HTTPRoute")
|
|
118
|
+
export type HttpRoute = typeof HttpRoute
|
|
119
|
+
|
|
120
|
+
export const TcpRoute = v1.kind("TCPRoute")
|
|
121
|
+
export type TcpRoute = typeof TcpRoute
|
|
122
|
+
|
|
123
|
+
export const TlsRoute = v1.kind("TLSRoute")
|
|
124
|
+
export type TlsRoute = typeof TlsRoute
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
package/src/node/abs-resource.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { displayers, Kind, Origin, RefKey, ResourceNode } from "@k8ts/instruments"
|
|
1
|
+
import { displayers, Kind, Origin, RefKey, ResourceEntity, ResourceNode } from "@k8ts/instruments"
|
|
2
2
|
import { Doddle, doddle } from "doddle"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
|
|
4
|
+
export interface ResourceIdentBlock {
|
|
5
|
+
kind: Kind.IdentParent
|
|
6
|
+
name: string
|
|
6
7
|
}
|
|
7
8
|
@displayers({
|
|
8
9
|
simple: s => s.node,
|
|
9
10
|
pretty: s => s.node
|
|
10
11
|
})
|
|
11
|
-
export abstract class AbsResource<Props extends object = object> {
|
|
12
|
+
export abstract class AbsResource<Props extends object = object> implements ResourceEntity {
|
|
12
13
|
abstract readonly kind: Kind.Identifier<string, Kind.Identifier>
|
|
13
14
|
|
|
14
15
|
private _node: Doddle<ResourceNode>
|
|
@@ -16,7 +17,7 @@ export abstract class AbsResource<Props extends object = object> {
|
|
|
16
17
|
get node() {
|
|
17
18
|
return this._node.pull()
|
|
18
19
|
}
|
|
19
|
-
constructor(
|
|
20
|
+
protected constructor(
|
|
20
21
|
origin: Origin,
|
|
21
22
|
readonly name: string,
|
|
22
23
|
readonly props: Props
|
package/src/node/equiv-cdk8s.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { Embedder } from "@k8ts/instruments"
|
|
1
|
+
import { Embedder, Kinded, LiveRefable } from "@k8ts/instruments"
|
|
2
2
|
import { Construct } from "constructs"
|
|
3
|
-
import { ManifestResource } from "./manifest-resource"
|
|
4
3
|
|
|
5
4
|
export type Cdk8sCtor = {
|
|
6
5
|
new (parent: Construct, id: string, props: any): Construct
|
|
7
6
|
}
|
|
8
|
-
export type
|
|
9
|
-
export const EquivCdk8s = new Embedder<
|
|
7
|
+
export type KindedCtor = new (...args: any[]) => Kinded
|
|
8
|
+
export const EquivCdk8s = new Embedder<LiveRefable, Cdk8sCtor>("CDK8S_RESOURCE")
|
|
10
9
|
|
|
11
10
|
export function equiv_cdk8s(ctor: Cdk8sCtor) {
|
|
12
|
-
return <F extends
|
|
11
|
+
return <F extends KindedCtor>(target: F) => {
|
|
13
12
|
const cdk8s = EquivCdk8s.tryGet(target.prototype)
|
|
14
13
|
if (cdk8s) {
|
|
15
14
|
throw new Error(`Target ${target} already has a cdk8s equivalent! ${cdk8s}`)
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Builder, Kind, type Origin } from "@k8ts/instruments"
|
|
2
2
|
import type { Meta, MutableMeta } from "@k8ts/metadata"
|
|
3
|
+
import { ResourceIdentBlock } from "./abs-resource"
|
|
3
4
|
import { TopResource } from "./top-resource"
|
|
4
5
|
|
|
6
|
+
export interface ManifestResourceIdent extends ResourceIdentBlock {
|
|
7
|
+
name: string
|
|
8
|
+
}
|
|
5
9
|
export abstract class ManifestResource<Props extends object = object> extends TopResource<Props> {
|
|
6
10
|
protected async manifest() {
|
|
7
11
|
return Builder.get(this).manifest()
|
package/src/node/sub-resource.ts
CHANGED
|
@@ -7,14 +7,14 @@ import type { ManifestResource } from "./manifest-resource"
|
|
|
7
7
|
})
|
|
8
8
|
export abstract class SubResource<Props extends object = object> extends AbsResource<Props> {
|
|
9
9
|
constructor(
|
|
10
|
-
readonly parent: ManifestResource,
|
|
10
|
+
readonly parent: SubResource | ManifestResource,
|
|
11
11
|
name: string,
|
|
12
12
|
props: Props
|
|
13
13
|
) {
|
|
14
14
|
super(parent.node.origin, name, props)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
get namespace() {
|
|
17
|
+
get namespace(): string | undefined {
|
|
18
18
|
return this.parent.namespace
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
resolveText
|
|
9
9
|
} from "@k8ts/instruments"
|
|
10
10
|
import { CDK } from "../../_imports"
|
|
11
|
-
import { v1 } from "../../api-versions"
|
|
12
11
|
import { k8ts } from "../../kind-map"
|
|
12
|
+
import { api } from "../../kinds"
|
|
13
13
|
import { equiv_cdk8s } from "../../node/equiv-cdk8s"
|
|
14
14
|
import { ManifestResource } from "../../node/manifest-resource"
|
|
15
15
|
export type ConfigMap = ConfigMap.ConfigMap
|
|
@@ -20,8 +20,7 @@ export namespace ConfigMap {
|
|
|
20
20
|
binaryData?: DataSourceRecord_Binary
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
@k8ts(ident)
|
|
23
|
+
@k8ts(api.v1_.ConfigMap)
|
|
25
24
|
@relations("none")
|
|
26
25
|
@equiv_cdk8s(CDK.KubeConfigMap)
|
|
27
26
|
@manifest({
|
|
@@ -37,6 +36,6 @@ export namespace ConfigMap {
|
|
|
37
36
|
}
|
|
38
37
|
})
|
|
39
38
|
export class ConfigMap extends ManifestResource<Props> {
|
|
40
|
-
override kind =
|
|
39
|
+
override kind = api.v1_.ConfigMap
|
|
41
40
|
}
|
|
42
41
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { manifest, Origin, relations } from "@k8ts/instruments"
|
|
1
|
+
import { manifest, Origin, Refable, relations } from "@k8ts/instruments"
|
|
2
2
|
import { Meta, MutableMeta } from "@k8ts/metadata"
|
|
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 { equiv_cdk8s } from "../../node/equiv-cdk8s"
|
|
8
8
|
import { ManifestResource } from "../../node/manifest-resource"
|
|
9
9
|
import { PodTemplate } from "../pod/pod-template"
|
|
@@ -14,9 +14,10 @@ export namespace Deployment {
|
|
|
14
14
|
export type Props<Ports extends string> = SmallerProps & {
|
|
15
15
|
template: PodTemplate.Props<Ports>
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
export type AbsDeployment<Ports extends string> = Refable<api.apps_.v1_.Deployment> & {
|
|
18
|
+
__PORTS__: Ports
|
|
19
|
+
}
|
|
20
|
+
@k8ts(api.apps_.v1_.Deployment)
|
|
20
21
|
@equiv_cdk8s(CDK.KubeDeployment)
|
|
21
22
|
@relations({
|
|
22
23
|
kids: s => [s.template]
|
|
@@ -39,8 +40,10 @@ export namespace Deployment {
|
|
|
39
40
|
}
|
|
40
41
|
})
|
|
41
42
|
export class Deployment<Ports extends string = string> extends ManifestResource<Props<Ports>> {
|
|
42
|
-
|
|
43
|
+
__PORTS__!: Ports
|
|
44
|
+
kind = api.apps_.v1_.Deployment
|
|
43
45
|
template: PodTemplate<Ports>
|
|
46
|
+
|
|
44
47
|
constructor(origin: Origin, meta: Meta | MutableMeta, props: Props<Ports>) {
|
|
45
48
|
super(origin, meta, props)
|
|
46
49
|
this.template = new PodTemplate.PodTemplate(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { manifest, relations } from "@k8ts/instruments"
|
|
2
2
|
import { CDK } from "../../_imports"
|
|
3
|
-
import { gateway_v1 } from "../../api-versions"
|
|
4
3
|
import type { External } from "../../external"
|
|
5
4
|
import { k8ts } from "../../kind-map"
|
|
5
|
+
import { api } from "../../kinds"
|
|
6
6
|
import { ManifestResource } from "../../node"
|
|
7
7
|
import { equiv_cdk8s } from "../../node/equiv-cdk8s"
|
|
8
8
|
import type { Service } from "../service"
|
|
@@ -10,15 +10,13 @@ import type { Service } from "../service"
|
|
|
10
10
|
export type HttpRoute<Ports extends string> = HttpRoute.HttpRoute<Ports>
|
|
11
11
|
|
|
12
12
|
export namespace HttpRoute {
|
|
13
|
-
const gwKind = gateway_v1.kind("Gateway")
|
|
14
13
|
export interface Props<Ports extends string> {
|
|
15
|
-
gateway: External<
|
|
14
|
+
gateway: External<api.gateway_.v1_.Gateway>
|
|
16
15
|
hostname: string
|
|
17
16
|
backend: Service.Port<Ports>
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
@k8ts(kind)
|
|
19
|
+
@k8ts(api.gateway_.v1_.HttpRoute)
|
|
22
20
|
@relations({
|
|
23
21
|
needs: self => ({
|
|
24
22
|
gateway: self.props.gateway,
|
|
@@ -42,6 +40,6 @@ export namespace HttpRoute {
|
|
|
42
40
|
}
|
|
43
41
|
})
|
|
44
42
|
export class HttpRoute<Ports extends string> extends ManifestResource<Props<Ports>> {
|
|
45
|
-
kind =
|
|
43
|
+
kind = api.gateway_.v1_.HttpRoute
|
|
46
44
|
}
|
|
47
45
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { manifest, relations, type Origin } from "@k8ts/instruments"
|
|
2
2
|
import { Meta, MutableMeta } from "@k8ts/metadata"
|
|
3
3
|
import { CDK } from "../../_imports"
|
|
4
|
-
import { v1 } from "../../api-versions"
|
|
5
4
|
import { k8ts } from "../../kind-map"
|
|
5
|
+
import { api } from "../../kinds"
|
|
6
6
|
import { equiv_cdk8s } from "../../node/equiv-cdk8s"
|
|
7
7
|
import { ManifestResource } from "../../node/manifest-resource"
|
|
8
8
|
export type Namespace = Namespace.Namespace
|
|
9
9
|
export namespace Namespace {
|
|
10
10
|
export interface Props {}
|
|
11
|
-
|
|
12
|
-
@k8ts(ident)
|
|
11
|
+
@k8ts(api.v1_.Namespace)
|
|
13
12
|
@relations("none")
|
|
14
13
|
@equiv_cdk8s(CDK.KubeNamespace)
|
|
15
14
|
@manifest({
|
|
@@ -20,7 +19,7 @@ export namespace Namespace {
|
|
|
20
19
|
}
|
|
21
20
|
})
|
|
22
21
|
export class Namespace extends ManifestResource<Props> {
|
|
23
|
-
override kind =
|
|
22
|
+
override kind = api.v1_.Namespace
|
|
24
23
|
constructor(origin: Origin, meta: Meta | MutableMeta, props?: Props) {
|
|
25
24
|
super(origin, meta.toMutable(), props ?? {})
|
|
26
25
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { manifest, relations, ResourcesSpec, Unit } 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 { ManifestResource } from "../../../node"
|
|
6
6
|
import { equiv_cdk8s } from "../../../node/equiv-cdk8s"
|
|
7
7
|
import { Access } from "../access-mode"
|
|
@@ -18,15 +18,14 @@ export namespace Pvc {
|
|
|
18
18
|
export interface Props<Mode extends DataMode> extends PvcResources {
|
|
19
19
|
accessModes: Access
|
|
20
20
|
mode?: Mode
|
|
21
|
-
bind: Pv<Mode>
|
|
21
|
+
bind: Pv.AbsPv<Mode>
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
@k8ts(ident)
|
|
24
|
+
@k8ts(api.v1_.PersistentVolumeClaim)
|
|
26
25
|
@equiv_cdk8s(CDK.KubePersistentVolumeClaim)
|
|
27
26
|
@relations({
|
|
28
27
|
needs: self => ({
|
|
29
|
-
bind: self.
|
|
28
|
+
bind: self.bound
|
|
30
29
|
})
|
|
31
30
|
})
|
|
32
31
|
@manifest({
|
|
@@ -49,6 +48,10 @@ export namespace Pvc {
|
|
|
49
48
|
}
|
|
50
49
|
})
|
|
51
50
|
export class Pvc<Mode extends DataMode = DataMode> extends ManifestResource<Props<Mode>> {
|
|
52
|
-
kind =
|
|
51
|
+
kind = api.v1_.PersistentVolumeClaim
|
|
52
|
+
|
|
53
|
+
get bound() {
|
|
54
|
+
return this.props.bind as Pv<Mode>
|
|
55
|
+
}
|
|
53
56
|
}
|
|
54
57
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { manifest, relations, type Unit } from "@k8ts/instruments"
|
|
1
|
+
import { manifest, Refable, relations, type Unit } from "@k8ts/instruments"
|
|
2
2
|
import { CDK } from "../../../_imports"
|
|
3
|
-
import { v1 } from "../../../api-versions"
|
|
4
3
|
import { MakeError } from "../../../error"
|
|
5
4
|
import { k8ts } from "../../../kind-map"
|
|
5
|
+
import { api } from "../../../kinds"
|
|
6
6
|
import { equiv_cdk8s } from "../../../node/equiv-cdk8s"
|
|
7
7
|
import { ManifestResource } from "../../../node/manifest-resource"
|
|
8
8
|
import { Access } from "../access-mode"
|
|
@@ -23,9 +23,9 @@ export namespace Pv {
|
|
|
23
23
|
nodeAffinity?: CDK.VolumeNodeAffinity
|
|
24
24
|
}
|
|
25
25
|
export type Reclaim = "Retain" | "Delete" | "Recycle"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
export type AbsPv<Mode extends DataMode = DataMode> = Refable<api.v1_.PersistentVolume> & {
|
|
27
|
+
__MODE__: Mode
|
|
28
|
+
}
|
|
29
29
|
@equiv_cdk8s(CDK.KubePersistentVolume)
|
|
30
30
|
@manifest({
|
|
31
31
|
body(self) {
|
|
@@ -59,9 +59,10 @@ export namespace Pv {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
})
|
|
62
|
-
@k8ts(
|
|
62
|
+
@k8ts(api.v1_.PersistentVolume)
|
|
63
63
|
@relations("none")
|
|
64
64
|
export class Pv<Mode extends DataMode = DataMode> extends ManifestResource<Props<Mode>> {
|
|
65
|
-
|
|
65
|
+
__MODE__!: Mode
|
|
66
|
+
readonly kind = api.v1_.PersistentVolume
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -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,11 @@ 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
|
-
export interface
|
|
37
|
+
export interface K8tsProps<Ports extends string = never> {
|
|
34
38
|
image: TaggedImage
|
|
35
39
|
ports?: InputPortSetRecord<Ports>
|
|
36
40
|
command?: CmdBuilder
|
|
@@ -39,19 +43,22 @@ export namespace Container {
|
|
|
39
43
|
securityContext?: CDK.SecurityContext
|
|
40
44
|
resources?: Resources
|
|
41
45
|
}
|
|
46
|
+
export type Props<Ports extends string = never> = K8tsProps<Ports> &
|
|
47
|
+
Omit<CDK.Container, keyof K8tsProps | "name">
|
|
48
|
+
|
|
49
|
+
@k8ts(api.v1_.Pod_.Container)
|
|
42
50
|
@relations({
|
|
43
51
|
needs: self => {
|
|
44
52
|
const a = self.mounts
|
|
45
53
|
return mapValues(
|
|
46
54
|
mapKeys(a, x => x.path),
|
|
47
|
-
x => x.mount.
|
|
55
|
+
x => x.mount.volume
|
|
48
56
|
)
|
|
49
57
|
}
|
|
50
58
|
})
|
|
51
|
-
export class Container<Ports extends string> extends SubResource<Props<Ports>> {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
59
|
+
export class Container<Ports extends string = string> extends SubResource<Props<Ports>> {
|
|
60
|
+
__PORTS__!: Ports
|
|
61
|
+
readonly kind = api.v1_.Pod_.Container
|
|
55
62
|
|
|
56
63
|
get mounts() {
|
|
57
64
|
return Map(this.props.mounts ?? {})
|
|
@@ -59,7 +66,7 @@ export namespace Container {
|
|
|
59
66
|
return [
|
|
60
67
|
mount,
|
|
61
68
|
{
|
|
62
|
-
mount,
|
|
69
|
+
mount: mount as Mount.ContainerVolumeMount | Mount.ContainerDeviceMount,
|
|
63
70
|
path: path as string
|
|
64
71
|
}
|
|
65
72
|
]
|
|
@@ -69,7 +76,7 @@ export namespace Container {
|
|
|
69
76
|
}
|
|
70
77
|
|
|
71
78
|
get volumes() {
|
|
72
|
-
return seq(this.mounts.map(x => x.mount.
|
|
79
|
+
return seq(this.mounts.map(x => x.mount.volume))
|
|
73
80
|
.uniq()
|
|
74
81
|
.toArray()
|
|
75
82
|
.pull()
|
|
@@ -96,7 +103,7 @@ export namespace Container {
|
|
|
96
103
|
parent: ManifestResource,
|
|
97
104
|
name: string,
|
|
98
105
|
readonly subtype: "init" | "main",
|
|
99
|
-
override readonly props:
|
|
106
|
+
override readonly props: K8tsProps<Ports>
|
|
100
107
|
) {
|
|
101
108
|
super(parent, name, props)
|
|
102
109
|
}
|
|
@@ -106,7 +113,8 @@ export namespace Container {
|
|
|
106
113
|
volumeMounts: [],
|
|
107
114
|
volumeDevices: []
|
|
108
115
|
} as Pick<CDK.Container, "volumeMounts" | "volumeDevices">
|
|
109
|
-
for (const
|
|
116
|
+
for (const mnt of this.mounts) {
|
|
117
|
+
const { mount, path } = mnt
|
|
110
118
|
if (mount instanceof Mount.ContainerDeviceMount) {
|
|
111
119
|
x.volumeDevices!.push(mount.submanifest(path))
|
|
112
120
|
} else {
|