@highstate/restic 0.9.9 → 0.9.11

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": "@highstate/restic",
3
- "version": "0.9.9",
3
+ "version": "0.9.11",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -20,15 +20,15 @@
20
20
  "build": "highstate build"
21
21
  },
22
22
  "dependencies": {
23
- "@highstate/common": "^0.9.9",
24
- "@highstate/k8s": "^0.9.9",
25
- "@highstate/library": "^0.9.9",
26
- "@highstate/pulumi": "^0.9.9",
23
+ "@highstate/common": "^0.9.11",
24
+ "@highstate/k8s": "^0.9.11",
25
+ "@highstate/library": "^0.9.11",
26
+ "@highstate/pulumi": "^0.9.11",
27
27
  "@pulumi/kubernetes": "^4.18.0",
28
28
  "remeda": "^2.21.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@highstate/cli": "^0.9.9"
31
+ "@highstate/cli": "^0.9.11"
32
32
  },
33
- "gitHead": "1c04a713fa1bb7c0231e5e6d0537709097bb0e8e"
33
+ "gitHead": "d62cae30ea9fadaa1aa4fb3b5734a16cf53810ce"
34
34
  }
package/src/job-pair.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import type { k8s, restic } from "@highstate/library"
2
2
  import type { InputL34Endpoint } from "@highstate/common"
3
- import { batch, core } from "@pulumi/kubernetes"
3
+ import { batch } from "@pulumi/kubernetes"
4
4
  import {
5
5
  createScriptContainer,
6
6
  CronJob,
7
+ getProvider,
7
8
  Job,
8
- mapMetadata,
9
9
  ScriptBundle,
10
+ Secret,
10
11
  type CommonArgs,
11
12
  type Container,
12
13
  type ScriptDistribution,
@@ -105,7 +106,7 @@ export class BackupJobPair extends ComponentResource {
105
106
  /**
106
107
  * The credentials used to access the repository and encrypt the backups.
107
108
  */
108
- readonly credentials: Output<core.v1.Secret>
109
+ readonly credentials: Output<Secret>
109
110
 
110
111
  /**
111
112
  * The script bundle used by the backup and restore jobs.
@@ -124,16 +125,17 @@ export class BackupJobPair extends ComponentResource {
124
125
 
125
126
  constructor(
126
127
  private readonly name: string,
127
- args: BackupJobPairArgs,
128
+ private readonly args: BackupJobPairArgs,
128
129
  private readonly opts?: ComponentResourceOptions,
129
130
  ) {
130
131
  super("highstate:restic:BackupJobPair", name, args, opts)
131
132
 
132
133
  this.credentials = output(args).apply(args => {
133
- return new core.v1.Secret(
134
+ return Secret.create(
134
135
  `${name}-backup-credentials`,
135
136
  {
136
- metadata: mapMetadata(args, `${name}-backup-credentials`),
137
+ namespace: args.namespace,
138
+ cluster: args.cluster,
137
139
 
138
140
  stringData: {
139
141
  password: args.backupPassword,
@@ -167,14 +169,14 @@ export class BackupJobPair extends ComponentResource {
167
169
  `,
168
170
  },
169
171
 
170
- allowedEndpoints: [
171
- "rclone.org:443",
172
- "downloads.rclone.org:443",
173
- ...(args.allowedEndpoints ?? []),
174
- ...(args.resticRepo.remoteEndpoints ?? []),
175
- ],
172
+ allowedEndpoints: ["rclone.org:443", "downloads.rclone.org:443"],
176
173
  },
177
174
 
175
+ allowedEndpoints: [
176
+ ...(args.allowedEndpoints ?? []),
177
+ ...(args.resticRepo.remoteEndpoints ?? []),
178
+ ],
179
+
178
180
  environment: {
179
181
  RESTIC_REPOSITORY: `rclone:${args.resticRepo.remoteName}:${repositoryPath}`,
180
182
  RESTIC_PASSWORD_FILE: "/credentials/password",
@@ -235,6 +237,8 @@ export class BackupJobPair extends ComponentResource {
235
237
  main: "restore.sh",
236
238
  bundle: this.scriptBundle,
237
239
  }),
240
+
241
+ backoffLimit: 2,
238
242
  },
239
243
  { ...opts, parent: this },
240
244
  )
@@ -259,12 +263,7 @@ export class BackupJobPair extends ComponentResource {
259
263
 
260
264
  jobTemplate: {
261
265
  spec: {
262
- backoffLimit: 1,
263
- template: {
264
- spec: {
265
- restartPolicy: "Never",
266
- },
267
- },
266
+ backoffLimit: 2,
268
267
  },
269
268
  },
270
269
  },
@@ -278,7 +277,7 @@ export class BackupJobPair extends ComponentResource {
278
277
  const invokedTrigger = triggers.find(trigger => trigger.name === triggerName)
279
278
 
280
279
  if (invokedTrigger) {
281
- this.createBackupOnDestroyJob()
280
+ void this.createBackupOnDestroyJob()
282
281
  return
283
282
  }
284
283
 
@@ -292,7 +291,7 @@ export class BackupJobPair extends ComponentResource {
292
291
  }
293
292
  }
294
293
 
295
- private createBackupOnDestroyJob(): void {
294
+ private async createBackupOnDestroyJob(): Promise<void> {
296
295
  new batch.v1.Job(
297
296
  `${this.name}-backup-on-destroy`,
298
297
  {
@@ -302,7 +301,7 @@ export class BackupJobPair extends ComponentResource {
302
301
  },
303
302
  spec: this.backupJob.cronJob.spec.jobTemplate.spec,
304
303
  },
305
- { ...this.opts, parent: this },
304
+ { ...this.opts, parent: this, provider: await getProvider(this.args.cluster) },
306
305
  )
307
306
  }
308
307
  }