Skip to content

Commit 05797f5

Browse files
committed
feat(upload-r2): migrate to template mode with exec function (v2.0.0)
1 parent 97358d4 commit 05797f5

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- /* upload-r2: upload config file to Cloudflare R2 via rclone */ -}}
2+
{{- $filename := .Config.filename | default (.Vars.filename | default "default-config.yaml") -}}
3+
{{- $bucketName := .Config.bucket_name | default (.Vars.buckets_name | default "test") -}}
4+
{{- $bucketPath := .Config.bucket_path | default (.Vars.buckets_path | default "") -}}
5+
{{- $bucketPath = trimSpace $bucketPath -}}
6+
{{- $filePath := printf "%s/%s" .CasePath $filename -}}
7+
{{- $remotePath := printf "r2:%s/" $bucketName -}}
8+
{{- if ne $bucketPath "" -}}
9+
{{- $remotePath = printf "r2:%s/%s/" $bucketName $bucketPath -}}
10+
{{- end -}}
11+
{{- /* Delete old file (ignore errors) */ -}}
12+
{{- exec "rclone" "deletefile" (printf "%s%s" $remotePath $filename) -}}
13+
{{- /* Upload */ -}}
14+
{{- exec "rclone" "copy" $filePath $remotePath -}}
15+
{{- setOutput "r2_path" (printf "%s%s" $remotePath $filename) -}}

plugins/redc-plugin-upload-r2/plugin.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
{
22
"name": "redc-plugin-upload-r2",
3-
"version": "1.0.1",
3+
"version": "2.0.0",
44
"description": "场景部署后将生成的配置文件上传到 Cloudflare R2 存储桶",
55
"description_en": "Upload generated config files to Cloudflare R2 bucket after deployment",
66
"author": "wgpsec",
77
"homepage": "https://github.com/wgpsec/redc-template",
88
"category": "storage",
99
"tags": ["r2", "cloudflare", "rclone", "upload"],
10-
"min_redc_version": "3.1.0",
10+
"min_redc_version": "3.3.5",
1111
"capabilities": {
1212
"hooks": {
13-
"post-apply": "hooks/post-apply.sh"
13+
"post-apply": {
14+
"type": "template",
15+
"template": "hooks/post-apply.tmpl",
16+
"output": ""
17+
}
1418
}
1519
},
1620
"config_schema": {

0 commit comments

Comments
 (0)