Skip to content

Commit bd7d01c

Browse files
committed
fix(upload-r2): bucket_name/bucket_path 改为必填,空值时跳过执行
1 parent 05797f5 commit bd7d01c

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{{- /* upload-r2: upload config file to Cloudflare R2 via rclone */ -}}
22
{{- $filename := .Config.filename | default (.Vars.filename | default "default-config.yaml") -}}
3-
{{- $bucketName := .Config.bucket_name | default (.Vars.buckets_name | default "test") -}}
3+
{{- $bucketName := .Config.bucket_name | default (.Vars.buckets_name | default "") -}}
44
{{- $bucketPath := .Config.bucket_path | default (.Vars.buckets_path | default "") -}}
5+
{{- if eq $bucketName "" -}}
6+
{{- else -}}
57
{{- $bucketPath = trimSpace $bucketPath -}}
68
{{- $filePath := printf "%s/%s" .CasePath $filename -}}
79
{{- $remotePath := printf "r2:%s/" $bucketName -}}
810
{{- if ne $bucketPath "" -}}
911
{{- $remotePath = printf "r2:%s/%s/" $bucketName $bucketPath -}}
1012
{{- end -}}
11-
{{- /* Delete old file (ignore errors) */ -}}
1213
{{- exec "rclone" "deletefile" (printf "%s%s" $remotePath $filename) -}}
13-
{{- /* Upload */ -}}
1414
{{- exec "rclone" "copy" $filePath $remotePath -}}
1515
{{- setOutput "r2_path" (printf "%s%s" $remotePath $filename) -}}
16+
{{- end -}}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"config_schema": {
2121
"bucket_name": {
2222
"type": "string",
23-
"required": false,
24-
"description": "R2 存储桶名称 (默认从 tfvars 读取 buckets_name,兜底 test)",
25-
"default": "test"
23+
"required": true,
24+
"description": "R2 存储桶名称",
25+
"default": ""
2626
},
2727
"bucket_path": {
2828
"type": "string",
29-
"required": false,
30-
"description": "R2 存储桶内路径 (默认从 tfvars 读取 buckets_path)",
29+
"required": true,
30+
"description": "R2 存储桶内路径",
3131
"default": ""
3232
},
3333
"filename": {

0 commit comments

Comments
 (0)