Compare commits

...

58 Commits

Author SHA1 Message Date
677cac0b33 feat(更新依赖): 更新依赖
All checks were successful
continuous-integration/drone/push Build is passing
2025-04-02 11:11:34 +08:00
4bdcf5d57e feat(更新依赖): 更新依赖
All checks were successful
continuous-integration/drone/push Build is passing
2025-03-05 18:29:06 +08:00
ec10d3093a feat(更新版本): 更新版本
All checks were successful
continuous-integration/drone/push Build is passing
2025-02-13 09:19:54 +08:00
61844be062 feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2025-02-11 21:49:42 +08:00
6be36afba1 feat(更新语法): 更新语法
All checks were successful
continuous-integration/drone/push Build is passing
2025-01-18 23:07:38 +08:00
c674c7c3c3 feat(更新镜像): 更新镜像
All checks were successful
continuous-integration/drone/push Build is passing
2025-01-18 22:59:05 +08:00
095ddd9165 feat(更新镜像): 更新镜像
All checks were successful
continuous-integration/drone/push Build is passing
2024-12-17 16:43:54 +08:00
67637fa55e feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-12-04 14:30:35 +08:00
a229f9eb3b feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-11-21 14:07:37 +08:00
4df67b8874 feat(更新依赖): 更新依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-11-08 21:49:22 +08:00
a470a2eab3 feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-10-08 09:59:10 +08:00
5a6d2baadf feat(升级版本): 升级版本
All checks were successful
continuous-integration/drone/push Build is passing
2024-09-12 14:58:02 +08:00
0c86408480 feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-15 03:44:45 +08:00
d5454ddc37 feat(更新依赖): 更新依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-17 10:03:17 +08:00
239c3d2ad0 feat(构建脚本): 调整构建脚本
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-22 22:56:00 +08:00
969b0cbe62 feat(更新镜像): 更新镜像
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-21 15:51:38 +08:00
0b233666f5 feat(更新依赖): 更新依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-19 14:31:33 +08:00
c7d127dff7 feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-05 13:51:08 +08:00
59411279eb feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-05-11 19:47:01 +08:00
e528f2ddf4 feat(更新版本): 更新版本
All checks were successful
continuous-integration/drone/push Build is passing
2024-04-07 13:38:13 +08:00
e9e86af4dd feat(更新依赖): 更新依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-13 16:55:55 +08:00
ab8323a34d feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-13 00:57:02 +08:00
1d73a5a962 feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2024-01-10 11:42:19 +08:00
882519753b feat(升级版本): 升级版本
All checks were successful
continuous-integration/drone/push Build is passing
2023-12-06 11:31:21 +08:00
bdaade4a18 feat(更新依赖): 更新依赖
All checks were successful
continuous-integration/drone/push Build is passing
2023-11-08 12:38:40 +08:00
83e9a70b01 feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2023-10-15 23:45:49 +08:00
67e3da13c7 Merge branch 'main' of github.com:xiaoqidun/gocos
All checks were successful
continuous-integration/drone/push Build is passing
2023-10-07 00:04:43 +08:00
1ab730b0bb feat(更新镜像): 更新镜像 2023-10-07 00:03:23 +08:00
e91e2d56e4 feat(编译参数): 调整编译参数
All checks were successful
continuous-integration/drone/push Build is passing
2023-10-06 02:26:17 +08:00
d7b165ce82 feat(升级镜像): 升级镜像
All checks were successful
continuous-integration/drone/push Build is passing
2023-09-29 17:37:01 +08:00
0d84371b1f feat(更新依赖): 更新依赖
All checks were successful
continuous-integration/drone/push Build is passing
2023-09-07 10:38:26 +08:00
536852bb79 feat(更新镜像): 更新底层镜像
All checks were successful
continuous-integration/drone/push Build is passing
2023-08-09 15:55:00 +08:00
11ab5e4f01 feat(更新镜像): 更新镜像
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
2023-07-12 11:10:26 +08:00
a2ea6579d9 feat(设置区域): 设置打包区域
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-07 02:28:15 +08:00
dff970b744 feat(更新镜像): 增加国内部署
Some checks reported errors
continuous-integration/drone/push Build is passing
continuous-integration/drone Build was killed
2023-07-07 01:28:01 +08:00
3ef8929f4b feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2022-08-04 12:56:15 +08:00
89b2e61cc8 feat(基础镜像): 更新基础镜像
All checks were successful
continuous-integration/drone/push Build is passing
2022-06-02 14:30:26 +08:00
f60851107c feat(更新依赖): 更新SDK 2022-06-02 14:29:46 +08:00
0a622b5bb7 feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2022-05-12 11:36:48 +08:00
98240a452c feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2022-04-02 11:33:22 +08:00
9f67466d89 feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2022-03-05 09:28:46 +08:00
31bc0fdb75 feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2022-02-23 14:39:33 +08:00
73502e2c49 feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2022-02-08 04:48:15 +08:00
802053acfd feat(升级依赖): 升级依赖
All checks were successful
continuous-integration/drone/push Build is passing
2021-11-26 10:29:22 +08:00
067622650a feat(发布镜像): 调整发布镜像
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-22 09:46:02 +08:00
a36fd1d626 feat(更新依赖): 更新COS SDK
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-29 22:51:09 +08:00
6030905e57 feat(更新依赖): 更新腾讯云COS SDK
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-03 09:06:50 +08:00
96830a79ef feat(更新依赖): 更新腾讯云COS SDK
All checks were successful
continuous-integration/drone/push Build is passing
2021-04-01 21:57:23 +08:00
379e65dafc feat(时区设置): 默认北京时区,支持TZ环境变量
All checks were successful
continuous-integration/drone/push Build is passing
2020-12-26 10:52:32 +08:00
f58a05391e docs(更新文档): 更新文档
All checks were successful
continuous-integration/drone/push Build is passing
2020-12-25 11:41:25 +08:00
594981b87c docs(更新说明): 更新说明 2020-12-25 11:39:38 +08:00
1e9aa6af24 feat(内嵌时区): 内嵌时区
All checks were successful
continuous-integration/drone/push Build is passing
2020-12-24 15:10:34 +08:00
4fac1685b8 fix(修正校验): 修正校验
All checks were successful
continuous-integration/drone/push Build is passing
2020-12-24 11:57:50 +08:00
a7b5361054 feat(错误提示): 添加错误提示
All checks were successful
continuous-integration/drone/push Build is passing
2020-12-24 11:49:24 +08:00
7503222aad docs(更新文档): 更新文档
All checks were successful
continuous-integration/drone/push Build is passing
2020-12-24 11:16:34 +08:00
853b453b04 docs(更新文档): 更新文档 2020-12-24 11:09:31 +08:00
e7f6b296d6 docs(更新文档): 更新文档 2020-12-24 11:08:32 +08:00
7a1e62a43c docs(更新文档): 更新文档 2020-12-24 11:05:03 +08:00
6 changed files with 102 additions and 37 deletions

