@toa.io/operations 0.24.0-alpha.14 → 0.24.0-alpha.16
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/operations",
|
|
3
|
-
"version": "0.24.0-alpha.
|
|
3
|
+
"version": "0.24.0-alpha.16",
|
|
4
4
|
"description": "Toa Deployment",
|
|
5
5
|
"homepage": "https://toa.io",
|
|
6
6
|
"author": {
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@toa.io/filesystem": "0.24.0-alpha.
|
|
31
|
-
"@toa.io/generic": "0.24.0-alpha.
|
|
32
|
-
"@toa.io/norm": "0.24.0-alpha.
|
|
33
|
-
"@toa.io/yaml": "0.24.0-alpha.
|
|
30
|
+
"@toa.io/filesystem": "0.24.0-alpha.16",
|
|
31
|
+
"@toa.io/generic": "0.24.0-alpha.16",
|
|
32
|
+
"@toa.io/norm": "0.24.0-alpha.16",
|
|
33
|
+
"@toa.io/yaml": "0.24.0-alpha.16",
|
|
34
34
|
"execa": "5.1.1",
|
|
35
35
|
"fs-extra": "11.1.1"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "dbfea6013c1aed5be6f18f120fa85f1bb46e153c"
|
|
38
38
|
}
|
|
@@ -9,22 +9,15 @@ const { Image } = require('./image')
|
|
|
9
9
|
class Composition extends Image {
|
|
10
10
|
dockerfile = join(__dirname, 'composition.Dockerfile')
|
|
11
11
|
|
|
12
|
-
/** @type {string} */
|
|
13
12
|
#name
|
|
14
|
-
|
|
15
|
-
/** @type {toa.norm.Component[]} */
|
|
13
|
+
#image
|
|
16
14
|
#components
|
|
17
15
|
|
|
18
|
-
/**
|
|
19
|
-
* @param {string} scope
|
|
20
|
-
* @param {toa.norm.context.Runtime} runtime
|
|
21
|
-
* @param {toa.norm.context.Registry} registry
|
|
22
|
-
* @param {toa.norm.context.Composition} composition
|
|
23
|
-
*/
|
|
24
16
|
constructor (scope, runtime, registry, composition) {
|
|
25
17
|
super(scope, runtime, registry)
|
|
26
18
|
|
|
27
19
|
this.#name = composition.name
|
|
20
|
+
this.#image = composition.image
|
|
28
21
|
this.#components = composition.components
|
|
29
22
|
}
|
|
30
23
|
|
|
@@ -38,6 +31,24 @@ class Composition extends Image {
|
|
|
38
31
|
return hash(tags.join(';'))
|
|
39
32
|
}
|
|
40
33
|
|
|
34
|
+
get base () {
|
|
35
|
+
if (this.#image !== undefined)
|
|
36
|
+
return this.#image
|
|
37
|
+
|
|
38
|
+
let image = null
|
|
39
|
+
|
|
40
|
+
for (const component of this.#components) {
|
|
41
|
+
const value = component.build?.image
|
|
42
|
+
|
|
43
|
+
if (image !== null && image !== value)
|
|
44
|
+
throw new Error(`Composition '${this.#name}' requires different base images for its components. Specify base image for the composition in the context.`)
|
|
45
|
+
|
|
46
|
+
image = value
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return image ?? undefined
|
|
50
|
+
}
|
|
51
|
+
|
|
41
52
|
async prepare (root) {
|
|
42
53
|
const context = await super.prepare(root)
|
|
43
54
|
|
|
@@ -13,36 +13,21 @@ const fs = require('fs-extra')
|
|
|
13
13
|
class Image {
|
|
14
14
|
context
|
|
15
15
|
reference
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @protected
|
|
19
|
-
* @type {string}
|
|
20
|
-
*/
|
|
21
16
|
dockerfile
|
|
22
17
|
|
|
23
|
-
/** @type {string} */
|
|
24
18
|
#scope
|
|
25
|
-
|
|
26
|
-
/** @type {toa.norm.context.Registry} */
|
|
27
19
|
#registry
|
|
28
|
-
|
|
29
|
-
/** @type {toa.norm.context.Runtime} */
|
|
30
20
|
#runtime
|
|
21
|
+
#values = {
|
|
22
|
+
build: {
|
|
23
|
+
image: 'node:20.9.0-alpine3.18'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
31
26
|
|
|
32
|
-
/** @type {{ runtime?: Partial<toa.norm.context.Runtime>, build: object }} */
|
|
33
|
-
#values = { build: { command: 'echo hello' } }
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @param {string} scope
|
|
37
|
-
* @param {toa.norm.context.Runtime} runtime
|
|
38
|
-
* @param {toa.norm.context.Registry} registry
|
|
39
|
-
*/
|
|
40
27
|
constructor (scope, runtime, registry) {
|
|
41
28
|
this.#scope = scope
|
|
42
29
|
this.#registry = registry
|
|
43
30
|
this.#runtime = runtime
|
|
44
|
-
|
|
45
|
-
this.#setValues()
|
|
46
31
|
}
|
|
47
32
|
|
|
48
33
|
tag () {
|
|
@@ -51,23 +36,17 @@ class Image {
|
|
|
51
36
|
this.reference = posix.join(this.#registry.base ?? '', this.#scope, `${this.name}:${tag}`)
|
|
52
37
|
}
|
|
53
38
|
|
|
54
|
-
/**
|
|
55
|
-
* @abstract
|
|
56
|
-
* @protected
|
|
57
|
-
* @type {string}
|
|
58
|
-
*/
|
|
59
39
|
get name () {}
|
|
60
40
|
|
|
61
|
-
/**
|
|
62
|
-
* @abstract
|
|
63
|
-
* @protected
|
|
64
|
-
* @type {string}
|
|
65
|
-
*/
|
|
66
41
|
get version () {}
|
|
67
42
|
|
|
43
|
+
get base () {}
|
|
44
|
+
|
|
68
45
|
async prepare (root) {
|
|
69
46
|
if (this.dockerfile === undefined) throw new Error('Dockerfile isn\'t specified')
|
|
70
47
|
|
|
48
|
+
this.#setValues()
|
|
49
|
+
|
|
71
50
|
const path = join(root, `${this.name}.${this.version}`)
|
|
72
51
|
|
|
73
52
|
await fs.ensureDir(path)
|
|
@@ -88,6 +67,11 @@ class Image {
|
|
|
88
67
|
this.#values.runtime = this.#runtime
|
|
89
68
|
this.#values.build = overwrite(this.#values.build, this.#registry.build)
|
|
90
69
|
|
|
70
|
+
const image = this.base
|
|
71
|
+
|
|
72
|
+
if (image !== undefined)
|
|
73
|
+
this.#values.build.image = image
|
|
74
|
+
|
|
91
75
|
if (this.#values.build.arguments !== undefined) this.#values.build.arguments = createArguments(this.#values.build.arguments)
|
|
92
76
|
if (this.#values.build.run !== undefined) this.#values.build.run = createRunCommands(this.#values.build.run)
|
|
93
77
|
}
|