@toa.io/operations 1.0.0-alpha.31 → 1.0.0-alpha.310
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/CHANGELOG.md +213 -0
- package/image/runtime.Dockerfile +14 -0
- package/package.json +10 -10
- package/readme.md +201 -0
- package/src/deployment/.deployment/.describe/components.js +1 -5
- package/src/deployment/.deployment/.describe/compositions.js +26 -7
- package/src/deployment/.deployment/.describe/dependencies.js +1 -6
- package/src/deployment/.deployment/.describe/events.js +63 -0
- package/src/deployment/.deployment/.describe/fold.js +42 -0
- package/src/deployment/.deployment/.describe/fold.test.js +108 -0
- package/src/deployment/.deployment/.describe/index.js +4 -13
- package/src/deployment/.deployment/.describe/mounts.js +17 -0
- package/src/deployment/.deployment/.describe/resources.js +129 -0
- package/src/deployment/.deployment/.describe/resources.test.js +129 -0
- package/src/deployment/.deployment/.describe/services.js +32 -6
- package/src/deployment/.deployment/.describe/services.test.js +78 -0
- package/src/deployment/.deployment/.describe/variables.js +5 -9
- package/src/deployment/.deployment/declare.js +1 -5
- package/src/deployment/.deployment/describe.js +153 -10
- package/src/deployment/.deployment/index.js +3 -9
- package/src/deployment/.deployment/merge.js +66 -6
- package/src/deployment/.deployment/merge.test.js +133 -0
- package/src/deployment/chart/templates/components.configmap.yaml +14 -0
- package/src/deployment/chart/templates/components.yaml +1 -1
- package/src/deployment/chart/templates/compositions.yaml +109 -4
- package/src/deployment/chart/templates/mono.yaml +195 -0
- package/src/deployment/chart/templates/services.yaml +97 -7
- package/src/deployment/chart/values.yaml +23 -1
- package/src/deployment/composition.js +8 -6
- package/src/deployment/deployment.js +147 -34
- package/src/deployment/drain.js +70 -0
- package/src/deployment/drain.test.js +64 -0
- package/src/deployment/factory.js +169 -37
- package/src/deployment/images/bundle.js +88 -0
- package/src/deployment/images/composition.Dockerfile +9 -17
- package/src/deployment/images/composition.js +9 -56
- package/src/deployment/images/dependencies.Dockerfile +23 -0
- package/src/deployment/images/dependencies.js +171 -0
- package/src/deployment/images/dependencies.test.js +268 -0
- package/src/deployment/images/factory.js +31 -15
- package/src/deployment/images/format.js +66 -0
- package/src/deployment/images/format.test.js +149 -0
- package/src/deployment/images/image.fixtures.js +17 -19
- package/src/deployment/images/image.js +79 -38
- package/src/deployment/images/image.test.js +11 -5
- package/src/deployment/images/index.js +1 -5
- package/src/deployment/images/mono.Dockerfile +11 -0
- package/src/deployment/images/mono.js +15 -0
- package/src/deployment/images/publish.js +91 -0
- package/src/deployment/images/runtime-base.test.js +97 -0
- package/src/deployment/images/service.Dockerfile +17 -5
- package/src/deployment/images/service.js +63 -14
- package/src/deployment/index.js +1 -5
- package/src/deployment/operator.js +22 -16
- package/src/deployment/operator.test.js +57 -7
- package/src/deployment/registry.js +210 -46
- package/src/deployment/registry.test.js +539 -0
- package/src/deployment/service.js +4 -6
- package/src/deployment/workspace.js +13 -8
- package/src/index.js +3 -2
- package/src/process.js +51 -13
- package/src/process.test.js +33 -0
- package/types/_deployment/composition.d.ts +2 -3
- package/types/_deployment/dependency.d.ts +13 -7
- package/types/_deployment/deployment.d.ts +7 -8
- package/types/_deployment/factory.d.ts +2 -4
- package/types/_deployment/images/factory.d.ts +6 -8
- package/types/_deployment/images/image.d.ts +16 -1
- package/types/_deployment/images/registry.d.ts +8 -11
- package/types/_deployment/operator.d.ts +10 -9
- package/types/_deployment/registry.d.ts +7 -4
- package/types/_deployment/service.d.ts +4 -3
- package/types/dependency.ts +79 -0
- package/types/index.ts +1 -0
- package/types/dependency.d.ts +0 -39
- package/types/index.d.ts +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { it, describe } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
|
|
4
|
+
import { Process } from './process.js'
|
|
5
|
+
|
|
6
|
+
describe('execute', () => {
|
|
7
|
+
it('should answer what the command wrote', async () => {
|
|
8
|
+
const output = await new Process().execute(
|
|
9
|
+
'node',
|
|
10
|
+
['-e', 'process.stdout.write("ok")'],
|
|
11
|
+
{ silently: true }
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
assert.strictEqual(output, 'ok')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('should reject what the command failed at, with what it wrote', async () => {
|
|
18
|
+
await assert.rejects(
|
|
19
|
+
new Process().execute(
|
|
20
|
+
'node',
|
|
21
|
+
['-e', 'process.stderr.write("broken"); process.exit(2)'],
|
|
22
|
+
{ silently: true }
|
|
23
|
+
),
|
|
24
|
+
(error) => /exit code 2: node/.test(error.message) && /broken/.test(error.message)
|
|
25
|
+
)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('should reject a command that does not exist', async () => {
|
|
29
|
+
await assert.rejects(
|
|
30
|
+
new Process().execute('toa-no-such-command', [], { silently: true })
|
|
31
|
+
)
|
|
32
|
+
})
|
|
33
|
+
})
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type * as _deployment from './deployment'
|
|
1
|
+
import type * as _deployment from './deployment.d.ts'
|
|
2
2
|
|
|
3
3
|
declare namespace toa.deployment {
|
|
4
|
-
|
|
5
4
|
interface Composition extends _deployment.Deployable {
|
|
6
5
|
components: Array<string>
|
|
6
|
+
replicas?: number
|
|
7
7
|
}
|
|
8
|
-
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
export type Composition = toa.deployment.Composition
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import * as _service from './service'
|
|
1
|
+
import * as _service from './service.d.ts'
|
|
2
2
|
import { dependencies } from '@toa.io/norm/types/context'
|
|
3
3
|
|
|
4
4
|
declare namespace toa.deployment {
|
|
5
|
-
|
|
6
5
|
namespace dependency {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
type Constructor = (
|
|
7
|
+
instances: dependencies.Instance[],
|
|
8
|
+
annotation: any
|
|
9
|
+
) => Declaration
|
|
9
10
|
|
|
10
11
|
type Reference = {
|
|
11
12
|
name: string
|
|
@@ -19,6 +20,11 @@ declare namespace toa.deployment {
|
|
|
19
20
|
group: string
|
|
20
21
|
name: string
|
|
21
22
|
version: string
|
|
23
|
+
|
|
24
|
+
/** The repository the extension publishes this service's image to, without a tag.
|
|
25
|
+
* Stating it lets an application take the published image instead of building one. */
|
|
26
|
+
image?: string
|
|
27
|
+
|
|
22
28
|
port: number
|
|
23
29
|
ingress?: {
|
|
24
30
|
host: string
|
|
@@ -36,7 +42,7 @@ declare namespace toa.deployment {
|
|
|
36
42
|
name: string
|
|
37
43
|
value?: string | number
|
|
38
44
|
secret?: {
|
|
39
|
-
name: string
|
|
45
|
+
name: string
|
|
40
46
|
key: string
|
|
41
47
|
}
|
|
42
48
|
}
|
|
@@ -50,8 +56,8 @@ declare namespace toa.deployment {
|
|
|
50
56
|
services?: Service[] // dependency.Service
|
|
51
57
|
proxies?: Proxy[]
|
|
52
58
|
variables?: Variables
|
|
59
|
+
events?: string[]
|
|
53
60
|
}
|
|
54
|
-
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
type Dependency = {
|
|
@@ -59,8 +65,8 @@ declare namespace toa.deployment {
|
|
|
59
65
|
services?: _service.Service[] // deployment.Service
|
|
60
66
|
proxies?: dependency.Proxy[]
|
|
61
67
|
variables?: dependency.Variables
|
|
68
|
+
events?: string[]
|
|
62
69
|
}
|
|
63
|
-
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
export type Declaration = toa.deployment.dependency.Declaration
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type * as _composition from './composition'
|
|
2
|
-
import type * as _service from './service'
|
|
3
|
-
import type * as _dependency from './dependency'
|
|
1
|
+
import type * as _composition from './composition.d.ts'
|
|
2
|
+
import type * as _service from './service.d.ts'
|
|
3
|
+
import type * as _dependency from './dependency.d.ts'
|
|
4
4
|
|
|
5
5
|
declare namespace toa.deployment {
|
|
6
|
-
|
|
7
6
|
interface Declaration {
|
|
8
7
|
apiVersion: string
|
|
9
8
|
type: string
|
|
@@ -25,13 +24,11 @@ declare namespace toa.deployment {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
namespace installation {
|
|
28
|
-
|
|
29
27
|
interface Options {
|
|
30
28
|
wait?: boolean
|
|
31
29
|
target?: string
|
|
32
30
|
namespace?: string
|
|
33
31
|
}
|
|
34
|
-
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
namespace template {
|
|
@@ -52,9 +49,11 @@ declare namespace toa.deployment {
|
|
|
52
49
|
|
|
53
50
|
template(options: template.Options): Promise<string>
|
|
54
51
|
|
|
55
|
-
variables(
|
|
52
|
+
variables(options?: {
|
|
53
|
+
components?: string[]
|
|
54
|
+
services?: string[]
|
|
55
|
+
}): _dependency.Variable[]
|
|
56
56
|
}
|
|
57
|
-
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
export namespace installation {
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type * as _operator from './operator'
|
|
2
|
-
import * as _registry from './registry'
|
|
1
|
+
import type * as _operator from './operator.d.ts'
|
|
2
|
+
import * as _registry from './registry.d.ts'
|
|
3
3
|
|
|
4
4
|
declare namespace toa.deployment {
|
|
5
|
-
|
|
6
5
|
interface Factory {
|
|
7
6
|
operator(): _operator.Operator
|
|
8
7
|
|
|
9
8
|
registry(): _registry.Registry
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
export type Factory = toa.deployment.Factory
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
// noinspection ES6UnusedImports
|
|
2
2
|
|
|
3
3
|
import type { Composition } from '@toa.io/norm/types'
|
|
4
|
-
import type { Image } from './image'
|
|
5
|
-
import type { dependency } from '../dependency'
|
|
4
|
+
import type { Image } from './image.d.ts'
|
|
5
|
+
import type { dependency } from '../dependency.d.ts'
|
|
6
6
|
|
|
7
7
|
declare namespace toa.deployment.images {
|
|
8
|
+
interface Factory {
|
|
9
|
+
composition(composition: Composition): Image
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
service(path: string, service: dependency.Service): Image
|
|
13
|
-
}
|
|
14
|
-
|
|
11
|
+
service(path: string, service: dependency.Service): Image
|
|
12
|
+
}
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
export type Factory = toa.deployment.images.Factory
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
declare namespace toa.deployment.images {
|
|
2
|
-
|
|
3
2
|
export interface Image {
|
|
4
3
|
readonly reference: string
|
|
5
4
|
readonly context: string
|
|
6
5
|
|
|
6
|
+
/** The image this one is laid over, built and pushed as an image of its own. */
|
|
7
|
+
readonly dependencies?: Image
|
|
8
|
+
|
|
9
|
+
/** Whether the build reads `registry.build.arguments`. */
|
|
10
|
+
readonly arguments?: boolean
|
|
11
|
+
|
|
12
|
+
name: string
|
|
13
|
+
|
|
7
14
|
tag(): void
|
|
8
15
|
|
|
9
16
|
prepare(root: string): Promise<string>
|
|
10
17
|
}
|
|
11
18
|
|
|
19
|
+
/** Components in one image, laid over their dependencies. */
|
|
20
|
+
export interface Bundle extends Image {
|
|
21
|
+
readonly image?: string
|
|
22
|
+
readonly components: any[]
|
|
23
|
+
|
|
24
|
+
conflict(): string
|
|
25
|
+
}
|
|
12
26
|
}
|
|
13
27
|
|
|
14
28
|
export type Image = toa.deployment.images.Image
|
|
29
|
+
export type Bundle = toa.deployment.images.Bundle
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
// noinspection ES6UnusedImports
|
|
2
2
|
|
|
3
3
|
import type { Composition } from '@toa.io/norm'
|
|
4
|
-
import type { dependency } from '../dependency'
|
|
5
|
-
import type { Image } from
|
|
4
|
+
import type { dependency } from '../dependency.d.ts'
|
|
5
|
+
import type { Image } from './image.d.ts'
|
|
6
6
|
|
|
7
7
|
declare namespace toa.deployment.images {
|
|
8
|
+
interface Registry {
|
|
9
|
+
composition(composition: Composition): Image
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
composition(composition: Composition): Image
|
|
11
|
+
service(path: string, service: dependency.Service): Image
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
prepare(target: string): Promise<void>
|
|
15
|
-
|
|
16
|
-
push(): Promise<void>
|
|
17
|
-
}
|
|
13
|
+
prepare(target: string): Promise<void>
|
|
18
14
|
|
|
15
|
+
push(): Promise<void>
|
|
16
|
+
}
|
|
19
17
|
}
|
|
20
|
-
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import * as _deployment from './deployment'
|
|
2
|
-
import * as _dependency from './dependency'
|
|
1
|
+
import * as _deployment from './deployment.d.ts'
|
|
2
|
+
import * as _dependency from './dependency.d.ts'
|
|
3
3
|
|
|
4
4
|
declare namespace toa.deployment {
|
|
5
|
-
|
|
6
5
|
interface Operator {
|
|
7
|
-
export
|
|
6
|
+
export(path?: string): Promise<string>
|
|
8
7
|
|
|
9
|
-
install
|
|
8
|
+
install(options?: _deployment.installation.Options): Promise<void>
|
|
10
9
|
|
|
11
|
-
template
|
|
10
|
+
template(options?: _deployment.template.Options): Promise<string>
|
|
12
11
|
|
|
13
|
-
variables
|
|
12
|
+
variables(options?: {
|
|
13
|
+
components?: string[]
|
|
14
|
+
services?: string[]
|
|
15
|
+
}): _dependency.Variable[]
|
|
14
16
|
|
|
15
|
-
listVariables
|
|
17
|
+
listVariables(): _dependency.Variable[]
|
|
16
18
|
}
|
|
17
|
-
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export type Operator = toa.deployment.Operator
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type * as _norm from '@toa.io/norm/types'
|
|
2
|
-
import type * as _dependency from './dependency'
|
|
3
|
-
import type * as _image from
|
|
2
|
+
import type * as _dependency from './dependency.d.ts'
|
|
3
|
+
import type * as _image from './images/image.d.ts'
|
|
4
4
|
|
|
5
5
|
declare namespace toa.deployment {
|
|
6
|
-
|
|
7
6
|
interface Registry {
|
|
8
7
|
composition(composition: _norm.Composition): _image.Image
|
|
9
8
|
|
|
@@ -14,8 +13,12 @@ declare namespace toa.deployment {
|
|
|
14
13
|
build(): Promise<void>
|
|
15
14
|
|
|
16
15
|
push(): Promise<void>
|
|
17
|
-
}
|
|
18
16
|
|
|
17
|
+
/** Point each workload image at `environment` (`:production`). `deps-*` is not tagged. */
|
|
18
|
+
alias(environment?: string): Promise<void>
|
|
19
|
+
|
|
20
|
+
tags(): string[]
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export type Registry = toa.deployment.Registry
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type * as _deployment from './deployment'
|
|
1
|
+
import type * as _deployment from './deployment.d.ts'
|
|
2
2
|
|
|
3
3
|
declare namespace toa.deployment {
|
|
4
|
-
|
|
5
4
|
interface Ingress {
|
|
6
5
|
host: string
|
|
7
6
|
class: string
|
|
@@ -11,8 +10,10 @@ declare namespace toa.deployment {
|
|
|
11
10
|
interface Service extends _deployment.Deployable {
|
|
12
11
|
port: number
|
|
13
12
|
ingress?: Ingress
|
|
14
|
-
}
|
|
15
13
|
|
|
14
|
+
/** Annotations for the Service itself, as opposed to `ingress.annotations`. */
|
|
15
|
+
annotations?: object
|
|
16
|
+
}
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export type Service = toa.deployment.Service
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Manifest } from '@toa.io/norm'
|
|
2
|
+
import type { Locator } from '@toa.io/core'
|
|
3
|
+
|
|
4
|
+
export interface Service {
|
|
5
|
+
group: string
|
|
6
|
+
name: string
|
|
7
|
+
version: string
|
|
8
|
+
/** The repository the extension publishes this service's image to, without a tag.
|
|
9
|
+
* Stating it lets an application take the published image instead of building one. */
|
|
10
|
+
image?: string
|
|
11
|
+
port?: number
|
|
12
|
+
ingress?: Ingress
|
|
13
|
+
/** Annotations for the Service itself, as opposed to `ingress.annotations`. */
|
|
14
|
+
annotations?: object
|
|
15
|
+
resources?: Resources
|
|
16
|
+
variables?: Variable[]
|
|
17
|
+
components?: string[]
|
|
18
|
+
probe?: Probe | false
|
|
19
|
+
/** The workloads running this service, when compositions declared it instead of letting
|
|
20
|
+
* it deploy on its own. Set by the deployment, never by an extension. */
|
|
21
|
+
workload?: string[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Variable {
|
|
25
|
+
name: string
|
|
26
|
+
value?: string
|
|
27
|
+
secret?: {
|
|
28
|
+
name: string
|
|
29
|
+
key: string
|
|
30
|
+
optional?: boolean
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Instance<T> {
|
|
35
|
+
locator: Locator
|
|
36
|
+
manifest: T
|
|
37
|
+
component: Manifest
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type Instances<T> = Array<Instance<T>>
|
|
41
|
+
|
|
42
|
+
export type Variables = Record<'global' | string, Variable[]>
|
|
43
|
+
export type Mounts = Record<'global' | string, Mount[]>
|
|
44
|
+
|
|
45
|
+
export interface Dependency {
|
|
46
|
+
services?: Service[]
|
|
47
|
+
variables?: Variables
|
|
48
|
+
mounts?: Mounts
|
|
49
|
+
/** Event labels (`namespace.name.event`) this dependency consumes. */
|
|
50
|
+
events?: string[]
|
|
51
|
+
/** Default probe for compositions and services without their own probe. `false` disables. */
|
|
52
|
+
probe?: Probe | false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface Ingress {
|
|
56
|
+
/** Path prefix this service claims on the host. Defaults to `/`. */
|
|
57
|
+
path?: string
|
|
58
|
+
default?: boolean
|
|
59
|
+
hosts?: string[]
|
|
60
|
+
class?: string
|
|
61
|
+
annotations?: object
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface Probe {
|
|
65
|
+
port: number
|
|
66
|
+
path: string
|
|
67
|
+
delay?: number
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface Mount {
|
|
71
|
+
name: string
|
|
72
|
+
path: string
|
|
73
|
+
claim: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface Resources {
|
|
77
|
+
cpu: string[]
|
|
78
|
+
memory: string[]
|
|
79
|
+
}
|
package/types/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dependency.ts'
|
package/types/dependency.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export type Service = {
|
|
2
|
-
group: string
|
|
3
|
-
name: string
|
|
4
|
-
version: string
|
|
5
|
-
port: number
|
|
6
|
-
ingress: Ingress
|
|
7
|
-
variables: Variable[]
|
|
8
|
-
components?: string[]
|
|
9
|
-
probe?: Probe
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type Variable = {
|
|
13
|
-
name: string
|
|
14
|
-
value?: string
|
|
15
|
-
secret?: {
|
|
16
|
-
name: string,
|
|
17
|
-
key: string
|
|
18
|
-
optional?: boolean
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type Variables = Record<'global' | string, Variable[]>
|
|
23
|
-
|
|
24
|
-
export type Dependency = {
|
|
25
|
-
services?: Service[]
|
|
26
|
-
variables?: Variables
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type Ingress = {
|
|
30
|
-
hosts: string[]
|
|
31
|
-
class?: string
|
|
32
|
-
annotations?: object
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface Probe {
|
|
36
|
-
port: number
|
|
37
|
-
path: string
|
|
38
|
-
delay?: number
|
|
39
|
-
}
|
package/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dependency'
|