View File

@ -1,20 +1,32 @@
kind: pipeline
type: docker
name: default
node:
region: cn
steps:
- name: build
pull: if-not-exists
image: xiaoqidun/goenv
image: ccr.ccs.tencentyun.com/xiaoqidun/goenv
commands:
- CGO_ENABLED=0 go build -o gocos -trimpath -ldflags '-s -w' gocos.go
- name: docker
- GOAMD64=v3 CGO_ENABLED=0 go build -o gocos -trimpath -ldflags "-s -w -buildid=" gocos.go
- name: docker-cn
pull: if-not-exists
image: plugins/docker
settings:
repo: xiaoqidun/gocos
repo: ccr.ccs.tencentyun.com/xiaoqidun/gocos
registry: ccr.ccs.tencentyun.com
username:
from_secret: docker_username
password:
from_secret: docker_password
dockerfile: Dockerfile
- name: docker-hk
pull: if-not-exists
image: plugins/docker
settings:
repo: hkccr.ccs.tencentyun.com/xiaoqidun/gocos
registry: hkccr.ccs.tencentyun.com
username:
from_secret: docker_username
password:
from_secret: docker_password
dockerfile: Dockerfile

View File

@ -1,11 +1,11 @@
# 基础镜像
FROM alpine
FROM alpine:3.21.3
# 作者信息
LABEL MAINTAINER="xiaoqidun@gmail.com"
LABEL authors="xiaoqidun"
# 复制程序
COPY gocos /bin/gocos
# 启动命令
ENTRYPOINT /bin/gocos
ENTRYPOINT ["/bin/gocos"]

View File

