@highstate/restic 0.9.4 → 0.9.5
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/highstate.manifest.json +2 -2
- package/dist/index.js +31 -21
- package/dist/index.js.map +1 -1
- package/dist/repo/index.js +1 -1
- package/dist/repo/index.js.map +1 -1
- package/package.json +7 -7
- package/src/job-pair.ts +23 -14
- package/src/repo/index.ts +1 -1
- package/src/scripts.ts +1 -1
package/dist/repo/index.js
CHANGED
package/dist/repo/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/repo/index.ts"],"sourcesContent":["import { restic } from \"@highstate/library\"\nimport { forUnit, getOrCreateSecret } from \"@highstate/pulumi\"\nimport { generatePassword } from \"@highstate/common\"\n\nconst { args, secrets, outputs } = forUnit(restic.repo)\n\nconst remoteName = secrets.rcloneConfig.apply(config => {\n const remoteNames = Array.from(config.matchAll(/(?<=\\[).+?(?=\\])/g))\n\n if (remoteNames.length === 0) {\n throw new Error(\"No remotes found in rclone config\")\n }\n\n if (remoteNames.length > 1) {\n throw new Error(\"Multiple remotes found in rclone config\")\n }\n\n return remoteNames[0][0]\n})\n\nconst password = getOrCreateSecret(secrets, \"password\", generatePassword)\nconst basePath = args.basePath?.replace(/\\/$/, \"\") ?? \"backups\"\n\nexport default outputs({\n repo: {\n password,\n type: \"rclone\",\n rcloneConfig: secrets.rcloneConfig,\n remoteName,\n
|
|
1
|
+
{"version":3,"sources":["../../src/repo/index.ts"],"sourcesContent":["import { restic } from \"@highstate/library\"\nimport { forUnit, getOrCreateSecret } from \"@highstate/pulumi\"\nimport { generatePassword } from \"@highstate/common\"\n\nconst { args, secrets, outputs } = forUnit(restic.repo)\n\nconst remoteName = secrets.rcloneConfig.apply(config => {\n const remoteNames = Array.from(config.matchAll(/(?<=\\[).+?(?=\\])/g))\n\n if (remoteNames.length === 0) {\n throw new Error(\"No remotes found in rclone config\")\n }\n\n if (remoteNames.length > 1) {\n throw new Error(\"Multiple remotes found in rclone config\")\n }\n\n return remoteNames[0][0]\n})\n\nconst password = getOrCreateSecret(secrets, \"password\", generatePassword)\nconst basePath = args.basePath?.replace(/\\/$/, \"\") ?? \"backups\"\n\nexport default outputs({\n repo: {\n password,\n type: \"rclone\",\n rcloneConfig: secrets.rcloneConfig,\n remoteName,\n remoteEndpoints: args.remoteDomains ?? [],\n basePath,\n },\n $status: {\n remoteName,\n basePath,\n },\n})\n"],"mappings":";;;AAAA,SAAS,cAAc;AACvB,SAAS,SAAS,yBAAyB;AAC3C,SAAS,wBAAwB;AAEjC,IAAM,EAAE,MAAM,SAAS,QAAQ,IAAI,QAAQ,OAAO,IAAI;AAEtD,IAAM,aAAa,QAAQ,aAAa,MAAM,YAAU;AACtD,QAAM,cAAc,MAAM,KAAK,OAAO,SAAS,mBAAmB,CAAC;AAEnE,MAAI,YAAY,WAAW,GAAG;AAC5B,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,MAAI,YAAY,SAAS,GAAG;AAC1B,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC3D;AAEA,SAAO,YAAY,CAAC,EAAE,CAAC;AACzB,CAAC;AAED,IAAM,WAAW,kBAAkB,SAAS,YAAY,gBAAgB;AACxE,IAAM,WAAW,KAAK,UAAU,QAAQ,OAAO,EAAE,KAAK;AAEtD,IAAO,eAAQ,QAAQ;AAAA,EACrB,MAAM;AAAA,IACJ;AAAA,IACA,MAAM;AAAA,IACN,cAAc,QAAQ;AAAA,IACtB;AAAA,IACA,iBAAiB,KAAK,iBAAiB,CAAC;AAAA,IACxC;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP;AAAA,IACA;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@highstate/restic",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"build": "highstate build"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@highstate/common": "^0.9.
|
|
24
|
-
"@highstate/k8s": "^0.9.
|
|
25
|
-
"@highstate/library": "^0.9.
|
|
26
|
-
"@highstate/pulumi": "^0.9.
|
|
23
|
+
"@highstate/common": "^0.9.5",
|
|
24
|
+
"@highstate/k8s": "^0.9.5",
|
|
25
|
+
"@highstate/library": "^0.9.5",
|
|
26
|
+
"@highstate/pulumi": "^0.9.5",
|
|
27
27
|
"@pulumi/kubernetes": "^4.18.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@highstate/cli": "^0.9.
|
|
30
|
+
"@highstate/cli": "^0.9.5"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "93fa1e8b1189a5232055c852fd79a684d8b80444"
|
|
33
33
|
}
|
package/src/job-pair.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { k8s, restic } from "@highstate/library"
|
|
2
|
+
import type { InputL34Endpoint } from "@highstate/common"
|
|
2
3
|
import { batch, core } from "@pulumi/kubernetes"
|
|
3
4
|
import {
|
|
4
5
|
createScriptContainer,
|
|
@@ -30,7 +31,7 @@ export type BackupJobPairArgs = CommonArgs & {
|
|
|
30
31
|
/**
|
|
31
32
|
* The k8s cluster to calculate the repository path.
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
+
cluster: Input<k8s.Cluster>
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
37
|
* The repository to backup/restore to/from.
|
|
@@ -87,6 +88,11 @@ export type BackupJobPairArgs = CommonArgs & {
|
|
|
87
88
|
* You can also use `ubuntu` if you need to install packages that are not available (or working) in Alpine.
|
|
88
89
|
*/
|
|
89
90
|
distribution?: ScriptDistribution
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Extra allowed endpoints for the backup and restore jobs.
|
|
94
|
+
*/
|
|
95
|
+
allowedEndpoints?: InputArray<InputL34Endpoint>
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
export class BackupJobPair extends ComponentResource {
|
|
@@ -128,7 +134,7 @@ export class BackupJobPair extends ComponentResource {
|
|
|
128
134
|
"rclone.conf": args.resticRepo.rcloneConfig,
|
|
129
135
|
},
|
|
130
136
|
},
|
|
131
|
-
{ parent: this
|
|
137
|
+
{ ...opts, parent: this },
|
|
132
138
|
)
|
|
133
139
|
})
|
|
134
140
|
|
|
@@ -149,10 +155,17 @@ export class BackupJobPair extends ComponentResource {
|
|
|
149
155
|
curl https://rclone.org/install.sh | bash
|
|
150
156
|
`,
|
|
151
157
|
},
|
|
158
|
+
|
|
159
|
+
allowedEndpoints: [
|
|
160
|
+
"rclone.org:443",
|
|
161
|
+
"downloads.rclone.org:443",
|
|
162
|
+
...(args.allowedEndpoints ?? []),
|
|
163
|
+
...(args.resticRepo.remoteEndpoints ?? []),
|
|
164
|
+
],
|
|
152
165
|
},
|
|
153
166
|
|
|
154
167
|
environment: {
|
|
155
|
-
RESTIC_REPOSITORY: `rclone:${args.resticRepo.remoteName}:${args.resticRepo.basePath}/${args.
|
|
168
|
+
RESTIC_REPOSITORY: `rclone:${args.resticRepo.remoteName}:${args.resticRepo.basePath}/${args.cluster.name}/${name}`,
|
|
156
169
|
RESTIC_PASSWORD_FILE: "/credentials/password",
|
|
157
170
|
RESTIC_HOSTNAME: "default",
|
|
158
171
|
RCLONE_CONFIG: "/credentials/rclone.conf",
|
|
@@ -184,6 +197,7 @@ export class BackupJobPair extends ComponentResource {
|
|
|
184
197
|
return new ScriptBundle(
|
|
185
198
|
`${name}-backup-scripts`,
|
|
186
199
|
{
|
|
200
|
+
cluster: args.cluster,
|
|
187
201
|
namespace: args.namespace,
|
|
188
202
|
distribution: args.distribution ?? "alpine",
|
|
189
203
|
|
|
@@ -193,7 +207,7 @@ export class BackupJobPair extends ComponentResource {
|
|
|
193
207
|
...normalize(args.environment, args.environments),
|
|
194
208
|
],
|
|
195
209
|
},
|
|
196
|
-
{ parent: this
|
|
210
|
+
{ ...opts, parent: this },
|
|
197
211
|
)
|
|
198
212
|
})
|
|
199
213
|
|
|
@@ -201,6 +215,7 @@ export class BackupJobPair extends ComponentResource {
|
|
|
201
215
|
return new Job(
|
|
202
216
|
`${name}-restore`,
|
|
203
217
|
{
|
|
218
|
+
cluster: args.cluster,
|
|
204
219
|
namespace: args.namespace,
|
|
205
220
|
|
|
206
221
|
container: createScriptContainer({
|
|
@@ -210,7 +225,7 @@ export class BackupJobPair extends ComponentResource {
|
|
|
210
225
|
bundle: this.scriptBundle,
|
|
211
226
|
}),
|
|
212
227
|
},
|
|
213
|
-
{ parent: this
|
|
228
|
+
{ ...opts, parent: this },
|
|
214
229
|
)
|
|
215
230
|
})
|
|
216
231
|
|
|
@@ -219,6 +234,7 @@ export class BackupJobPair extends ComponentResource {
|
|
|
219
234
|
`${name}-backup`,
|
|
220
235
|
{
|
|
221
236
|
namespace: args.namespace,
|
|
237
|
+
cluster: args.cluster,
|
|
222
238
|
|
|
223
239
|
container: createScriptContainer({
|
|
224
240
|
...args.backupContainer,
|
|
@@ -241,16 +257,9 @@ export class BackupJobPair extends ComponentResource {
|
|
|
241
257
|
},
|
|
242
258
|
},
|
|
243
259
|
},
|
|
244
|
-
{ parent: this
|
|
260
|
+
{ ...opts, parent: this },
|
|
245
261
|
)
|
|
246
262
|
})
|
|
247
|
-
|
|
248
|
-
this.registerOutputs({
|
|
249
|
-
credentials: this.credentials,
|
|
250
|
-
scriptBundle: this.scriptBundle,
|
|
251
|
-
restoreJob: this.restoreJob,
|
|
252
|
-
backupJob: this.backupJob,
|
|
253
|
-
})
|
|
254
263
|
}
|
|
255
264
|
|
|
256
265
|
handleTrigger(triggers: InstanceTriggerInvocation[]): InstanceTrigger | undefined {
|
|
@@ -282,7 +291,7 @@ export class BackupJobPair extends ComponentResource {
|
|
|
282
291
|
},
|
|
283
292
|
spec: this.backupJob.cronJob.spec.jobTemplate.spec,
|
|
284
293
|
},
|
|
285
|
-
{ parent: this
|
|
294
|
+
{ ...this.opts, parent: this },
|
|
286
295
|
)
|
|
287
296
|
}
|
|
288
297
|
}
|
package/src/repo/index.ts
CHANGED