k8ts 0.4.20 → 0.4.22
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/factory.d.ts +1 -2
- package/dist/file/factory.d.ts.map +1 -1
- package/dist/file/factory.js +6 -4
- package/dist/file/factory.js.map +1 -1
- package/dist/resources/deployment/deployment.d.ts +10 -3
- package/dist/resources/deployment/deployment.d.ts.map +1 -1
- package/dist/resources/deployment/deployment.js +19 -1
- package/dist/resources/deployment/deployment.js.map +1 -1
- package/dist/resources/pod/container/container.d.ts +2 -2
- package/dist/resources/pod/container/container.d.ts.map +1 -1
- package/dist/resources/pod/container/container.js.map +1 -1
- package/dist/resources/pod/pod-template.d.ts +10 -0
- package/dist/resources/pod/pod-template.d.ts.map +1 -1
- package/dist/resources/pod/pod-template.js.map +1 -1
- package/dist/resources/utils/adapters.d.ts.map +1 -1
- package/dist/resources/utils/adapters.js +3 -1
- package/dist/resources/utils/adapters.js.map +1 -1
- package/dist/runner/exporter/assembler.d.ts +2 -2
- package/dist/runner/exporter/assembler.d.ts.map +1 -1
- package/dist/runner/exporter/assembler.js.map +1 -1
- package/dist/runner/exporter/serializer.d.ts +4 -3
- package/dist/runner/exporter/serializer.d.ts.map +1 -1
- package/dist/runner/exporter/serializer.js +4 -1
- package/dist/runner/exporter/serializer.js.map +1 -1
- package/dist/runner/runner.d.ts +3 -2
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +6 -1
- package/dist/runner/runner.js.map +1 -1
- package/dist/src.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/src/file/factory.ts +25 -19
- package/src/resources/deployment/deployment.ts +31 -4
- package/src/resources/pod/container/container.ts +3 -1
- package/src/resources/pod/pod-template.ts +10 -0
- package/src/resources/utils/adapters.ts +3 -1
- package/src/runner/exporter/assembler.ts +2 -2
- package/src/runner/exporter/serializer.ts +8 -4
- package/src/runner/runner.ts +15 -3
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { manifest, Origin, Refable, relations } from "@k8ts/instruments"
|
|
1
|
+
import { manifest, Origin, Refable, relations, WritableDeep } 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 { MakeError } from "../../error"
|
|
5
6
|
import { k8ts } from "../../kind-map"
|
|
6
7
|
import { api } from "../../kinds"
|
|
7
8
|
import { equiv_cdk8s } from "../../node/equiv-cdk8s"
|
|
@@ -10,13 +11,22 @@ import { PodTemplate } from "../pod/pod-template"
|
|
|
10
11
|
|
|
11
12
|
export type Deployment<Ports extends string> = Deployment.Deployment<Ports>
|
|
12
13
|
export namespace Deployment {
|
|
13
|
-
export type
|
|
14
|
-
|
|
14
|
+
export type DeploymentStrategy =
|
|
15
|
+
| { type: "Recreate" }
|
|
16
|
+
| ({
|
|
17
|
+
type: "RollingUpdate"
|
|
18
|
+
} & CDK.RollingUpdateDeployment)
|
|
19
|
+
export type NormalProps = WritableDeep<
|
|
20
|
+
Omit<CDK.DeploymentSpec, "selector" | "template" | "strategy">
|
|
21
|
+
>
|
|
22
|
+
export type Props<Ports extends string> = NormalProps & {
|
|
15
23
|
template: PodTemplate.Props<Ports>
|
|
24
|
+
strategy?: DeploymentStrategy
|
|
16
25
|
}
|
|
17
26
|
export type AbsDeployment<Ports extends string> = Refable<api.apps_.v1_.Deployment> & {
|
|
18
27
|
__PORTS__: Ports
|
|
19
28
|
}
|
|
29
|
+
|
|
20
30
|
@k8ts(api.apps_.v1_.Deployment)
|
|
21
31
|
@equiv_cdk8s(CDK.KubeDeployment)
|
|
22
32
|
@relations({
|
|
@@ -34,7 +44,8 @@ export namespace Deployment {
|
|
|
34
44
|
app: self.name
|
|
35
45
|
}
|
|
36
46
|
},
|
|
37
|
-
template: noKindFields
|
|
47
|
+
template: noKindFields,
|
|
48
|
+
strategy: self._strategy
|
|
38
49
|
}
|
|
39
50
|
}
|
|
40
51
|
}
|
|
@@ -44,6 +55,22 @@ export namespace Deployment {
|
|
|
44
55
|
kind = api.apps_.v1_.Deployment
|
|
45
56
|
template: PodTemplate<Ports>
|
|
46
57
|
|
|
58
|
+
private get _strategy() {
|
|
59
|
+
const strat = this.props.strategy
|
|
60
|
+
if (!strat) {
|
|
61
|
+
return undefined
|
|
62
|
+
}
|
|
63
|
+
if (strat.type === "Recreate") {
|
|
64
|
+
return strat
|
|
65
|
+
}
|
|
66
|
+
if (strat.type === "RollingUpdate") {
|
|
67
|
+
return {
|
|
68
|
+
type: "RollingUpdate",
|
|
69
|
+
rollingUpdate: omit(strat, "type")
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw new MakeError(`Invalid strategy type: ${strat}`)
|
|
73
|
+
}
|
|
47
74
|
constructor(origin: Origin, meta: Meta | MutableMeta, props: Props<Ports>) {
|
|
48
75
|
super(origin, meta, props)
|
|
49
76
|
this.template = new PodTemplate.PodTemplate(
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
relations,
|
|
6
6
|
ResourcesSpec,
|
|
7
7
|
Unit,
|
|
8
|
+
WritableDeep,
|
|
8
9
|
type CmdBuilder,
|
|
9
10
|
type InputEnvMapping,
|
|
10
11
|
type InputPortSetRecord,
|
|
@@ -34,6 +35,7 @@ export namespace Container {
|
|
|
34
35
|
export type Mounts = {
|
|
35
36
|
[key: string]: SomeMount
|
|
36
37
|
}
|
|
38
|
+
|
|
37
39
|
export interface K8tsProps<Ports extends string = never> {
|
|
38
40
|
image: TaggedImage
|
|
39
41
|
ports?: InputPortSetRecord<Ports>
|
|
@@ -44,7 +46,7 @@ export namespace Container {
|
|
|
44
46
|
resources?: Resources
|
|
45
47
|
}
|
|
46
48
|
export type Props<Ports extends string = never> = K8tsProps<Ports> &
|
|
47
|
-
Omit<CDK.Container, keyof K8tsProps | "name"
|
|
49
|
+
WritableDeep<Omit<CDK.Container, keyof K8tsProps | "name">>
|
|
48
50
|
|
|
49
51
|
@k8ts(api.v1_.Pod_.Container)
|
|
50
52
|
@relations({
|
|
@@ -17,6 +17,16 @@ export namespace PodTemplate {
|
|
|
17
17
|
export type Props<Ports extends string> = PodProps & {
|
|
18
18
|
POD: PodContainerProducer<Ports>
|
|
19
19
|
}
|
|
20
|
+
export type HostPortSpec<Ports extends string> = {
|
|
21
|
+
[port in Ports]?: {
|
|
22
|
+
ip?: string
|
|
23
|
+
port?: number
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export interface HostNetInput<Ports extends string> {
|
|
27
|
+
hostNetwork?: boolean
|
|
28
|
+
ports: HostPortSpec<Ports>
|
|
29
|
+
}
|
|
20
30
|
@k8ts(api.v1_.PodTemplate)
|
|
21
31
|
@relations({
|
|
22
32
|
kids: s => [...s.containers, ...s.volumes]
|
|
@@ -7,7 +7,7 @@ import type { File } from "../../file"
|
|
|
7
7
|
import { ResourceLoader, type ResourceLoaderEventsTable } from "./loader"
|
|
8
8
|
import { Manifester, NodeManifest, type ManifesterEventsTable } from "./manifester"
|
|
9
9
|
import { ManifestSaver, type ManifestSaverEventsTable } from "./saver"
|
|
10
|
-
import { YamlSerializer, type
|
|
10
|
+
import { YamlSerializer, type SerializerEventsTable } from "./serializer"
|
|
11
11
|
import { NodeGraphValidator, ValidatorEventsTable } from "./validator"
|
|
12
12
|
|
|
13
13
|
export class Assembler extends Emittery<AssemblerEventsTable> {
|
|
@@ -166,7 +166,7 @@ export type AssemblyStage =
|
|
|
166
166
|
| "gathering"
|
|
167
167
|
export interface AssemblerEventsTable
|
|
168
168
|
extends ManifestSaverEventsTable,
|
|
169
|
-
|
|
169
|
+
SerializerEventsTable,
|
|
170
170
|
ManifesterEventsTable,
|
|
171
171
|
ResourceLoaderEventsTable,
|
|
172
172
|
ValidatorEventsTable {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseManifest, ManifestSourceEmbedder } from "@k8ts/instruments"
|
|
1
|
+
import { BaseManifest, ManifestSourceEmbedder, type ResourceNode } from "@k8ts/instruments"
|
|
2
2
|
import Emittery from "emittery"
|
|
3
3
|
import { dump, type DumpOptions } from "js-yaml"
|
|
4
4
|
import { CDK } from "../../_imports"
|
|
@@ -9,17 +9,21 @@ export interface YamlSerializerOptions {
|
|
|
9
9
|
}
|
|
10
10
|
export interface SerializingEvent {
|
|
11
11
|
manifest: BaseManifest
|
|
12
|
+
resource: ResourceNode
|
|
12
13
|
}
|
|
13
|
-
export interface
|
|
14
|
+
export interface SerializerEventsTable {
|
|
14
15
|
serialize: SerializingEvent
|
|
15
16
|
}
|
|
16
|
-
export class YamlSerializer extends Emittery<
|
|
17
|
+
export class YamlSerializer extends Emittery<SerializerEventsTable> {
|
|
17
18
|
constructor(private readonly _options: Partial<YamlSerializerOptions>) {
|
|
18
19
|
super()
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
async serialize(input: BaseManifest) {
|
|
22
|
-
await this.emit("serialize", {
|
|
23
|
+
await this.emit("serialize", {
|
|
24
|
+
manifest: input,
|
|
25
|
+
resource: ManifestSourceEmbedder.get(input).node
|
|
26
|
+
})
|
|
23
27
|
|
|
24
28
|
try {
|
|
25
29
|
const result = dump(input, {
|
package/src/runner/runner.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { GitTrace, Trace } from "@k8ts/instruments"
|
|
2
2
|
import { Meta } from "@k8ts/metadata"
|
|
3
3
|
import chalk from "chalk"
|
|
4
|
+
import Emittery from "emittery"
|
|
4
5
|
import StackTracey from "stacktracey"
|
|
5
6
|
import { File } from "../file"
|
|
6
7
|
import { proverbsPath } from "../paths"
|
|
7
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
Assembler,
|
|
10
|
+
AssemblerEventsTable,
|
|
11
|
+
AssemblerOptions,
|
|
12
|
+
ProgressOptions,
|
|
13
|
+
ProgressShower
|
|
14
|
+
} from "./exporter"
|
|
8
15
|
import { k8ts_namespace } from "./exporter/meta"
|
|
9
16
|
import { Proverbs } from "./silly/proverbs"
|
|
10
17
|
import { Summarizer } from "./summarizer"
|
|
@@ -15,8 +22,10 @@ export interface RunnerOptions extends AssemblerOptions {
|
|
|
15
22
|
progress: ProgressOptions
|
|
16
23
|
}
|
|
17
24
|
|
|
18
|
-
export class Runner {
|
|
19
|
-
constructor(private readonly _options: RunnerOptions) {
|
|
25
|
+
export class Runner extends Emittery<AssemblerEventsTable> {
|
|
26
|
+
constructor(private readonly _options: RunnerOptions) {
|
|
27
|
+
super()
|
|
28
|
+
}
|
|
20
29
|
|
|
21
30
|
async run(input: Iterable<File.Input>) {
|
|
22
31
|
const gitInfo = await GitTrace.make({
|
|
@@ -36,6 +45,9 @@ export class Runner {
|
|
|
36
45
|
|
|
37
46
|
const progressShower = new ProgressShower(options.progress)
|
|
38
47
|
const assembler = new Assembler(options)
|
|
48
|
+
assembler.onAny(async (name, data) => {
|
|
49
|
+
await this.emit(name, data)
|
|
50
|
+
})
|
|
39
51
|
const summarizer = new Summarizer({
|
|
40
52
|
printOptions: this._options.printOptions
|
|
41
53
|
})
|