@ -1,23 +1,51 @@
# gocos
腾讯云对象存储Drone CI插件
# GoCOS
腾讯云对象存储(COS)Drone CI插件[AWS S3](http://plugins.drone.io/drone-plugins/drone-s3/)的COS实现
# Drone CI配置例子
```yml
kind: pipeline
type: docker
name: default
steps:
- name: upload
image: xiaoqidun/gocos
settings:
secret_id:
from_secret: secret_id
secret_key:
from_secret: secret_key
bucket_url:
from_secret: bucket_url
source: build/release
target: build/release
strip_prefix: build/release
- name: upload
image: ccr.ccs.tencentyun.com/xiaoqidun/gocos
settings:
secret_id:
from_secret: secret_id
secret_key:
from_secret: secret_key
bucket_url:
from_secret: bucket_url
source: build/release
target: build/release
strip_prefix: build/release
```
# Drone CI配置说明
### secret_id
API密钥管理获得的SecretId
### secret_key
API密钥管理获得的SecretKey
### bucket_url
存储桶概览中的访问域名
### source
DroneCI中文件的源位置
### target
存储桶中文件的目标位置
### strip_prefix
从文件的源位置剔除前缀

11
go.mod
View File

@ -1,5 +1,12 @@
module github.com/xiaoqidun/gocos
go 1.16
go 1.24.2
require github.com/tencentyun/cos-go-sdk-v5 v0.7.15
require github.com/tencentyun/cos-go-sdk-v5 v0.7.64
require (
github.com/clbanning/mxj v1.8.4 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mozillazg/go-httpheader v0.2.1 // indirect
)

11
go.sum
View File

@ -1,13 +1,20 @@
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ=
github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/tencentyun/cos-go-sdk-v5 v0.7.15 h1:+uKDylojhKkGhBzb8B7J/nIoEl6afGYiJubkVWEctxA=
github.com/tencentyun/cos-go-sdk-v5 v0.7.15/go.mod h1:wQBO5HdAkLjj2q6XQiIfDSP8DXDNrppDRw2Kp/1BODA=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=
github.com/tencentyun/cos-go-sdk-v5 v0.7.64 h1:2ADzzr+hcWl4Fw44DwXe0btlVzAYkdvHQ4glUyR0+mM=
github.com/tencentyun/cos-go-sdk-v5 v0.7.64/go.mod h1:8+hG+mQMuRP/OIS9d83syAvXvrMj9HhkND6Q1fLghw0=

View File

@ -2,6 +2,7 @@ package main
import (
"context"
"errors"
"github.com/tencentyun/cos-go-sdk-v5"
"io/fs"
"log"
@ -10,10 +11,11 @@ import (
"os"
"path/filepath"
"strings"
"time"
_ "time/tzdata"
)
const (
CodeErr = 1
SecretID = "secret_id"
SecretKey = "secret_key"
BucketURL = "bucket_url"
@ -23,6 +25,11 @@ const (
PathSeparator = "/"
)
func ErrExit(err error) {
log.Println(err.Error())
os.Exit(1)
}
func GetConfig(key string) string {
key = "PLUGIN_" + strings.ToUpper(key)
return os.Getenv(key)
@ -48,6 +55,14 @@ func VarIsEmpty(a ...interface{}) bool {
return false
}
func init() {
tz := os.Getenv("TZ")
if tz == "" {
tz = "Asia/Shanghai"
}
time.Local, _ = time.LoadLocation(tz)
}
func main() {
var (
err error
@ -58,9 +73,8 @@ func main() {
target = GetConfig(Target)
stripPrefix = GetConfig(StripPrefix)
)
if !VarIsEmpty(secretID, secretKey, bucketURL, source, target) {
os.Exit(CodeErr)
return
if VarIsEmpty(secretID, secretKey, bucketURL, source, target) {
ErrExit(errors.New("input error"))
}
sourceFiles := make([]string, 0, 0)
if err = filepath.WalkDir(source, func(path string, d fs.DirEntry, err error) error {
@ -69,8 +83,7 @@ func main() {
}
return nil
}); err != nil {
os.Exit(CodeErr)
return
ErrExit(err)
}
sourceLen := len(sourceFiles)
if sourceLen == 0 {
@ -81,8 +94,7 @@ func main() {
}
u, err := url.Parse(bucketURL)
if err != nil {
os.Exit(CodeErr)
return
ErrExit(err)
}
cosClient := cos.NewClient(
&cos.BaseURL{
@ -105,8 +117,7 @@ func main() {
ACLHeaderOptions: &cos.ACLHeaderOptions{},
ObjectPutHeaderOptions: &cos.ObjectPutHeaderOptions{},
}); err != nil {
os.Exit(CodeErr)
return
ErrExit(err)
}
log.Printf("source:%s target:%s\r\n", local, remote)
}