k8ts 0.5.0 → 0.5.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/.imports.tsbuildinfo +1 -1
- package/dist/_imports/k8s.d.ts +1 -1
- package/dist/_imports/k8s.js +1 -1
- package/dist/external/index.d.ts +1 -1
- package/dist/external/index.d.ts.map +1 -1
- package/dist/external/index.js +1 -1
- package/dist/external/index.js.map +1 -1
- package/dist/kinds.d.ts +12 -0
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +10 -0
- package/dist/kinds.js.map +1 -1
- package/dist/node/abs-resource.d.ts +1 -1
- package/dist/node/abs-resource.d.ts.map +1 -1
- package/dist/node/abs-resource.js.map +1 -1
- package/dist/resources/persistent/claim/pvc.d.ts +4 -1
- package/dist/resources/persistent/claim/pvc.d.ts.map +1 -1
- package/dist/resources/persistent/claim/pvc.js +9 -4
- package/dist/resources/persistent/claim/pvc.js.map +1 -1
- package/dist/resources/persistent/volume/parse-backend.d.ts +4 -1
- package/dist/resources/persistent/volume/parse-backend.d.ts.map +1 -1
- package/dist/resources/persistent/volume/parse-backend.js +4 -1
- package/dist/resources/persistent/volume/parse-backend.js.map +1 -1
- package/dist/resources/persistent/volume/pv.d.ts +3 -2
- package/dist/resources/persistent/volume/pv.d.ts.map +1 -1
- package/dist/resources/persistent/volume/pv.js +12 -3
- package/dist/resources/persistent/volume/pv.js.map +1 -1
- package/dist/runner/exporter/progress-shower.d.ts.map +1 -1
- package/dist/runner/exporter/progress-shower.js.map +1 -1
- package/dist/src.tsbuildinfo +1 -1
- package/dist/world/world.d.ts +1 -1
- package/dist/world/world.d.ts.map +1 -1
- package/dist/world/world.js.map +1 -1
- package/package.json +3 -3
- package/src/_imports/k8s.ts +2 -2
- package/src/external/index.ts +1 -1
- package/src/kinds.ts +15 -0
- package/src/node/abs-resource.ts +1 -1
- package/src/resources/persistent/claim/pvc.ts +14 -5
- package/src/resources/persistent/volume/parse-backend.ts +5 -2
- package/src/resources/persistent/volume/pv.ts +17 -5
- package/src/runner/exporter/progress-shower.ts +3 -1
- package/src/world/world.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "k8ts",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Powerful framwork for building Kubernetes manifests in TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kubernetes",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@datreeio/datree-cdk8s": "^1.3.5",
|
|
80
|
-
"@k8ts/instruments": "^0.4.
|
|
80
|
+
"@k8ts/instruments": "^0.4.10",
|
|
81
81
|
"@k8ts/metadata": "^0.4.6",
|
|
82
82
|
"@swc/core": "^1.11.11",
|
|
83
83
|
"@swc/jest": "^0.2.37",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"yamprint": "^0.8.4"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@k8ts/instruments": "^0.4.
|
|
101
|
+
"@k8ts/instruments": "^0.4.10",
|
|
102
102
|
"@k8ts/metadata": "^0.4.6"
|
|
103
103
|
},
|
|
104
104
|
"packageManager": "yarn@4.1.1",
|
package/src/_imports/k8s.ts
CHANGED
|
@@ -15157,7 +15157,7 @@ export interface PodSpec {
|
|
|
15157
15157
|
* @default false.
|
|
15158
15158
|
* @schema io.k8s.api.core.v1.PodSpec#hostPID
|
|
15159
15159
|
*/
|
|
15160
|
-
readonly
|
|
15160
|
+
readonly hostPID?: boolean
|
|
15161
15161
|
|
|
15162
15162
|
/**
|
|
15163
15163
|
* Use the host's user namespace. Optional: Default to true. If set to true or not present, the
|
|
@@ -15450,7 +15450,7 @@ export function toJson_PodSpec(obj: PodSpec | undefined): Record<string, any> |
|
|
|
15450
15450
|
hostAliases: obj.hostAliases?.map(y => toJson_HostAlias(y)),
|
|
15451
15451
|
hostIPC: obj.hostIpc,
|
|
15452
15452
|
hostNetwork: obj.hostNetwork,
|
|
15453
|
-
hostPID: obj.
|
|
15453
|
+
hostPID: obj.hostPID,
|
|
15454
15454
|
hostUsers: obj.hostUsers,
|
|
15455
15455
|
hostname: obj.hostname,
|
|
15456
15456
|
imagePullSecrets: obj.imagePullSecrets?.map(y => toJson_LocalObjectReference(y)),
|
package/src/external/index.ts
CHANGED
package/src/kinds.ts
CHANGED
|
@@ -124,4 +124,19 @@ export namespace api {
|
|
|
124
124
|
export type TlsRoute = typeof TlsRoute
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
+
|
|
128
|
+
export const storage = Kind.group("storage.k8s.io")
|
|
129
|
+
export type storage = typeof storage
|
|
130
|
+
export namespace storage_ {
|
|
131
|
+
export const v1 = storage.version("v1")
|
|
132
|
+
export type v1 = typeof v1
|
|
133
|
+
|
|
134
|
+
export namespace v1_ {
|
|
135
|
+
export const StorageClass = v1.kind("StorageClass")
|
|
136
|
+
export type StorageClass = typeof StorageClass
|
|
137
|
+
|
|
138
|
+
export const VolumeAttachment = v1.kind("VolumeAttachment")
|
|
139
|
+
export type VolumeAttachment = typeof VolumeAttachment
|
|
140
|
+
}
|
|
141
|
+
}
|
|
127
142
|
}
|
package/src/node/abs-resource.ts
CHANGED
|
@@ -19,7 +19,7 @@ export abstract class AbsResource<Props extends object = object> implements Reso
|
|
|
19
19
|
}
|
|
20
20
|
protected constructor(
|
|
21
21
|
origin: Origin,
|
|
22
|
-
|
|
22
|
+
public name: string,
|
|
23
23
|
readonly props: Props
|
|
24
24
|
) {
|
|
25
25
|
this._node = doddle(() => new ResourceNode(origin, this, RefKey.make(this.kind, this.name)))
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { manifest, relations, ResourcesSpec, Unit } from "@k8ts/instruments"
|
|
2
2
|
import { CDK } from "../../../_imports"
|
|
3
3
|
import { Prefix$ } from "../../../_type/prefix$"
|
|
4
|
+
import { MakeError } from "../../../error"
|
|
5
|
+
import { External } from "../../../external"
|
|
4
6
|
import { k8ts } from "../../../kind-map"
|
|
5
7
|
import { api } from "../../../kinds"
|
|
6
8
|
import { ManifestResource } from "../../../node"
|
|
@@ -19,31 +21,38 @@ export namespace Pvc {
|
|
|
19
21
|
export interface Props<Mode extends DataMode> extends PvcResources {
|
|
20
22
|
$accessModes: Access
|
|
21
23
|
$mode?: Mode
|
|
22
|
-
$
|
|
24
|
+
$storageClass?: External<api.storage_.v1_.StorageClass>
|
|
25
|
+
$bind?: Pv.AbsPv<Mode>
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
@k8ts(api.v1_.PersistentVolumeClaim)
|
|
26
29
|
@equiv_cdk8s(CDK.KubePersistentVolumeClaim)
|
|
27
30
|
@relations({
|
|
28
31
|
needs: self => ({
|
|
29
|
-
bind: self.bound
|
|
32
|
+
bind: self.bound,
|
|
33
|
+
storageClass: self.props.$storageClass
|
|
30
34
|
})
|
|
31
35
|
})
|
|
32
36
|
@manifest({
|
|
33
37
|
body(self): CDK.KubePersistentVolumeClaimProps {
|
|
34
|
-
const { $storage, $accessModes, $mode } = self.props
|
|
38
|
+
const { $storage, $accessModes, $mode, $storageClass, $bind } = self.props
|
|
35
39
|
const nAccessModes = Access.parse($accessModes)
|
|
40
|
+
if (!$bind && !$storageClass) {
|
|
41
|
+
throw new MakeError(
|
|
42
|
+
`While manifesting ${self.node.format("source")}, PVC that doesn't have a $bind must have a $storageClass.`
|
|
43
|
+
)
|
|
44
|
+
}
|
|
36
45
|
return {
|
|
37
46
|
spec: {
|
|
38
47
|
accessModes: nAccessModes,
|
|
39
|
-
volumeName: self.props.$bind
|
|
48
|
+
volumeName: self.props.$bind?.name,
|
|
40
49
|
volumeMode: $mode,
|
|
41
50
|
resources: pvc_ResourcesSpec
|
|
42
51
|
.parse({
|
|
43
52
|
storage: $storage
|
|
44
53
|
})
|
|
45
54
|
.toObject(),
|
|
46
|
-
storageClassName: "standard"
|
|
55
|
+
storageClassName: self.props.$storageClass?.name ?? "standard"
|
|
47
56
|
}
|
|
48
57
|
}
|
|
49
58
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { MakeError } from "../../../error"
|
|
2
2
|
import { Backend } from "./backend"
|
|
3
|
-
export function parseBackend(backend
|
|
4
|
-
switch (backend
|
|
3
|
+
export function parseBackend(backend?: Backend) {
|
|
4
|
+
switch (backend?.type) {
|
|
5
|
+
case undefined:
|
|
6
|
+
case null:
|
|
7
|
+
return {}
|
|
5
8
|
case "HostPath":
|
|
6
9
|
return {
|
|
7
10
|
hostPath: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { manifest, Refable, relations, type Unit } from "@k8ts/instruments"
|
|
2
2
|
import { CDK } from "../../../_imports"
|
|
3
3
|
import { MakeError } from "../../../error"
|
|
4
|
+
import { External } from "../../../external"
|
|
4
5
|
import { k8ts } from "../../../kind-map"
|
|
5
6
|
import { api } from "../../../kinds"
|
|
6
7
|
import { equiv_cdk8s } from "../../../node/equiv-cdk8s"
|
|
@@ -15,11 +16,11 @@ export namespace Pv {
|
|
|
15
16
|
export import Backend = Backend_
|
|
16
17
|
export interface Props<Mode extends DataMode = DataMode> {
|
|
17
18
|
$accessModes: Access
|
|
18
|
-
|
|
19
|
+
$storageClass?: External<api.storage_.v1_.StorageClass>
|
|
19
20
|
$mode?: Mode
|
|
20
21
|
reclaimPolicy?: Reclaim
|
|
21
22
|
$capacity: Unit.Data
|
|
22
|
-
$backend
|
|
23
|
+
$backend?: Backend
|
|
23
24
|
nodeAffinity?: CDK.VolumeNodeAffinity
|
|
24
25
|
}
|
|
25
26
|
export type Reclaim = "Retain" | "Delete" | "Recycle"
|
|
@@ -31,16 +32,21 @@ export namespace Pv {
|
|
|
31
32
|
body(self) {
|
|
32
33
|
const pvProps = self.props
|
|
33
34
|
const accessModes = Access.parse(pvProps.$accessModes)
|
|
34
|
-
if (self.props.$backend
|
|
35
|
+
if (self.props.$backend?.type === "Local") {
|
|
35
36
|
if (!pvProps.nodeAffinity) {
|
|
36
37
|
throw new MakeError(
|
|
37
38
|
`While manifesting ${self.node.format("source")}, PV with Local backend must have nodeAffinity.`
|
|
38
39
|
)
|
|
39
40
|
}
|
|
40
41
|
}
|
|
42
|
+
if (!self.props.$backend && !self.props.$storageClass) {
|
|
43
|
+
throw new MakeError(
|
|
44
|
+
`While manifesting ${self.node.format("source")}, PV that doesn't have a $backend must have a $storageClass.`
|
|
45
|
+
)
|
|
46
|
+
}
|
|
41
47
|
let base: CDK.PersistentVolumeSpec = {
|
|
42
48
|
accessModes,
|
|
43
|
-
storageClassName: pvProps
|
|
49
|
+
storageClassName: pvProps.$storageClass?.name ?? "standard",
|
|
44
50
|
capacity: pvProps.$capacity
|
|
45
51
|
? {
|
|
46
52
|
storage: CDK.Quantity.fromString(pvProps.$capacity)
|
|
@@ -60,7 +66,13 @@ export namespace Pv {
|
|
|
60
66
|
}
|
|
61
67
|
})
|
|
62
68
|
@k8ts(api.v1_.PersistentVolume)
|
|
63
|
-
@relations(
|
|
69
|
+
@relations({
|
|
70
|
+
needs(self) {
|
|
71
|
+
return {
|
|
72
|
+
storageClass: self.props.$storageClass
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
})
|
|
64
76
|
export class Pv<Mode extends DataMode = DataMode> extends ManifestResource<Props<Mode>> {
|
|
65
77
|
__MODE__!: Mode
|
|
66
78
|
readonly kind = api.v1_.PersistentVolume
|
|
@@ -12,7 +12,9 @@ function typedOnAny(
|
|
|
12
12
|
target: Assembler,
|
|
13
13
|
handler: (
|
|
14
14
|
typedEvent: {
|
|
15
|
-
[K in keyof AssemblerEventsTable]: AssemblerEventsTable[K] & {
|
|
15
|
+
[K in keyof AssemblerEventsTable]: AssemblerEventsTable[K] & {
|
|
16
|
+
type: K
|
|
17
|
+
}
|
|
16
18
|
}[keyof AssemblerEventsTable]
|
|
17
19
|
) => void | Promise<void>
|
|
18
20
|
) {
|
package/src/world/world.ts
CHANGED
|
@@ -30,7 +30,7 @@ export namespace World {
|
|
|
30
30
|
this._ExternalOrigin = new ExternalOriginEntity(this.node)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
External<K extends Kind>(kind: K, name: string, namespace
|
|
33
|
+
External<K extends Kind>(kind: K, name: string, namespace?: string) {
|
|
34
34
|
return new External(this._ExternalOrigin.node, kind, name, namespace)
|
|
35
35
|
}
|
|
36
36
|
|