@toa.io/operations 1.0.0-alpha.70 → 1.0.0-alpha.72

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": "1.0.0-alpha.70",
3
+ "version": "1.0.0-alpha.72",
4
4
  "description": "Toa Deployment",
5
5
  "homepage": "https://toa.io",
6
6
  "author": {
@@ -34,5 +34,5 @@
34
34
  "execa": "5.1.1",
35
35
  "fs-extra": "11.1.1"
36
36
  },
37
- "gitHead": "3fe12fa8b6a82fecc9205e9f6dd4b39e03184c7b"
37
+ "gitHead": "919b587dfcdfab40d18f0f8bd24b34d8107f811a"
38
38
  }
@@ -42,6 +42,7 @@ class Deployment {
42
42
 
43
43
  if (options.namespace !== undefined) args.push('-n', options.namespace)
44
44
  if (options.wait === true) args.push('--wait')
45
+ if (options.timeout !== undefined) args.push('--timeout', options.timeout)
45
46
 
46
47
  await this.#process.execute('helm', ['dependency', 'update', this.#target])
47
48
  await this.#process.execute('helm', ['upgrade', this.#chart.name, '-i', ...args, this.#target])
@@ -74,6 +74,11 @@ class Registry {
74
74
  * @returns {Promise<void>}
75
75
  */
76
76
  async #build (image, push = false) {
77
+ if (await this.exists(image.reference)) {
78
+ console.log('Image already exists, skipping:', image.reference)
79
+ return
80
+ }
81
+
77
82
  const args = ['--context=default', 'buildx', 'build']
78
83
 
79
84
  if (push) {
@@ -96,7 +101,6 @@ class Registry {
96
101
 
97
102
  args.push('--platform', platform)
98
103
  args.push('--builder', builder)
99
-
100
104
  } else {
101
105
  args.push('--builder', 'default')
102
106
  }
@@ -110,6 +114,18 @@ class Registry {
110
114
  await this.#build(image, true)
111
115
  }
112
116
 
117
+ async exists (tag) {
118
+ const args = ['inspect', tag]
119
+
120
+ try {
121
+ await this.#process.execute('docker', args, { silently: true })
122
+ } catch {
123
+ return false
124
+ }
125
+
126
+ return true
127
+ }
128
+
113
129
  async #createBuilder () {
114
130
  const name = `toa-${newid()}`
115
131
  const create = `buildx create --name ${name} --bootstrap --use`.split(' ')
@@ -4,9 +4,11 @@ declare namespace toa.deployment.images {
4
4
  readonly reference: string
5
5
  readonly context: string
6
6
 
7
- tag(): void
7
+ name: string
8
8
 
9
- prepare(root: string): Promise<string>
9
+ tag (): void
10
+
11
+ prepare (root: string): Promise<string>
10
12
  }
11
13
 
12
14
  }