From 72745885e03969712e1f19435fed0a8d03ab897f Mon Sep 17 00:00:00 2001 From: rainerosion Date: Tue, 9 May 2023 20:52:31 +0800 Subject: [PATCH] docker supported --- Dockerfile | 4 ++++ cos.go | 6 +++++- readme.md | 29 +++++++++++++++++++++-------- 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0193be4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM alpine:latest +LABEL authors="rainerosion@gmail.com" +COPY upcos /bin/upcos +ENTRYPOINT ["upcos"] \ No newline at end of file diff --git a/cos.go b/cos.go index a75cf40..6592955 100644 --- a/cos.go +++ b/cos.go @@ -38,8 +38,12 @@ func main() { resume := &upyun.MemoryRecorder{} // 若设置为 nil,则为正常的分片上传 yun.SetRecorder(resume) + separator := "/" for _, path := range fileList { - remotePath := remoteBasePath + "/" + path + if strings.HasPrefix(path, "/") { + separator = "" + } + remotePath := remoteBasePath + separator + path err = yun.Put(&upyun.PutObjectConfig{ Path: remotePath, LocalPath: path, diff --git a/readme.md b/readme.md index 4579a15..ef08d04 100644 --- a/readme.md +++ b/readme.md @@ -1,12 +1,25 @@ # drone plugins for upyun cos ## 参数说明 -| 参数 | 说明 | 备注 | -| ---------------- |----------|--------| -| up_operator | 操作员名称 || -| up_password | 操作员密码 || -| up_bucket | bucket名称 | 服务名称 | -| local_base_path | 本地路径 | 文件或文件夹 | -| remote_base_path | 对象存储路径 | 文件夹 | +| 参数 | 说明 | 备注 | +| ---------------- |--------|-------------| +| up_operator | 操作员名称 | | +| up_password | 操作员密码 | | +| up_bucket | bucket | 服务名称 | +| local_base_path | 本地路径 | 文件或文件夹 | +| remote_base_path | 对象存储路径 | 文件存放路径(文件夹) | -## 使用方式 \ No newline at end of file +## 使用方式 +````yaml + - name: upload-upyun + image: rainteam/upcos:latest + settings: + up_operator: + from_secret: up_operator + up_password: + from_secret: up_password + up_bucket: + from_bucket: up_bucket + local_base_path: wechatbot + remote_base_path: gitea/devops +```` \ No newline at end of file