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.
Files changed (173) hide show
  1. package/dist/common-world.d.ts +12 -0
  2. package/dist/common-world.d.ts.map +1 -0
  3. package/dist/{default-world.js → common-world.js} +11 -6
  4. package/dist/common-world.js.map +1 -0
  5. package/dist/env/env.d.ts +10 -12
  6. package/dist/env/env.d.ts.map +1 -1
  7. package/dist/env/env.js +9 -34
  8. package/dist/env/env.js.map +1 -1
  9. package/dist/env/index.d.ts +1 -1
  10. package/dist/env/index.d.ts.map +1 -1
  11. package/dist/env/types.d.ts +5 -13
  12. package/dist/env/types.d.ts.map +1 -1
  13. package/dist/env/types.js +0 -11
  14. package/dist/env/types.js.map +1 -1
  15. package/dist/index.d.ts +1 -2
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +3 -4
  18. package/dist/index.js.map +1 -1
  19. package/dist/origins/file/file.d.ts +3 -3
  20. package/dist/origins/file/file.d.ts.map +1 -1
  21. package/dist/origins/file/file.js +1 -1
  22. package/dist/origins/file/file.js.map +1 -1
  23. package/dist/origins/file/modifier.js +1 -1
  24. package/dist/origins/file/modifier.js.map +1 -1
  25. package/dist/origins/file/section.d.ts +4 -4
  26. package/dist/origins/file/section.d.ts.map +1 -1
  27. package/dist/origins/file/section.js +1 -1
  28. package/dist/origins/file/section.js.map +1 -1
  29. package/dist/origins/index.d.ts +0 -1
  30. package/dist/origins/index.d.ts.map +1 -1
  31. package/dist/origins/index.js +0 -1
  32. package/dist/origins/index.js.map +1 -1
  33. package/dist/origins/world.d.ts +2 -5
  34. package/dist/origins/world.d.ts.map +1 -1
  35. package/dist/origins/world.js +4 -10
  36. package/dist/origins/world.js.map +1 -1
  37. package/dist/resources/config/config-keys-of.d.ts +2 -0
  38. package/dist/resources/config/config-keys-of.d.ts.map +1 -0
  39. package/dist/resources/config/config-keys-of.js +3 -0
  40. package/dist/resources/config/config-keys-of.js.map +1 -0
  41. package/dist/resources/config/configmap.d.ts +11 -0
  42. package/dist/resources/config/configmap.d.ts.map +1 -0
  43. package/dist/resources/config/configmap.js +20 -0
  44. package/dist/resources/config/configmap.js.map +1 -0
  45. package/dist/resources/config/index.d.ts +4 -0
  46. package/dist/resources/config/index.d.ts.map +1 -0
  47. package/dist/resources/{configmap → config}/index.js +2 -0
  48. package/dist/resources/config/index.js.map +1 -0
  49. package/dist/resources/config/key-ref.d.ts +7 -0
  50. package/dist/resources/config/key-ref.d.ts.map +1 -0
  51. package/dist/resources/config/key-ref.js +13 -0
  52. package/dist/resources/config/key-ref.js.map +1 -0
  53. package/dist/resources/config/resolver.d.ts +10 -0
  54. package/dist/resources/config/resolver.d.ts.map +1 -0
  55. package/dist/resources/config/resolver.js +31 -0
  56. package/dist/resources/config/resolver.js.map +1 -0
  57. package/dist/resources/config/secret.d.ts +24 -0
  58. package/dist/resources/config/secret.d.ts.map +1 -0
  59. package/dist/resources/config/secret.js +24 -0
  60. package/dist/resources/config/secret.js.map +1 -0
  61. package/dist/resources/deployment/deployment.d.ts +2 -2
  62. package/dist/resources/deployment/deployment.d.ts.map +1 -1
  63. package/dist/resources/http-route/http-route.d.ts +3 -3
  64. package/dist/resources/index.d.ts +3 -7
  65. package/dist/resources/index.d.ts.map +1 -1
  66. package/dist/resources/index.js +3 -7
  67. package/dist/resources/index.js.map +1 -1
  68. package/dist/resources/persistent/claim/pvc.d.ts +3 -3
  69. package/dist/resources/persistent/volume/pv.d.ts +4 -4
  70. package/dist/resources/persistent/volume/pv.d.ts.map +1 -1
  71. package/dist/resources/persistent/volume/pv.js.map +1 -1
  72. package/dist/resources/pod/container/container.d.ts +13 -9
  73. package/dist/resources/pod/container/container.d.ts.map +1 -1
  74. package/dist/resources/pod/container/container.js +46 -0
  75. package/dist/resources/pod/container/container.js.map +1 -1
  76. package/dist/resources/pod/container/mounts.d.ts +2 -3
  77. package/dist/resources/pod/container/mounts.d.ts.map +1 -1
  78. package/dist/resources/pod/pod-template.d.ts +15 -7
  79. package/dist/resources/pod/pod-template.d.ts.map +1 -1
  80. package/dist/resources/pod/pod-template.js +11 -1
  81. package/dist/resources/pod/pod-template.js.map +1 -1
  82. package/dist/resources/pod/volume/devices.d.ts +1 -0
  83. package/dist/resources/pod/volume/devices.d.ts.map +1 -1
  84. package/dist/resources/pod/volume/devices.js +4 -0
  85. package/dist/resources/pod/volume/devices.js.map +1 -1
  86. package/dist/resources/pod/volume/volumes.d.ts +31 -14
  87. package/dist/resources/pod/volume/volumes.d.ts.map +1 -1
  88. package/dist/resources/pod/volume/volumes.js +29 -24
  89. package/dist/resources/pod/volume/volumes.js.map +1 -1
  90. package/dist/resources/rbac/cluster-role.d.ts +1 -1
  91. package/dist/resources/rbac/cluster-role.d.ts.map +1 -1
  92. package/dist/resources/rbac/cluster-role.js +1 -1
  93. package/dist/resources/rbac/cluster-role.js.map +1 -1
  94. package/dist/resources/rbac/index.d.ts +4 -0
  95. package/dist/resources/rbac/index.d.ts.map +1 -0
  96. package/dist/resources/{secret → rbac}/index.js +3 -1
  97. package/dist/resources/rbac/index.js.map +1 -0
  98. package/dist/resources/service/service.d.ts +2 -2
  99. package/dist/resources/service/service.d.ts.map +1 -1
  100. package/dist/resources/service/service.js.map +1 -1
  101. package/dist/runner/exporter/assembler.d.ts.map +1 -1
  102. package/dist/runner/exporter/assembler.js +1 -0
  103. package/dist/runner/exporter/assembler.js.map +1 -1
  104. package/dist/runner/exporter/loader.d.ts.map +1 -1
  105. package/dist/runner/exporter/loader.js +2 -0
  106. package/dist/runner/exporter/loader.js.map +1 -1
  107. package/dist/runner/exporter/manifester.d.ts.map +1 -1
  108. package/dist/runner/exporter/manifester.js +0 -2
  109. package/dist/runner/exporter/manifester.js.map +1 -1
  110. package/package.json +9 -10
  111. package/src/{default-world.ts → common-world.ts} +14 -7
  112. package/src/env/env.ts +30 -57
  113. package/src/env/index.ts +1 -1
  114. package/src/env/types.ts +5 -22
  115. package/src/index.ts +1 -2
  116. package/src/origins/file/file.ts +4 -7
  117. package/src/origins/file/modifier.ts +1 -1
  118. package/src/origins/file/section.ts +5 -12
  119. package/src/origins/index.ts +0 -1
  120. package/src/origins/world.ts +4 -12
  121. package/src/resources/config/config-keys-of.ts +0 -0
  122. package/src/resources/config/configmap.ts +24 -0
  123. package/src/resources/config/index.ts +3 -0
  124. package/src/resources/config/key-ref.ts +8 -0
  125. package/src/resources/config/resolver.ts +29 -0
  126. package/src/resources/config/secret.ts +43 -0
  127. package/src/resources/deployment/deployment.ts +2 -2
  128. package/src/resources/http-route/http-route.ts +2 -2
  129. package/src/resources/index.ts +3 -7
  130. package/src/resources/persistent/claim/pvc.ts +2 -2
  131. package/src/resources/persistent/volume/pv.ts +5 -11
  132. package/src/resources/pod/container/container.ts +70 -9
  133. package/src/resources/pod/container/mounts.ts +1 -1
  134. package/src/resources/pod/pod-template.ts +54 -6
  135. package/src/resources/pod/volume/devices.ts +4 -1
  136. package/src/resources/pod/volume/volumes.ts +66 -53
  137. package/src/resources/rbac/cluster-role.ts +1 -1
  138. package/src/resources/rbac/index.ts +3 -0
  139. package/src/resources/service/service.ts +2 -2
  140. package/src/runner/exporter/assembler.ts +1 -0
  141. package/src/runner/exporter/loader.ts +3 -0
  142. package/src/runner/exporter/manifester.ts +0 -3
  143. package/dist/default-world.d.ts +0 -5
  144. package/dist/default-world.d.ts.map +0 -1
  145. package/dist/default-world.js.map +0 -1
  146. package/dist/origins/external.d.ts +0 -8
  147. package/dist/origins/external.d.ts.map +0 -1
  148. package/dist/origins/external.js +0 -19
  149. package/dist/origins/external.js.map +0 -1
  150. package/dist/resources/configmap/configmap.d.ts +0 -12
  151. package/dist/resources/configmap/configmap.d.ts.map +0 -1
  152. package/dist/resources/configmap/configmap.js +0 -27
  153. package/dist/resources/configmap/configmap.js.map +0 -1
  154. package/dist/resources/configmap/index.d.ts +0 -2
  155. package/dist/resources/configmap/index.d.ts.map +0 -1
  156. package/dist/resources/configmap/index.js.map +0 -1
  157. package/dist/resources/external/index.d.ts +0 -19
  158. package/dist/resources/external/index.d.ts.map +0 -1
  159. package/dist/resources/external/index.js +0 -44
  160. package/dist/resources/external/index.js.map +0 -1
  161. package/dist/resources/secret/index.d.ts +0 -2
  162. package/dist/resources/secret/index.d.ts.map +0 -1
  163. package/dist/resources/secret/index.js.map +0 -1
  164. package/dist/resources/secret/secret.d.ts +0 -13
  165. package/dist/resources/secret/secret.d.ts.map +0 -1
  166. package/dist/resources/secret/secret.js +0 -18
  167. package/dist/resources/secret/secret.js.map +0 -1
  168. package/src/origins/external.ts +0 -14
  169. package/src/resources/configmap/configmap.ts +0 -36
  170. package/src/resources/configmap/index.ts +0 -1
  171. package/src/resources/external/index.ts +0 -49
  172. package/src/resources/secret/index.ts +0 -1
  173. package/src/resources/secret/secret.ts +0 -20
