k8ts 0.9.1 → 0.11.2
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/common-world.d.ts +12 -0
- package/dist/common-world.d.ts.map +1 -0
- package/dist/{default-world.js → common-world.js} +11 -6
- package/dist/common-world.js.map +1 -0
- package/dist/env/env.d.ts +10 -12
- package/dist/env/env.d.ts.map +1 -1
- package/dist/env/env.js +9 -34
- package/dist/env/env.js.map +1 -1
- package/dist/env/index.d.ts +1 -1
- package/dist/env/index.d.ts.map +1 -1
- package/dist/env/types.d.ts +5 -13
- package/dist/env/types.d.ts.map +1 -1
- package/dist/env/types.js +0 -11
- package/dist/env/types.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/origins/file/file.d.ts +3 -3
- package/dist/origins/file/file.d.ts.map +1 -1
- package/dist/origins/file/file.js +1 -1
- package/dist/origins/file/file.js.map +1 -1
- package/dist/origins/file/modifier.js +1 -1
- package/dist/origins/file/modifier.js.map +1 -1
- package/dist/origins/file/section.d.ts +4 -4
- package/dist/origins/file/section.d.ts.map +1 -1
- package/dist/origins/file/section.js +1 -1
- package/dist/origins/file/section.js.map +1 -1
- package/dist/origins/index.d.ts +0 -1
- package/dist/origins/index.d.ts.map +1 -1
- package/dist/origins/index.js +0 -1
- package/dist/origins/index.js.map +1 -1
- package/dist/origins/world.d.ts +2 -5
- package/dist/origins/world.d.ts.map +1 -1
- package/dist/origins/world.js +4 -10
- package/dist/origins/world.js.map +1 -1
- package/dist/resources/config/config-keys-of.d.ts +2 -0
- package/dist/resources/config/config-keys-of.d.ts.map +1 -0
- package/dist/resources/config/config-keys-of.js +3 -0
- package/dist/resources/config/config-keys-of.js.map +1 -0
- package/dist/resources/config/configmap.d.ts +11 -0
- package/dist/resources/config/configmap.d.ts.map +1 -0
- package/dist/resources/config/configmap.js +20 -0
- package/dist/resources/config/configmap.js.map +1 -0
- package/dist/resources/config/index.d.ts +4 -0
- package/dist/resources/config/index.d.ts.map +1 -0
- package/dist/resources/{configmap → config}/index.js +2 -0
- package/dist/resources/config/index.js.map +1 -0
- package/dist/resources/config/key-ref.d.ts +7 -0
- package/dist/resources/config/key-ref.d.ts.map +1 -0
- package/dist/resources/config/key-ref.js +13 -0
- package/dist/resources/config/key-ref.js.map +1 -0
- package/dist/resources/config/resolver.d.ts +10 -0
- package/dist/resources/config/resolver.d.ts.map +1 -0
- package/dist/resources/config/resolver.js +31 -0
- package/dist/resources/config/resolver.js.map +1 -0
- package/dist/resources/config/secret.d.ts +24 -0
- package/dist/resources/config/secret.d.ts.map +1 -0
- package/dist/resources/config/secret.js +24 -0
- package/dist/resources/config/secret.js.map +1 -0
- package/dist/resources/deployment/deployment.d.ts +2 -2
- package/dist/resources/deployment/deployment.d.ts.map +1 -1
- package/dist/resources/http-route/http-route.d.ts +3 -3
- package/dist/resources/index.d.ts +3 -7
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +3 -7
- package/dist/resources/index.js.map +1 -1
- package/dist/resources/persistent/claim/pvc.d.ts +3 -3
- 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.map +1 -1
- package/dist/resources/pod/container/container.d.ts +13 -9
- package/dist/resources/pod/container/container.d.ts.map +1 -1
- package/dist/resources/pod/container/container.js +46 -0
- package/dist/resources/pod/container/container.js.map +1 -1
- package/dist/resources/pod/container/mounts.d.ts +2 -3
- package/dist/resources/pod/container/mounts.d.ts.map +1 -1
- package/dist/resources/pod/pod-template.d.ts +15 -7
- package/dist/resources/pod/pod-template.d.ts.map +1 -1
- package/dist/resources/pod/pod-template.js +11 -1
- package/dist/resources/pod/pod-template.js.map +1 -1
- package/dist/resources/pod/volume/devices.d.ts +1 -0
- package/dist/resources/pod/volume/devices.d.ts.map +1 -1
- package/dist/resources/pod/volume/devices.js +4 -0
- package/dist/resources/pod/volume/devices.js.map +1 -1
- package/dist/resources/pod/volume/volumes.d.ts +31 -14
- package/dist/resources/pod/volume/volumes.d.ts.map +1 -1
- package/dist/resources/pod/volume/volumes.js +29 -24
- package/dist/resources/pod/volume/volumes.js.map +1 -1
- package/dist/resources/rbac/cluster-role.d.ts +1 -1
- package/dist/resources/rbac/cluster-role.d.ts.map +1 -1
- package/dist/resources/rbac/cluster-role.js +1 -1
- package/dist/resources/rbac/cluster-role.js.map +1 -1
- package/dist/resources/rbac/index.d.ts +4 -0
- package/dist/resources/rbac/index.d.ts.map +1 -0
- package/dist/resources/{secret → rbac}/index.js +3 -1
- package/dist/resources/rbac/index.js.map +1 -0
- package/dist/resources/service/service.d.ts +2 -2
- package/dist/resources/service/service.d.ts.map +1 -1
- package/dist/resources/service/service.js.map +1 -1
- package/dist/runner/exporter/assembler.d.ts.map +1 -1
- package/dist/runner/exporter/assembler.js +1 -0
- package/dist/runner/exporter/assembler.js.map +1 -1
- package/dist/runner/exporter/loader.d.ts.map +1 -1
- package/dist/runner/exporter/loader.js +2 -0
- package/dist/runner/exporter/loader.js.map +1 -1
- package/dist/runner/exporter/manifester.d.ts.map +1 -1
- package/dist/runner/exporter/manifester.js +0 -2
- package/dist/runner/exporter/manifester.js.map +1 -1
- package/package.json +9 -10
- package/src/{default-world.ts → common-world.ts} +14 -7
- package/src/env/env.ts +30 -57
- package/src/env/index.ts +1 -1
- package/src/env/types.ts +5 -22
- package/src/index.ts +1 -2
- package/src/origins/file/file.ts +4 -7
- package/src/origins/file/modifier.ts +1 -1
- package/src/origins/file/section.ts +5 -12
- package/src/origins/index.ts +0 -1
- package/src/origins/world.ts +4 -12
- package/src/resources/config/config-keys-of.ts +0 -0
- package/src/resources/config/configmap.ts +24 -0
- package/src/resources/config/index.ts +3 -0
- package/src/resources/config/key-ref.ts +8 -0
- package/src/resources/config/resolver.ts +29 -0
- package/src/resources/config/secret.ts +43 -0
- package/src/resources/deployment/deployment.ts +2 -2
- package/src/resources/http-route/http-route.ts +2 -2
- package/src/resources/index.ts +3 -7
- package/src/resources/persistent/claim/pvc.ts +2 -2
- package/src/resources/persistent/volume/pv.ts +5 -11
- package/src/resources/pod/container/container.ts +70 -9
- package/src/resources/pod/container/mounts.ts +1 -1
- package/src/resources/pod/pod-template.ts +54 -6
- package/src/resources/pod/volume/devices.ts +4 -1
- package/src/resources/pod/volume/volumes.ts +66 -53
- package/src/resources/rbac/cluster-role.ts +1 -1
- package/src/resources/rbac/index.ts +3 -0
- package/src/resources/service/service.ts +2 -2
- package/src/runner/exporter/assembler.ts +1 -0
- package/src/runner/exporter/loader.ts +3 -0
- package/src/runner/exporter/manifester.ts +0 -3
- package/dist/default-world.d.ts +0 -5
- package/dist/default-world.d.ts.map +0 -1
- package/dist/default-world.js.map +0 -1
- package/dist/origins/external.d.ts +0 -8
- package/dist/origins/external.d.ts.map +0 -1
- package/dist/origins/external.js +0 -19
- package/dist/origins/external.js.map +0 -1
- package/dist/resources/configmap/configmap.d.ts +0 -12
- package/dist/resources/configmap/configmap.d.ts.map +0 -1
- package/dist/resources/configmap/configmap.js +0 -27
- package/dist/resources/configmap/configmap.js.map +0 -1
- package/dist/resources/configmap/index.d.ts +0 -2
- package/dist/resources/configmap/index.d.ts.map +0 -1
- package/dist/resources/configmap/index.js.map +0 -1
- package/dist/resources/external/index.d.ts +0 -19
- package/dist/resources/external/index.d.ts.map +0 -1
- package/dist/resources/external/index.js +0 -44
- package/dist/resources/external/index.js.map +0 -1
- package/dist/resources/secret/index.d.ts +0 -2
- package/dist/resources/secret/index.d.ts.map +0 -1
- package/dist/resources/secret/index.js.map +0 -1
- package/dist/resources/secret/secret.d.ts +0 -13
- package/dist/resources/secret/secret.d.ts.map +0 -1
- package/dist/resources/secret/secret.js +0 -18
- package/dist/resources/secret/secret.js.map +0 -1
- package/src/origins/external.ts +0 -14
- package/src/resources/configmap/configmap.ts +0 -36
- package/src/resources/configmap/index.ts +0 -1
- package/src/resources/external/index.ts +0 -49
- package/src/resources/secret/index.ts +0 -1
- package/src/resources/secret/secret.ts +0 -20
package/src/env/env.ts
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Ref2_Of } from "@k8ts/instruments"
|
|
2
2
|
import type { CDK } from "@k8ts/sample-interfaces"
|
|
3
3
|
import { seq } from "doddle"
|
|
4
4
|
import { isObject } from "what-are-you"
|
|
5
5
|
import { MakeError } from "../error"
|
|
6
6
|
import { v1 } from "../kinds/index"
|
|
7
|
-
import {
|
|
8
|
-
toInputEnv,
|
|
9
|
-
type EnvVarFrom,
|
|
10
|
-
type InputEnv,
|
|
11
|
-
type InputEnvMap,
|
|
12
|
-
type InputEnvMapping,
|
|
13
|
-
type InputEnvValue
|
|
14
|
-
} from "./types"
|
|
7
|
+
import { type Env_From, type Env_Leaf, type Env_Value } from "./types"
|
|
15
8
|
import { isValidEnvVarName } from "./validate-name"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
|
|
10
|
+
export class EnvBuilder<M extends Record<keyof M, Env_Leaf>> {
|
|
11
|
+
constructor(private readonly _env: M) {
|
|
12
|
+
for (const key of Object.keys(_env)) {
|
|
19
13
|
if (!isValidEnvVarName(key)) {
|
|
20
14
|
throw new MakeError("Invalid environment variable name", {
|
|
21
15
|
key: key
|
|
@@ -28,29 +22,31 @@ export class EnvBuilder {
|
|
|
28
22
|
return this._env
|
|
29
23
|
}
|
|
30
24
|
|
|
31
|
-
private _envFromSecret(value:
|
|
25
|
+
private _envFromSecret(value: Env_From): CDK.EnvVarSource {
|
|
32
26
|
return {
|
|
33
27
|
secretKeyRef: {
|
|
34
|
-
name: value.$
|
|
28
|
+
name: value.$backend.name,
|
|
35
29
|
key: value.key,
|
|
36
30
|
optional: value.optional
|
|
37
31
|
}
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
34
|
|
|
41
|
-
private _envFromConfigMap
|
|
35
|
+
private _envFromConfigMap<S extends Ref2_Of<v1.ConfigMap._>>(
|
|
36
|
+
value: Env_From
|
|
37
|
+
): CDK.EnvVarSource {
|
|
42
38
|
return {
|
|
43
39
|
configMapKeyRef: {
|
|
44
|
-
name: value.$
|
|
40
|
+
name: value.$backend.name,
|
|
45
41
|
key: value.key,
|
|
46
42
|
optional: value.optional
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
|
|
51
|
-
*[Symbol.iterator](): IterableIterator<[string,
|
|
52
|
-
for (const entry of this._env
|
|
53
|
-
yield entry
|
|
47
|
+
*[Symbol.iterator](): IterableIterator<[string, Env_Value]> {
|
|
48
|
+
for (const entry of Object.entries(this._env)) {
|
|
49
|
+
yield entry as any
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
|
|
@@ -63,18 +59,18 @@ export class EnvBuilder {
|
|
|
63
59
|
value: `${value}`
|
|
64
60
|
}
|
|
65
61
|
}
|
|
66
|
-
const resourceValue = value as
|
|
67
|
-
switch (resourceValue.$
|
|
62
|
+
const resourceValue = value as any
|
|
63
|
+
switch (resourceValue.$backend.kind) {
|
|
68
64
|
case v1.Secret._:
|
|
69
65
|
return {
|
|
70
66
|
name: key,
|
|
71
67
|
valueFrom: this._envFromSecret(resourceValue as any)
|
|
72
|
-
}
|
|
68
|
+
} satisfies CDK.EnvVar
|
|
73
69
|
case v1.ConfigMap._:
|
|
74
70
|
return {
|
|
75
71
|
name: key,
|
|
76
72
|
valueFrom: this._envFromConfigMap(resourceValue as any)
|
|
77
|
-
}
|
|
73
|
+
} satisfies CDK.EnvVar
|
|
78
74
|
default:
|
|
79
75
|
throw new MakeError("Invalid environment variable reference", {
|
|
80
76
|
key: key,
|
|
@@ -85,37 +81,6 @@ export class EnvBuilder {
|
|
|
85
81
|
.toArray()
|
|
86
82
|
.pull()
|
|
87
83
|
}
|
|
88
|
-
private _withEnv(f: (env: InputEnvMap) => InputEnvMap) {
|
|
89
|
-
return new EnvBuilder(f(this._env))
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
add(name: string, value: InputEnvMapping[string]): EnvBuilder
|
|
93
|
-
add(input: InputEnvMapping): EnvBuilder
|
|
94
|
-
add(a: any, b?: any) {
|
|
95
|
-
const pairs: [string, string][] = typeof a === "string" ? [[a, b]] : Object.entries(a)
|
|
96
|
-
const map = new Map(pairs)
|
|
97
|
-
const existingKeys = seq(map.keys())
|
|
98
|
-
.filter(k => this._env.has(k))
|
|
99
|
-
.toArray()
|
|
100
|
-
.pull()
|
|
101
|
-
if (existingKeys.length > 0) {
|
|
102
|
-
throw new MakeError("Cannot overwrite existing keys using add", {
|
|
103
|
-
keys: existingKeys
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
return this._withEnv(env => merge(env, map))
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
overwrite(name: string, value: string): EnvBuilder
|
|
110
|
-
overwrite(input: InputEnvMapping): EnvBuilder
|
|
111
|
-
overwrite(a: any, b?: any) {
|
|
112
|
-
if (typeof a === "string") {
|
|
113
|
-
return this._withEnv(env => env.set(a, b))
|
|
114
|
-
} else {
|
|
115
|
-
const map = toInputEnv(a)
|
|
116
|
-
return this._withEnv(env => merge(env, map))
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
84
|
|
|
120
85
|
toObject() {
|
|
121
86
|
return seq(this)
|
|
@@ -124,11 +89,19 @@ export class EnvBuilder {
|
|
|
124
89
|
.pull()
|
|
125
90
|
}
|
|
126
91
|
|
|
127
|
-
|
|
128
|
-
return
|
|
92
|
+
get entries() {
|
|
93
|
+
return Object.entries(this._env) as [string, Env_Leaf][]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static make<M>(env?: M) {
|
|
97
|
+
return new EnvBuilder(env ?? {})
|
|
129
98
|
}
|
|
130
99
|
}
|
|
131
100
|
|
|
132
|
-
export function Env
|
|
101
|
+
export function Env<
|
|
102
|
+
M extends {
|
|
103
|
+
[key in keyof M]: Env_Leaf
|
|
104
|
+
}
|
|
105
|
+
>(env?: M) {
|
|
133
106
|
return EnvBuilder.make(env)
|
|
134
107
|
}
|
package/src/env/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Env, EnvBuilder } from "./env"
|
|
2
|
-
export type {
|
|
2
|
+
export type { Env_From, Env_Leaf, Env_Value } from "./types"
|
package/src/env/types.ts
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { EnvBuilder } from "./env"
|
|
1
|
+
import type { Ref2_Of } from "@k8ts/instruments"
|
|
3
2
|
|
|
4
|
-
export type
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
$ref: Resource_Core_Ref<_Kind>
|
|
3
|
+
export type Env_Value = string | null | number | boolean | bigint | undefined
|
|
4
|
+
export interface Env_From {
|
|
5
|
+
$backend: Ref2_Of
|
|
8
6
|
key: string
|
|
9
7
|
optional?: boolean
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
export type
|
|
13
|
-
|
|
14
|
-
export function toInputEnv(env: InputEnv): InputEnvMap {
|
|
15
|
-
if (env instanceof EnvBuilder) {
|
|
16
|
-
return new Map(env["_env"])
|
|
17
|
-
}
|
|
18
|
-
if (env instanceof Map) {
|
|
19
|
-
return new Map(env)
|
|
20
|
-
}
|
|
21
|
-
return new Map(Object.entries(env))
|
|
22
|
-
}
|
|
23
|
-
export type EnvFrom<_Kind extends Kind = Kind> = {
|
|
24
|
-
$ref: Resource_Core_Ref<_Kind>
|
|
25
|
-
prefix?: string
|
|
26
|
-
}
|
|
27
|
-
export type InputEnvMap = Map<string, InputEnvValue>
|
|
10
|
+
export type Env_Leaf = string | null | number | boolean | bigint | undefined | Env_From
|
package/src/index.ts
CHANGED
package/src/origins/file/file.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Origin_Exporter,
|
|
4
4
|
type Origin_Entity,
|
|
5
5
|
type Origin_Props,
|
|
6
|
-
type
|
|
6
|
+
type Ref2_Of,
|
|
7
7
|
type Resource_Ctor_Of
|
|
8
8
|
} from "@k8ts/instruments"
|
|
9
9
|
import { doddlify, seq } from "doddle"
|
|
@@ -15,7 +15,7 @@ export interface File_Props<
|
|
|
15
15
|
Exports extends Kinds[number]["prototype"] = Kinds[number]["prototype"]
|
|
16
16
|
> extends Origin_Props<Kinds[number]> {
|
|
17
17
|
kinds?: Kinds
|
|
18
|
-
namespace?:
|
|
18
|
+
namespace?: Ref2_Of<v1.Namespace._>
|
|
19
19
|
FILE(FILE: Origin_File_Scope<Kinds>): Iterable<Exports | FwRef_Exports<Exports>>
|
|
20
20
|
}
|
|
21
21
|
export class Origin_File extends Origin_Exporter<File_Props> {
|
|
@@ -26,16 +26,13 @@ export class Origin_File extends Origin_Exporter<File_Props> {
|
|
|
26
26
|
this.meta.overwrite("namespace", this._props.namespace?.name)
|
|
27
27
|
})()
|
|
28
28
|
get kind() {
|
|
29
|
-
return "k8ts
|
|
29
|
+
return "[k8ts] File"
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
@doddlify
|
|
33
33
|
protected __exports__() {
|
|
34
34
|
return seq(
|
|
35
|
-
this._props.FILE.call(
|
|
36
|
-
this,
|
|
37
|
-
new Origin_File_Scope(this) as any
|
|
38
|
-
) as Iterable<Resource_Core_Ref>
|
|
35
|
+
this._props.FILE.call(this, new Origin_File_Scope(this) as any) as Iterable<Ref2_Of>
|
|
39
36
|
).cache()
|
|
40
37
|
}
|
|
41
38
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Origin_Exporter_Props,
|
|
3
|
-
type Resource_Core_Ref,
|
|
4
|
-
Origin_Exporter
|
|
5
|
-
} from "@k8ts/instruments"
|
|
1
|
+
import { type Origin_Exporter_Props, type Ref2_Of, Origin_Exporter } from "@k8ts/instruments"
|
|
6
2
|
import { doddle, doddlify, seq } from "doddle"
|
|
7
3
|
import type { v1 } from "../../kinds"
|
|
8
4
|
|
|
@@ -15,15 +11,15 @@ export class File_Section_Scope {
|
|
|
15
11
|
this.on = this._section.on
|
|
16
12
|
}
|
|
17
13
|
}
|
|
18
|
-
export interface File_Section_Props<Exported extends
|
|
14
|
+
export interface File_Section_Props<Exported extends Ref2_Of = Ref2_Of>
|
|
19
15
|
extends Origin_Exporter_Props {
|
|
20
|
-
namespace?:
|
|
16
|
+
namespace?: Ref2_Of<v1.Namespace._>
|
|
21
17
|
SECTION(SCOPE: File_Section_Scope): Iterable<Exported>
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
export class Origin_Section extends Origin_Exporter<File_Section_Props> {
|
|
25
21
|
get kind() {
|
|
26
|
-
return "k8ts
|
|
22
|
+
return "[k8ts] File/Section"
|
|
27
23
|
}
|
|
28
24
|
#_ = doddle(() => {
|
|
29
25
|
this.meta.overwrite({
|
|
@@ -34,10 +30,7 @@ export class Origin_Section extends Origin_Exporter<File_Section_Props> {
|
|
|
34
30
|
@doddlify
|
|
35
31
|
protected __exports__() {
|
|
36
32
|
return seq(
|
|
37
|
-
this._props.SECTION.call(
|
|
38
|
-
this,
|
|
39
|
-
new File_Section_Scope(this)
|
|
40
|
-
) as Iterable<Resource_Core_Ref>
|
|
33
|
+
this._props.SECTION.call(this, new File_Section_Scope(this)) as Iterable<Ref2_Of>
|
|
41
34
|
).cache()
|
|
42
35
|
}
|
|
43
36
|
}
|
package/src/origins/index.ts
CHANGED
package/src/origins/world.ts
CHANGED
|
@@ -1,34 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Origin_Entity,
|
|
3
3
|
type FwRef_Exports,
|
|
4
|
-
type Kind,
|
|
5
4
|
type Origin_Props,
|
|
6
5
|
type Resource_Ctor_Of
|
|
7
6
|
} from "@k8ts/instruments"
|
|
8
7
|
|
|
9
|
-
import { External } from "../resources/external"
|
|
10
|
-
import { Origin_External } from "./external"
|
|
11
8
|
import { File, type File_Props, type File_sName } from "./file"
|
|
12
9
|
|
|
13
10
|
export type World_Props<Kinds extends Resource_Ctor_Of[]> = Origin_Props<Kinds[number]>
|
|
14
11
|
|
|
15
|
-
export class
|
|
16
|
-
|
|
17
|
-
> {
|
|
12
|
+
export class World_Entity<
|
|
13
|
+
Kinds extends Resource_Ctor_Of[] = Resource_Ctor_Of[]
|
|
14
|
+
> extends Origin_Entity<World_Props<Kinds>> {
|
|
18
15
|
get kind() {
|
|
19
|
-
return "k8ts
|
|
16
|
+
return "[k8ts] World"
|
|
20
17
|
}
|
|
21
|
-
private readonly _ExternalOrigin = new Origin_External(this)
|
|
22
18
|
#_ = (() => {
|
|
23
19
|
this.meta.add("source.k8ts.org/", {
|
|
24
20
|
"^world": this.name
|
|
25
21
|
})
|
|
26
22
|
})()
|
|
27
23
|
|
|
28
|
-
External<K extends Kind, Name extends string>(kind: K, name: Name, namespace?: string) {
|
|
29
|
-
return new External(this._ExternalOrigin, kind.refKey(name), namespace)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
24
|
File<Exports extends Resource_Ctor_Of["prototype"]>(
|
|
33
25
|
name: File_sName,
|
|
34
26
|
props: File_Props<Kinds, Exports>
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Resource_Top, type DataSource } from "@k8ts/instruments"
|
|
2
|
+
import { CDK } from "@k8ts/sample-interfaces"
|
|
3
|
+
import { v1 } from "../../kinds/default"
|
|
4
|
+
import { resolveDataSourceRecord } from "./resolver"
|
|
5
|
+
export interface ConfigMap_Props<Keys extends string = string> {
|
|
6
|
+
$data: Record<Keys, DataSource>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class ConfigMap<
|
|
10
|
+
Name extends string = string,
|
|
11
|
+
Keys extends string = string
|
|
12
|
+
> extends Resource_Top<Name, ConfigMap_Props<Keys>> {
|
|
13
|
+
get keys(): Keys[] {
|
|
14
|
+
return Object.keys(this.props.$data) as Keys[]
|
|
15
|
+
}
|
|
16
|
+
get kind() {
|
|
17
|
+
return v1.ConfigMap._
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected async body(): Promise<CDK.KubeConfigMapProps> {
|
|
21
|
+
const resolvedRecord = await resolveDataSourceRecord(this, this.props.$data)
|
|
22
|
+
return resolvedRecord
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DataSource_Lazy, type DataSource, type Resource_Ref_Min } from "@k8ts/instruments"
|
|
2
|
+
import { isArrayBufferLike, isTypedArray } from "what-are-you"
|
|
3
|
+
|
|
4
|
+
export async function resolveDataSourceRecord(
|
|
5
|
+
resource: Resource_Ref_Min,
|
|
6
|
+
input: Record<string, DataSource>
|
|
7
|
+
) {
|
|
8
|
+
const binaryData: [string, string][] = []
|
|
9
|
+
const data: [string, string][] = []
|
|
10
|
+
const entries = Object.entries(input ?? {}) as [string, DataSource][]
|
|
11
|
+
for (const [k, v] of entries) {
|
|
12
|
+
let current = v
|
|
13
|
+
if (current instanceof DataSource_Lazy) {
|
|
14
|
+
current = await current.get()
|
|
15
|
+
}
|
|
16
|
+
if (isTypedArray(current) || isArrayBufferLike(current)) {
|
|
17
|
+
const encoded = Buffer.from(current).toString("base64")
|
|
18
|
+
binaryData.push([k, encoded])
|
|
19
|
+
} else if (typeof current === "string") {
|
|
20
|
+
data.push([k, current])
|
|
21
|
+
} else {
|
|
22
|
+
throw new Error(`Unsupported DataSource for ConfigMap ${resource} key "${k}"`)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
data: Object.fromEntries(data),
|
|
27
|
+
binaryData: Object.fromEntries(binaryData)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Resource_Top, type DataSource } from "@k8ts/instruments"
|
|
2
|
+
import { v1 } from "../../kinds/default"
|
|
3
|
+
import { resolveDataSourceRecord } from "./resolver"
|
|
4
|
+
|
|
5
|
+
export interface Secret_Data_Entry {
|
|
6
|
+
as: "base64" | "plain"
|
|
7
|
+
value: DataSource
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type Secret_Types =
|
|
11
|
+
| `kubernetes.io/${
|
|
12
|
+
| "service-account-token"
|
|
13
|
+
| "dockercfg"
|
|
14
|
+
| "dockerconfigjson"
|
|
15
|
+
| "basic-auth"
|
|
16
|
+
| "ssh-auth"
|
|
17
|
+
| "tls"}`
|
|
18
|
+
| "bootstrap.kubernetes.io/token"
|
|
19
|
+
export interface Secret_Props<Keys extends string = string> {
|
|
20
|
+
$type?: Secret_Types
|
|
21
|
+
$data?: Record<Keys, DataSource>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class Secret<
|
|
25
|
+
Name extends string = string,
|
|
26
|
+
Keys extends string = string
|
|
27
|
+
> extends Resource_Top<Name, Secret_Props<Keys>> {
|
|
28
|
+
get keys() {
|
|
29
|
+
return Object.keys(this.props.$data ?? {}) as Keys[]
|
|
30
|
+
}
|
|
31
|
+
get kind() {
|
|
32
|
+
return v1.Secret._
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
protected async body() {
|
|
36
|
+
const resolved = await resolveDataSourceRecord(this, this.props.$data ?? {})
|
|
37
|
+
return {
|
|
38
|
+
type: this.props.$type ?? "Opaque",
|
|
39
|
+
data: resolved.binaryData,
|
|
40
|
+
stringData: resolved.data
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OriginContextTracker,
|
|
3
|
-
|
|
3
|
+
Ref2_Of,
|
|
4
4
|
Resource_Top,
|
|
5
5
|
type Resource_Entity
|
|
6
6
|
} from "@k8ts/instruments"
|
|
@@ -27,7 +27,7 @@ export type Deployment_Props<Ports extends string> = Deployment_Props_Original &
|
|
|
27
27
|
$template: Pod_Props<Ports>
|
|
28
28
|
$strategy?: Deployment_Strategy
|
|
29
29
|
}
|
|
30
|
-
export type Deployment_Ref<Ports extends string> =
|
|
30
|
+
export type Deployment_Ref<Ports extends string> = Ref2_Of<apps.v1.Deployment._> & {
|
|
31
31
|
__PORTS__: Ports
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Resource_Top, type
|
|
1
|
+
import { Resource_Top, type Resource_Ref_Full } from "@k8ts/instruments"
|
|
2
2
|
import { CDK } from "@k8ts/sample-interfaces"
|
|
3
3
|
import { gateway } from "../../kinds/gateway"
|
|
4
4
|
import type { Port } from "../service/service-port"
|
|
@@ -7,7 +7,7 @@ const GatewayKind = gateway.v1.Gateway._
|
|
|
7
7
|
const HttpRouteKind = gateway.v1.HttpRoute._
|
|
8
8
|
|
|
9
9
|
export interface HttpRoute_Props<Ports extends string> {
|
|
10
|
-
$gateway:
|
|
10
|
+
$gateway: Resource_Ref_Full<gateway.v1.Gateway._>
|
|
11
11
|
$hostname: string
|
|
12
12
|
$backend: Port<Ports>
|
|
13
13
|
_filters?: CDK.HttpRouteSpecRulesFilters[]
|
package/src/resources/index.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./config"
|
|
2
2
|
export * from "./cronjob"
|
|
3
3
|
export * from "./deployment"
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./http-route/http-route"
|
|
4
|
+
export * from "./http-route"
|
|
6
5
|
export * from "./namespace"
|
|
7
6
|
export * from "./persistent"
|
|
8
7
|
export * from "./pod"
|
|
9
|
-
export * from "./rbac
|
|
10
|
-
export * from "./rbac/cluster-role-binding"
|
|
11
|
-
export * from "./rbac/service-account"
|
|
12
|
-
export * from "./secret"
|
|
8
|
+
export * from "./rbac"
|
|
13
9
|
export * from "./service"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Resource_Top, ResourcesSpec, Unit, type
|
|
1
|
+
import { Resource_Top, ResourcesSpec, Unit, type Resource_Ref_Full } from "@k8ts/instruments"
|
|
2
2
|
import { CDK } from "@k8ts/sample-interfaces"
|
|
3
3
|
import { Prefix$ } from "../../../_type/prefix$"
|
|
4
4
|
import { MakeError } from "../../../error"
|
|
@@ -17,7 +17,7 @@ type Pvc_Resources = Prefix$<(typeof pvc_ResourcesSpec)["__INPUT__"]>
|
|
|
17
17
|
export interface Pvc_Props<Mode extends Pv_VolumeMode> extends Pvc_Resources {
|
|
18
18
|
$accessModes: Access
|
|
19
19
|
$mode?: Mode
|
|
20
|
-
$storageClass?:
|
|
20
|
+
$storageClass?: Resource_Ref_Full<typeof StorageClassKind>
|
|
21
21
|
$bind?: Pv_Ref<Mode>
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Resource_Core_Ref,
|
|
3
|
-
Resource_Top,
|
|
4
|
-
type Resource_Full_Ref,
|
|
5
|
-
type Unit
|
|
6
|
-
} from "@k8ts/instruments"
|
|
1
|
+
import { Ref2_Of, Resource_Top, type Resource_Ref_Full, type Unit } from "@k8ts/instruments"
|
|
7
2
|
import { CDK } from "@k8ts/sample-interfaces"
|
|
8
3
|
import { MakeError } from "../../../error"
|
|
9
4
|
import { v1 } from "../../../kinds/default"
|
|
@@ -32,7 +27,7 @@ export interface Pv_Backend_Nfs {
|
|
|
32
27
|
export type Pv_Backend = Pv_Backend_HostPath | Pv_Backend_Local | Pv_Backend_Nfs
|
|
33
28
|
export interface Pv_Props_K8ts<Mode extends Pv_VolumeMode = Pv_VolumeMode> {
|
|
34
29
|
$accessModes: Access
|
|
35
|
-
$storageClass?:
|
|
30
|
+
$storageClass?: Resource_Ref_Full<storage.v1.StorageClass._>
|
|
36
31
|
$mode?: Mode
|
|
37
32
|
reclaimPolicy?: Reclaim
|
|
38
33
|
$capacity: Unit.Data
|
|
@@ -41,10 +36,9 @@ export interface Pv_Props_K8ts<Mode extends Pv_VolumeMode = Pv_VolumeMode> {
|
|
|
41
36
|
nodeAffinity?: CDK.VolumeNodeAffinity
|
|
42
37
|
}
|
|
43
38
|
export type Reclaim = "Retain" | "Delete" | "Recycle"
|
|
44
|
-
export type Pv_Ref<Mode extends Pv_VolumeMode = Pv_VolumeMode> =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
39
|
+
export type Pv_Ref<Mode extends Pv_VolumeMode = Pv_VolumeMode> = Ref2_Of<v1.PersistentVolume._> & {
|
|
40
|
+
__MODE__: Mode
|
|
41
|
+
}
|
|
48
42
|
|
|
49
43
|
export class Pv<
|
|
50
44
|
Mode extends Pv_VolumeMode = "Filesystem",
|