@@ -4,16 +4,17 @@ import {
4
4
  Unit,
5
5
  type CmdBuilder,
6
6
  type InputPortSetRecord,
7
+ type Ref2_Of,
7
8
  type TaggedImage
8
9
  } from "@k8ts/instruments"
9
10
  import type { CDK } from "@k8ts/sample-interfaces"
10
11
  import { toContainerPorts } from "../../utils/adapters"
11
12
 
12
- import type { Resource_Entity, Resource_Min_Ref, Resource_Top } from "@k8ts/instruments"
13
- import { Resource_Child } from "@k8ts/instruments"
13
+ import { Resource_Child, Resource_Entity, Resource_Ref_Min, Resource_Top } from "@k8ts/instruments"
14
14
  import { seq } from "doddle"
15
15
  import { mapKeys, mapValues, omitBy } from "lodash"
16
- import { Env, type InputEnvMapping } from "../../../env"
16
+ import { Env } from "../../../env"
17
+ import type { Env_Leaf } from "../../../env/types"
17
18
  import { v1 } from "../../../kinds/default"
18
19
  import { Container_Mount_Device, type Container_Mount } from "./mounts"
19
20
  const container_ResourcesSpec = ResourcesSpec.make({
@@ -22,24 +23,31 @@ const container_ResourcesSpec = ResourcesSpec.make({
22
23
  })
23
24
 
24
25
  type Container_Resources = (typeof container_ResourcesSpec)["__INPUT__"]
25
- type Container_Mount_Some = Resource_Min_Ref<
26
+ type Container_Mount_Some = Resource_Ref_Min<
26
27
  v1.Pod.Container.DeviceMount._ | v1.Pod.Container.VolumeMount._
27
28
  >
28
29
  export type Container_Mounts = {
29
30
  [key: string]: Container_Mount_Some
30
31
  }
31
- interface Container_Props_K8ts<Ports extends string = never> {
32
+
33
+ export interface Container_Env_From {
34
+ source: Ref2_Of<v1.ConfigMap._> | Ref2_Of<v1.Secret._>
35
+ prefix?: string
36
+ optional?: boolean
37
+ }
38
+ export interface Container_Props<
39
+ Ports extends string = never,
40
+ _Env extends Record<string, Env_Leaf> = Record<string, Env_Leaf>
41
+ > extends Omit<CDK.Container, "name"> {
32
42
  $image: TaggedImage
33
43
  $ports?: InputPortSetRecord<Ports>
34
44
  $command?: CmdBuilder
35
45
  $mounts?: Container_Mounts
36
- $env?: InputEnvMapping
46
+ $env?: _Env
47
+ $envFrom?: Container_Env_From[]
37
48
  $resources?: Container_Resources
38
49
  }
39
50
 
40
- export type Container_Props<Ports extends string = never> = Container_Props_K8ts<Ports> &
41
- Omit<CDK.Container, keyof Container_Props_K8ts | "name">
42
-
43
51
  export class Container<Ports extends string = string> extends Resource_Child<
44
52
  Container_Props<Ports>
45
53
  > {
@@ -86,6 +94,58 @@ export class Container<Ports extends string = string> extends Resource_Child<
86
94
  seq(toContainerPorts(PortSet.make($ports)).values())
87
95
  .toArray()
88
96
  .pull()
97
+
98
+ const env = Env($env)
99
+ for (const [key, value] of env.entries) {
100
+ if (typeof value !== "object") {
101
+ continue
102
+ }
103
+ if (!value) {
104
+ continue
105
+ }
106
+ const backend = value.$backend
107
+ if (backend instanceof Resource_Entity) {
108
+ if (backend.namespace !== self.namespace) {
109
+ throw new Error(
110
+ `Environment variable reference "${key}" must be in the same namespace as the container "${self}", but was ${backend}"`
111
+ )
112
+ }
113
+ }
114
+ }
115
+ for (const vol of self.volumes) {
116
+ if (vol.sourceNamespace !== self.namespace) {
117
+ throw new Error(
118
+ `Volume reference "${vol}" must be in the same namespace as the container "${self}"`
119
+ )
120
+ }
121
+ }
122
+ const envFroms = (self.props.$envFrom ?? []).map(ef => {
123
+ const source = ef.source as any as Resource_Entity
124
+ if (source.namespace !== self.namespace) {
125
+ throw new Error(
126
+ `EnvFrom source reference "${source}" must be in the same namespace as the container "${self}"`
127
+ )
128
+ }
129
+ if (source.is(v1.Secret._)) {
130
+ return {
131
+ secretRef: {
132
+ optional: ef.optional,
133
+ name: source.name
134
+ }
135
+ } as CDK.EnvFromSource
136
+ } else if (source.is(v1.ConfigMap._)) {
137
+ return {
138
+ configMapRef: {
139
+ optional: ef.optional,
140
+ name: source.name
141
+ }
142
+ } as CDK.EnvFromSource
143
+ } else {
144
+ throw new Error(
145
+ `EnvFrom source reference "${source}" must be a ConfigMap or Secret, but was ${source.kind}`
146
+ )
147
+ }
148
+ })
89
149
  const container: CDK.Container = {
90
150
  ...untaggedProps,
91
151
  name: self.name,
@@ -94,6 +154,7 @@ export class Container<Ports extends string = string> extends Resource_Child<
94
154
  resources: resourcesObject,
95
155
  command: $command?.toArray(),
96
156
  env: Env($env).toEnvVars(),
157
+ envFrom: envFroms,
97
158
  ...self._groupedMounts()
98
159
  }
99
160
  return container
@@ -3,7 +3,7 @@ import type { CDK } from "@k8ts/sample-interfaces"
3
3
  import { v1 } from "../../../kinds/default"
4
4
  import type { Pod_Volume } from "../volume"
5
5
  import type { Pod_Device } from "../volume/devices"
6
- type Path_Rooted = `/${string}`
6
+ export type Path_Rooted = `/${string}`
7
7
  export type Container_Mount_Path = `${"" | "." | ".."}${Path_Rooted}`
8
8
 
9
9
  export type Container_Mount = Container_Mount_Volume | Container_Mount_Device
@@ -1,14 +1,30 @@
1
- import { Resource_Child, Resource_Min_Ref } from "@k8ts/instruments"
1
+ import {
2
+ Resource_Child,
3
+ Resource_Ref_Min,
4
+ type Ref2_Of,
5
+ type Resource_Entity,
6
+ type Resource_Ref_Keys_Of
7
+ } from "@k8ts/instruments"
2
8
  import { Meta } from "@k8ts/metadata"
3
9
  import { CDK } from "@k8ts/sample-interfaces"
4
10
  import { seq } from "doddle"
5
11
  import { omitBy } from "lodash"
12
+ import type { Env_Value } from "../../env/types"
6
13
  import { v1 } from "../../kinds/default"
7
14
  import { Container, type Container_Props } from "./container"
8
15
  import { Pod_Device, type Pod_Device_Backend } from "./volume/devices"
9
- import { Pod_Volume, type Pod_Volume_Backend } from "./volume/volumes"
16
+ import {
17
+ Pod_Volume,
18
+ Pod_Volume_ConfigMap,
19
+ Pod_Volume_Pvc,
20
+ Pod_Volume_Secret,
21
+ type Pod_Volume_Backend,
22
+ type Pod_Volume_Backend_ConfigMap,
23
+ type Pod_Volume_Backend_Pvc,
24
+ type Pod_Volume_Backend_Secret
25
+ } from "./volume/volumes"
10
26
  export type Pod_Props_Original = Omit<CDK.PodSpec, "containers" | "initContainers" | "volumes">
11
- type Container_Ref<Ports extends string> = Resource_Min_Ref<v1.Pod.Container._> & {
27
+ type Container_Ref<Ports extends string> = Resource_Ref_Min<v1.Pod.Container._> & {
12
28
  __PORTS__: Ports
13
29
  }
14
30
  export type Pod_Container_Producer<Ports extends string> = (
@@ -80,14 +96,46 @@ export class Pod_Template<Ports extends string = string> extends Resource_Child<
80
96
 
81
97
  export class PodScope {
82
98
  constructor(private readonly _parent: Pod_Template) {}
83
- Container<Ports extends string>(name: string, options: Container_Props<Ports>) {
99
+ Container<
100
+ Ports extends string,
101
+ Env extends {
102
+ [key in keyof Env]:
103
+ | {
104
+ $backend: Ref2_Of
105
+ key: Env[key] extends object
106
+ ? Resource_Ref_Keys_Of<Env[key]["$backend"], string>
107
+ : never
108
+ }
109
+ | Env_Value
110
+ }
111
+ >(name: string, options: Container_Props<Ports, Env>) {
84
112
  return new Container(this._parent, name, "main", options)
85
113
  }
86
114
  InitContainer(name: string, options: Container_Props<never>) {
87
115
  return new Container(this._parent, name, "init", options)
88
116
  }
89
- Volume(name: string, options: Pod_Volume_Backend) {
90
- return Pod_Volume.make(this._parent, name, options)
117
+ Volume<Actual extends Ref2_Of<v1.ConfigMap._>>(
118
+ name: string,
119
+ options: Pod_Volume_Backend_ConfigMap<Actual>
120
+ ): Pod_Volume
121
+ Volume<Actual extends Ref2_Of<v1.Secret._>>(
122
+ name: string,
123
+ options: Pod_Volume_Backend_Secret<Actual>
124
+ ): Pod_Volume
125
+ Volume<Actual extends Ref2_Of<v1.PersistentVolumeClaim._>>(
126
+ name: string,
127
+ options: Pod_Volume_Backend_Pvc<Actual>
128
+ ): Pod_Volume
129
+ Volume(name: string, options: Pod_Volume_Backend): Pod_Volume {
130
+ const backend = options.$backend as any as Resource_Entity
131
+ if (backend.is(v1.ConfigMap._)) {
132
+ return new Pod_Volume_ConfigMap(this._parent, name, options as any)
133
+ } else if (backend.is(v1.Secret._)) {
134
+ return new Pod_Volume_Secret(this._parent, name, options as any)
135
+ } else if (backend.is(v1.PersistentVolumeClaim._)) {
136
+ return new Pod_Volume_Pvc(this._parent, name, options as any)
137
+ }
138
+ throw new Error(`Unsupported volume backend kind: ${backend.kind}`)
91
139
  }
92
140
  Device(name: string, options: Pod_Device_Backend) {
93
141
  return new Pod_Device(this._parent, name, options)
@@ -23,7 +23,10 @@ export class Pod_Device extends Resource_Child<Pod_Device_Backend_Pvc> {
23
23
  ) {
24
24
  super(parent, name, backend)
25
25
  }
26
-
26
+ get sourceNamespace() {
27
+ const backend = this.props.$backend as any as Resource_Entity
28
+ return backend.namespace
29
+ }
27
30
  protected __needs__(): Record<string, Resource_Entity | Resource_Entity[] | undefined> {
28
31
  return {
29
32
  backend: this.backend.$backend
@@ -1,62 +1,63 @@
1
1
  import type { CDK } from "@k8ts/sample-interfaces"
2
2
 
3
- import type { Resource_Entity } from "@k8ts/instruments"
3
+ import type {
4
+ Ref2_Of,
5
+ Resource_Entity,
6
+ Resource_Ref_Keys_Of,
7
+ Resource_Ref_Min
8
+ } from "@k8ts/instruments"
4
9
  import { Resource_Child } from "@k8ts/instruments"
5
10
  import { v1 } from "../../../kinds/default"
6
- import type { ConfigMap } from "../../configmap"
7
- import { Pvc, type Pv_VolumeMode } from "../../persistent"
8
- import type { Secret } from "../../secret"
9
11
  import { Container_Mount_Volume, type Container_Mount_Props } from "../container/mounts"
10
12
 
11
- interface Pod_Volume_Backend_Pvc<Mode extends Pv_VolumeMode = Pv_VolumeMode> {
12
- $backend: Pvc<Mode>
13
+ export interface Pod_Volume_Backend_Pvc<
14
+ A extends Ref2_Of<v1.PersistentVolumeClaim._> = Ref2_Of<v1.PersistentVolumeClaim._>
15
+ > {
16
+ $backend: A
13
17
  readOnly?: boolean
14
18
  }
15
19
 
16
- interface Pod_Volume_Backend_ConfigMap {
17
- $backend: ConfigMap
20
+ const allowedVolumeResourceKinds = [v1.ConfigMap._, v1.Secret._] as const
21
+ type VolumeResourceKind = (typeof allowedVolumeResourceKinds)[number]
22
+ export type AllowedResources = Resource_Ref_Min<VolumeResourceKind>
23
+ export interface Pod_Volume_Backend_ConfigMap<
24
+ A extends Ref2_Of<v1.ConfigMap._> = Ref2_Of<v1.ConfigMap._>
25
+ > {
26
+ $backend: A
27
+ optional?: boolean
28
+ mappings?: {
29
+ [K in Resource_Ref_Keys_Of<A>]?: string
30
+ }
18
31
  }
19
- interface Pod_Volume_Backend_Secret {
20
- $backend: Secret
32
+
33
+ export interface Pod_Volume_Backend_Secret<A extends Ref2_Of<v1.Secret._> = Ref2_Of<v1.Secret._>> {
34
+ $backend: A
35
+ optional?: boolean
36
+ mappings?: {
37
+ [K in Resource_Ref_Keys_Of<A>]?: string
38
+ }
21
39
  }
22
- export type Pod_Volume_Backend<Mode extends Pv_VolumeMode = Pv_VolumeMode> =
23
- | Pod_Volume_Backend_Pvc<Mode>
40
+
41
+ export type Pod_Volume_Backend =
42
+ | Pod_Volume_Backend_Pvc
24
43
  | Pod_Volume_Backend_ConfigMap
25
44
  | Pod_Volume_Backend_Secret
26
45
 
27
46
  export abstract class Pod_Volume<
28
- Props extends Pod_Volume_Backend = Pod_Volume_Backend
29
- > extends Resource_Child<Props> {
47
+ P extends Pod_Volume_Backend = Pod_Volume_Backend
48
+ > extends Resource_Child<P> {
30
49
  get kind() {
31
50
  return v1.Pod.Volume._
32
51
  }
33
52
 
34
- static make<Mode extends Pv_VolumeMode>(
35
- parent: Resource_Entity,
36
- name: string,
37
- backend: Pod_Volume_Backend<Mode>
38
- ): Pod_Volume<Pod_Volume_Backend<Mode>> {
39
- switch (backend.$backend.kind.name) {
40
- case "PersistentVolumeClaim":
41
- return new Pod_Volume_Pvc<Mode>(
42
- parent,
43
- name,
44
- backend as Pod_Volume_Backend_Pvc<Mode>
45
- )
46
- case "ConfigMap":
47
- return new Pod_Volume_ConfigMap(
48
- parent,
49
- name,
50
- backend as Pod_Volume_Backend_ConfigMap
51
- )
52
- case "Secret":
53
- return new Pod_Volume_Secret(parent, name, backend as Pod_Volume_Backend_Secret)
54
- }
53
+ get sourceNamespace() {
54
+ const backend = this.props.$backend as any as Resource_Entity
55
+ return backend.namespace
55
56
  }
56
57
 
57
58
  protected __needs__(): Record<string, Resource_Entity | Resource_Entity[] | undefined> {
58
59
  return {
59
- backend: this.props.$backend
60
+ backend: this.props.$backend as any
60
61
  }
61
62
  }
62
63
  Mount(options?: Omit<Container_Mount_Props, "volume">) {
@@ -69,7 +70,7 @@ export abstract class Pod_Volume<
69
70
  protected abstract __submanifest__(): CDK.Volume
70
71
  }
71
72
 
72
- class Pod_Volume_Pvc<Mode extends Pv_VolumeMode> extends Pod_Volume<Pod_Volume_Backend_Pvc<Mode>> {
73
+ export class Pod_Volume_Pvc extends Pod_Volume<Pod_Volume_Backend_Pvc> {
73
74
  protected __submanifest__(): CDK.Volume {
74
75
  return {
75
76
  name: this.name,
@@ -81,36 +82,48 @@ class Pod_Volume_Pvc<Mode extends Pv_VolumeMode> extends Pod_Volume<Pod_Volume_B
81
82
  }
82
83
  }
83
84
 
84
- class Pod_Volume_ConfigMap extends Pod_Volume<Pod_Volume_Backend_ConfigMap> {
85
+ function mappingsToKeyPaths(input: Record<string, string>) {
86
+ const mappings = input
87
+ const arr = Object.entries(mappings).map(([key, value]) => {
88
+ return {
89
+ key: key,
90
+ path: value
91
+ } satisfies CDK.KeyToPath
92
+ })
93
+ if (arr.length === 0) {
94
+ return undefined
95
+ }
96
+ return arr
97
+ }
98
+
99
+ export class Pod_Volume_ConfigMap extends Pod_Volume<Pod_Volume_Backend_ConfigMap> {
85
100
  protected __submanifest__(): CDK.Volume {
101
+ const mappings = mappingsToKeyPaths(this.props.mappings ?? {})
102
+
86
103
  return {
87
104
  name: this.name,
88
105
  configMap: {
89
- name: this.props.$backend.name
106
+ name: this.props.$backend.name,
107
+ optional: this.props.optional,
108
+ items: mappings
90
109
  }
91
110
  }
92
111
  }
93
112
  }
94
113
 
95
- class Pod_Volume_Secret extends Pod_Volume<Pod_Volume_Backend_Secret> {
114
+ export class Pod_Volume_Secret<
115
+ Source extends Ref2_Of<v1.Secret._>
116
+ > extends Pod_Volume<Pod_Volume_Backend_Secret> {
96
117
  protected __submanifest__(): CDK.Volume {
118
+ const mappings = mappingsToKeyPaths(this.props.mappings ?? {})
119
+
97
120
  return {
98
121
  name: this.name,
99
122
  secret: {
100
- secretName: this.props.$backend.name
123
+ secretName: this.props.$backend.name,
124
+ optional: this.props.optional,
125
+ items: mappings
101
126
  }
102
127
  }
103
128
  }
104
129
  }
105
-
106
- export function make(parent: Resource_Entity, name: string, input: Pod_Volume_Backend): Pod_Volume {
107
- const { $backend } = input
108
- switch ($backend.kind.name) {
109
- case "PersistentVolumeClaim":
110
- return new Pod_Volume_Pvc(parent, name, input as Pod_Volume_Backend_Pvc)
111
- case "ConfigMap":
112
- return new Pod_Volume_ConfigMap(parent, name, input as Pod_Volume_Backend_ConfigMap)
113
- case "Secret":
114
- return new Pod_Volume_Secret(parent, name, input as Pod_Volume_Backend_Secret)
115
- }
116
- }
@@ -13,7 +13,7 @@ export type ClusterRole_RuleProducer<Rules extends ClusterRole_Rule> = (
13
13
  scope: ClusterRole_Scope
14
14
  ) => Iterable<Rules>
15
15
  class ClusterRole_Scope {
16
- Resources<const R extends Kind[]>(...resources: R) {
16
+ Rule<const R extends Kind[]>(...resources: R) {
17
17
  return {
18
18
  verbs(...verbs: Verbs[]) {
19
19
  return {
@@ -0,0 +1,3 @@
1
+ export * from "./cluster-role"
2
+ export * from "./cluster-role-binding"
3
+ export * from "./service-account"
@@ -1,4 +1,4 @@
1
- import { Resource_Core_Ref, Resource_Top, type InputPortMapping } from "@k8ts/instruments"
1
+ import { Ref2_Of, Resource_Top, type InputPortMapping } from "@k8ts/instruments"
2
2
  import { CDK } from "@k8ts/sample-interfaces"
3
3
  import { seq } from "doddle"
4
4
  import { MakeError } from "../../error"
@@ -20,7 +20,7 @@ export interface Service_Props<DeployPorts extends string, ExposedPorts extends
20
20
  $backend: Deployment_Ref<DeployPorts>
21
21
  $frontend: Service_Frontend
22
22
  }
23
- export interface Service_Ref<ExposedPorts extends string> extends Resource_Core_Ref<v1.Service._> {
23
+ export interface Service_Ref<ExposedPorts extends string> extends Ref2_Of<v1.Service._> {
24
24
  __PORTS__: ExposedPorts
25
25
  }
26
26
 
@@ -60,6 +60,7 @@ export class Assembler extends Emittery<AssemblerEventsTable> {
60
60
  .collect()
61
61
  .map(async ({ file, resources }) => {
62
62
  const manifests = await aseq(resources)
63
+ .filter(x => !x.disabled)
63
64
  .map(async resource => {
64
65
  return await generator.generate(resource)
65
66
  })
@@ -25,6 +25,9 @@ export class ResourceLoader extends Emittery<ResourceLoaderEventsTable> {
25
25
  )
26
26
  }
27
27
  names.set(name, resource)
28
+ const resourceOriginMetas = resource.origin.inheritedMeta
29
+
30
+ resource.meta!.add(resourceOriginMetas)
28
31
  }
29
32
  }
30
33
 
@@ -58,9 +58,6 @@ export class Manifester extends Emittery<ManifesterEventsTable> {
58
58
  "^constructed-at": loc,
59
59
  "^produced-by": `k8ts@${version}`
60
60
  })
61
- const resourceOriginMetas = resource.origin.inheritedMeta
62
-
63
- resource.meta!.add(resourceOriginMetas)
64
61
  }
65
62
 
66
63
  async generate(res: Resource_Node): Promise<NodeManifest> {
@@ -1,5 +0,0 @@
1
- import type { Resource_Core_Ref } from "@k8ts/instruments";
2
- import type { AnyCtor } from "what-are-you";
3
- import { World } from "./origins";
4
- export declare function K8ts<MoreKinds extends AnyCtor<Resource_Core_Ref>>(...extraKinds: MoreKinds[]): World<import("@k8ts/instruments").Resource_Ctor_Of[]>;
5
- //# sourceMappingURL=default-world.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default-world.d.ts","sourceRoot":"","sources":["../src/default-world.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AA2DjC,wBAAgB,IAAI,CAAC,SAAS,SAAS,OAAO,CAAC,iBAAiB,CAAC,EAAE,GAAG,UAAU,EAAE,SAAS,EAAE,yDAI5F"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"default-world.js","sourceRoot":"","sources":["../src/default-world.ts"],"names":[],"mappings":";;AA6DA,oBAIC;AA/DD,uCAAiC;AACjC,2CAYoB;AAEpB,yBAAyB;AACzB,oBAAoB;AACpB,sBAAsB;AACtB,mBAAmB;AACnB,6BAA6B;AAC7B,kCAAkC;AAClC,sBAAsB;AACtB,2BAA2B;AAC3B,4BAA4B;AAC5B,+BAA+B;AAC/B,6BAA6B;AAC7B,8BAA8B;AAC9B,sCAAsC;AACtC,iCAAiC;AACjC,uCAAuC;AACvC,0BAA0B;AAC1B,sBAAsB;AACtB,4BAA4B;AAC5B,mCAAmC;AACnC,8BAA8B;AAC9B,gCAAgC;AAChC,gCAAgC;AAChC,wCAAwC;AACxC,uCAAuC;AACvC,wBAAwB;AACxB,+BAA+B;AAC/B,6BAA6B;AAC7B,mCAAmC;AACnC,sCAAsC;AACtC,aAAa;AAEb,MAAM,gBAAgB,GAAG;IACrB,mBAAO;IACP,sBAAU;IACV,qBAAS;IACT,kBAAM;IACN,cAAE;IACF,eAAG;IACH,qBAAS;IACT,mBAAO;IACP,0BAAc;IACd,uBAAW;IACX,8BAAkB;CACZ,CAAA;AACV,SAAgB,IAAI,CAA+C,GAAG,UAAuB;IACzF,OAAO,IAAI,eAAK,CAAC,MAAM,EAAE;QACrB,KAAK,EAAE,CAAC,GAAG,gBAAgB,CAAC;KAC/B,CAAC,CAAA;AACN,CAAC"}
@@ -1,8 +0,0 @@
1
- import { Origin_Entity, type Origin_Props, type Resource_Ctor_Of } from "@k8ts/instruments";
2
- export declare class Origin_External extends Origin_Entity {
3
- readonly _parent: Origin_Entity;
4
- get kind(): string;
5
- constructor(_parent: Origin_Entity);
6
- protected __parent__(): Origin_Entity<Origin_Props<Resource_Ctor_Of>> | undefined;
7
- }
8
- //# sourceMappingURL=external.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/origins/external.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAE3F,qBAAa,eAAgB,SAAQ,aAAa;IAIlC,QAAQ,CAAC,OAAO,EAAE,aAAa;IAH3C,IAAI,IAAI,WAEP;gBACoB,OAAO,EAAE,aAAa;IAI3C,SAAS,CAAC,UAAU,IAAI,aAAa,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,GAAG,SAAS;CAGpF"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Origin_External = void 0;
4
- const instruments_1 = require("@k8ts/instruments");
5
- class Origin_External extends instruments_1.Origin_Entity {
6
- _parent;
7
- get kind() {
8
- return "External";
9
- }
10
- constructor(_parent) {
11
- super("External", {});
12
- this._parent = _parent;
13
- }
14
- __parent__() {
15
- return this._parent;
16
- }
17
- }
18
- exports.Origin_External = Origin_External;
19
- //# sourceMappingURL=external.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"external.js","sourceRoot":"","sources":["../../src/origins/external.ts"],"names":[],"mappings":";;;AAAA,mDAA2F;AAE3F,MAAa,eAAgB,SAAQ,2BAAa;IAIzB;IAHrB,IAAI,IAAI;QACJ,OAAO,UAAU,CAAA;IACrB,CAAC;IACD,YAAqB,OAAsB;QACvC,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;QADJ,YAAO,GAAP,OAAO,CAAe;IAE3C,CAAC;IAES,UAAU;QAChB,OAAO,IAAI,CAAC,OAAO,CAAA;IACvB,CAAC;CACJ;AAXD,0CAWC"}
@@ -1,12 +0,0 @@
1
- import { DataSourceRecord_Binary, DataSourceRecord_Text, DataSource_LocalFile, Resource_Top } from "@k8ts/instruments";
2
- import { CDK } from "@k8ts/sample-interfaces";
3
- export type ConfigMap_Entry_Source = DataSource_LocalFile | string;
4
- export interface ConfigMap_Props {
5
- data: DataSourceRecord_Text;
6
- binaryData?: DataSourceRecord_Binary;
7
- }
8
- export declare class ConfigMap<Name extends string = string> extends Resource_Top<Name, ConfigMap_Props> {
9
- get kind(): import("@k8ts/instruments").Kind.Kind<"", "v1", "ConfigMap">;
10
- protected body(): Promise<CDK.KubeConfigMapProps>;
11
- }
12
- //# sourceMappingURL=configmap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configmap.d.ts","sourceRoot":"","sources":["../../../src/resources/configmap/configmap.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EAGf,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAG7C,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,GAAG,MAAM,CAAA;AAClE,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,qBAAqB,CAAA;IAC3B,UAAU,CAAC,EAAE,uBAAuB,CAAA;CACvC;AAED,qBAAa,SAAS,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,YAAY,CAAC,IAAI,EAAE,eAAe,CAAC;IAC5F,IAAI,IAAI,iEAEP;cACe,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;CAa1D"}
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigMap = void 0;
4
- const instruments_1 = require("@k8ts/instruments");
5
- const util_1 = require("@k8ts/metadata/util");
6
- const doddle_1 = require("doddle");
7
- const default_1 = require("../../kinds/default");
8
- class ConfigMap extends instruments_1.Resource_Top {
9
- get kind() {
10
- return default_1.v1.ConfigMap._;
11
- }
12
- async body() {
13
- const self = this;
14
- const binaryData = await (0, instruments_1.resolveBinary)(self.props.binaryData ?? {});
15
- const data = await (0, instruments_1.resolveText)(self.props.data);
16
- const encodedBinaryData = (0, doddle_1.seq)(binaryData)
17
- .map(([k, x]) => [k, Buffer.from(x).toString("base64")])
18
- .toRecord(x => x)
19
- .pull();
20
- return {
21
- data: data.size === 0 ? undefined : (0, util_1.toObject)(data),
22
- binaryData: binaryData.size === 0 ? undefined : encodedBinaryData
23
- };
24
- }
25
- }
26
- exports.ConfigMap = ConfigMap;
27
- //# sourceMappingURL=configmap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configmap.js","sourceRoot":"","sources":["../../../src/resources/configmap/configmap.ts"],"names":[],"mappings":";;;AAAA,mDAO0B;AAC1B,8CAA8C;AAE9C,mCAA4B;AAC5B,iDAAwC;AAOxC,MAAa,SAAwC,SAAQ,0BAAmC;IAC5F,IAAI,IAAI;QACJ,OAAO,YAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IACzB,CAAC;IACS,KAAK,CAAC,IAAI;QAChB,MAAM,IAAI,GAAG,IAAI,CAAA;QACjB,MAAM,UAAU,GAAG,MAAM,IAAA,2BAAa,EAAC,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC,CAAA;QACnE,MAAM,IAAI,GAAG,MAAM,IAAA,yBAAW,EAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC/C,MAAM,iBAAiB,GAAG,IAAA,YAAG,EAAC,UAAU,CAAC;aACpC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAU,CAAC;aAChE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aAChB,IAAI,EAAE,CAAA;QACX,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC;YAClD,UAAU,EAAE,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB;SACpE,CAAA;IACL,CAAC;CACJ;AAjBD,8BAiBC"}
@@ -1,2 +0,0 @@
1
- export * from "./configmap";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/resources/configmap/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/configmap/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B"}
@@ -1,19 +0,0 @@
1
- import { Kind, Resource_Entity, type Origin_Entity, type RefKey } from "@k8ts/instruments";
2
- import { Meta } from "@k8ts/metadata";
3
- export declare class External<K extends Kind.IdentParent = Kind.IdentParent, Name extends string = string> extends Resource_Entity<Name> {
4
- private readonly _origin;
5
- readonly key: RefKey<K, Name>;
6
- meta: Meta.Meta;
7
- constructor(_origin: Origin_Entity, key: RefKey<K, Name>, namespace?: string | undefined);
8
- get namespace(): string | undefined;
9
- get kind(): K;
10
- protected __origin__(): Origin_Entity;
11
- protected __parent__(): undefined;
12
- protected body(): never;
13
- ref(): {
14
- kind: string;
15
- name: Name;
16
- namespace: string | undefined;
17
- };
18
- }
19
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/resources/external/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1F,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAGrC,qBAAa,QAAQ,CACjB,CAAC,SAAS,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,EAC7C,IAAI,SAAS,MAAM,GAAG,MAAM,CAC9B,SAAQ,eAAe,CAAC,IAAI,CAAC;IAGvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC;IAHjC,IAAI,YAAc;gBAEG,OAAO,EAAE,aAAa,EAC9B,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,EAC7B,SAAS,GAAE,MAAM,GAAG,SAAqB;IAS7C,IAAI,SAAS,uBAEZ;IAED,IAAI,IAAI,MAEP;IAED,SAAS,CAAC,UAAU,IAAI,aAAa;IAIrC,SAAS,CAAC,UAAU;IAIpB,SAAS,CAAC,IAAI,IAAI,KAAK;IAIvB,GAAG;;;;;CAON"}
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.External = void 0;
4
- const instruments_1 = require("@k8ts/instruments");
5
- const metadata_1 = require("@k8ts/metadata");
6
- const error_1 = require("../../error");
7
- class External extends instruments_1.Resource_Entity {
8
- _origin;
9
- key;
10
- meta = metadata_1.Meta.make();
11
- constructor(_origin, key, namespace = undefined) {
12
- super(key.name, {});
13
- this._origin = _origin;
14
- this.key = key;
15
- this.meta.overwrite("name", key.name);
16
- if (namespace) {
17
- this.meta.overwrite("namespace", namespace);
18
- }
19
- }
20
- get namespace() {
21
- return this.meta.tryGet("namespace");
22
- }
23
- get kind() {
24
- return this.key.kind;
25
- }
26
- __origin__() {
27
- return this._origin;
28
- }
29
- __parent__() {
30
- return undefined;
31
- }
32
- body() {
33
- throw new error_1.MakeError("Cannot get body of External resource");
34
- }
35
- ref() {
36
- return {
37
- kind: this.kind.name,
38
- name: this.name,
39
- namespace: this.namespace
40
- };
41
- }
42
- }
43
- exports.External = External;
44
- //# sourceMappingURL=index.js.map