From 5ecd3598fa6b1b19ebb7aab072faf7e33cad2d8e Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 9 Jan 2019 00:32:13 +0800 Subject: [PATCH 1/2] feat(go): switch dep to go module (#49) as title --- .appveyor.yml | 4 +-- .drone.yml | 23 ++++++------- Gopkg.lock | 94 --------------------------------------------------- Gopkg.toml | 23 ------------- aws.go | 6 ++-- go.mod | 12 +++++++ go.sum | 32 ++++++++++++++++++ main.go | 9 +++-- 8 files changed, 63 insertions(+), 140 deletions(-) delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml create mode 100644 go.mod create mode 100644 go.sum diff --git a/.appveyor.yml b/.appveyor.yml index b2bf601..3c57f4d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -11,6 +11,7 @@ environment: secure: '4YzzahbEiMZQJpOCOd1LAw==' DOCKER_PASSWORD: secure: 'VqO/G3Zfslu6zSLdwHKO+Q==' + GO111MODULE: on install: - ps: | @@ -21,9 +22,6 @@ install: build_script: - ps: | - go get -u github.com/golang/dep/cmd/dep - dep ensure - if ( $env:APPVEYOR_REPO_TAG -eq 'false' ) { go build -ldflags "-X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-s3-sync.exe } else { diff --git a/.drone.yml b/.drone.yml index 3b9d089..0ae1438 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,28 +3,24 @@ workspace: path: src/github.com/drone-plugins/drone-s3-sync pipeline: - deps: - image: golang:1.10 - pull: true - commands: - - go get -u github.com/golang/dep/cmd/dep - - dep ensure - test: - image: golang:1.10 + image: golang:1.11 pull: true + environment: + - GO111MODULE=on commands: - go vet ./... - go test -cover ./... build_linux_amd64: - image: golang:1.10 + image: golang:1.11 pull: true group: build environment: - GOOS=linux - GOARCH=amd64 - CGO_ENABLED=0 + - GO111MODULE=on commands: - | if test "${DRONE_TAG}" = ""; then @@ -34,13 +30,14 @@ pipeline: fi build_linux_i386: - image: golang:1.10 + image: golang:1.11 pull: true group: build environment: - GOOS=linux - GOARCH=386 - CGO_ENABLED=0 + - GO111MODULE=on commands: - | if test "${DRONE_TAG}" = ""; then @@ -50,13 +47,14 @@ pipeline: fi build_linux_arm64: - image: golang:1.10 + image: golang:1.11 pull: true group: build environment: - GOOS=linux - GOARCH=arm64 - CGO_ENABLED=0 + - GO111MODULE=on commands: - | if test "${DRONE_TAG}" = ""; then @@ -66,7 +64,7 @@ pipeline: fi build_linux_arm: - image: golang:1.10 + image: golang:1.11 pull: true group: build environment: @@ -74,6 +72,7 @@ pipeline: - GOARCH=arm - CGO_ENABLED=0 - GOARM=7 + - GO111MODULE=on commands: - | if test "${DRONE_TAG}" = ""; then diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index 1cd0fba..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,94 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/Sirupsen/logrus" - packages = ["."] - revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc" - version = "v1.0.5" - -[[projects]] - name = "github.com/aws/aws-sdk-go" - packages = [ - "aws", - "aws/awserr", - "aws/awsutil", - "aws/client", - "aws/client/metadata", - "aws/corehandlers", - "aws/credentials", - "aws/credentials/ec2rolecreds", - "aws/credentials/endpointcreds", - "aws/credentials/stscreds", - "aws/defaults", - "aws/ec2metadata", - "aws/endpoints", - "aws/request", - "aws/session", - "aws/signer/v4", - "internal/sdkio", - "internal/sdkrand", - "internal/shareddefaults", - "private/protocol", - "private/protocol/query", - "private/protocol/query/queryutil", - "private/protocol/rest", - "private/protocol/restxml", - "private/protocol/xml/xmlutil", - "service/cloudfront", - "service/s3", - "service/sts" - ] - revision = "f0872da8a448f8cb10f4f0c95c2100e4f7356448" - version = "v1.13.16" - -[[projects]] - name = "github.com/go-ini/ini" - packages = ["."] - revision = "6333e38ac20b8949a8dd68baa3650f4dee8f39f0" - version = "v1.33.0" - -[[projects]] - name = "github.com/jmespath/go-jmespath" - packages = ["."] - revision = "0b12d6b5" - -[[projects]] - name = "github.com/joho/godotenv" - packages = ["."] - revision = "a79fa1e548e2c689c241d10173efd51e5d689d5b" - version = "v1.2.0" - -[[projects]] - name = "github.com/ryanuber/go-glob" - packages = ["."] - revision = "572520ed46dbddaed19ea3d9541bdd0494163693" - version = "v0.1" - -[[projects]] - name = "github.com/urfave/cli" - packages = ["."] - revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1" - version = "v1.20.0" - -[[projects]] - branch = "master" - name = "golang.org/x/crypto" - packages = ["ssh/terminal"] - revision = "374053ea96cb300f8671b8d3b07edeeb06e203b4" - -[[projects]] - branch = "master" - name = "golang.org/x/sys" - packages = [ - "unix", - "windows" - ] - revision = "2f1e207ee39ff70f3433e49c6eb52677a515e3b5" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "0ae6c8475682e1b48bad52d2486af272d0903917f02fcfcf214f81c95cf30db3" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index fff4684..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,23 +0,0 @@ -[[constraint]] - name = "github.com/Sirupsen/logrus" - version = "1.0.5" - -[[constraint]] - name = "github.com/aws/aws-sdk-go" - version = "1.13.16" - -[[constraint]] - name = "github.com/joho/godotenv" - version = "1.2.0" - -[[constraint]] - name = "github.com/ryanuber/go-glob" - version = "0.1.0" - -[[constraint]] - name = "github.com/urfave/cli" - version = "1.20.0" - -[prune] - go-tests = true - unused-packages = true diff --git a/aws.go b/aws.go index 1f73899..f5277c5 100644 --- a/aws.go +++ b/aws.go @@ -310,9 +310,9 @@ func (a *AWS) Redirect(path, location string) error { } _, err := a.client.PutObject(&s3.PutObjectInput{ - Bucket: aws.String(p.Bucket), - Key: aws.String(path), - ACL: aws.String("public-read"), + Bucket: aws.String(p.Bucket), + Key: aws.String(path), + ACL: aws.String("public-read"), WebsiteRedirectLocation: aws.String(location), }) return err diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6b5b3a3 --- /dev/null +++ b/go.mod @@ -0,0 +1,12 @@ +module github.com/drone-plugins/drone-s3-sync + +require ( + github.com/aws/aws-sdk-go v1.16.15 + github.com/joho/godotenv v1.3.0 + github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735 + github.com/sirupsen/logrus v1.3.0 + github.com/stretchr/testify v1.3.0 // indirect + github.com/urfave/cli v1.20.0 + golang.org/x/net v0.0.0-20190108150841-be88a9aa50a1 // indirect + golang.org/x/text v0.3.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..fc79b53 --- /dev/null +++ b/go.sum @@ -0,0 +1,32 @@ +github.com/aws/aws-sdk-go v1.16.15 h1:kQyxfRyjAwIYjf0225sn/pn+WAlncKyI8dmT3+ItMFE= +github.com/aws/aws-sdk-go v1.16.15/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735 h1:7YvPJVmEeFHR1Tj9sZEYsmarJEQfMVYpd/Vyy/A8dqE= +github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= +github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME= +github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/net v0.0.0-20190108150841-be88a9aa50a1 h1:GPpXcPUwWLSpS88tNfabqPG/HJ5b2k2yTwzkSx1sf4c= +golang.org/x/net v0.0.0-20190108150841-be88a9aa50a1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/main.go b/main.go index 62930fb..c37ce84 100644 --- a/main.go +++ b/main.go @@ -4,8 +4,8 @@ import ( "fmt" "os" - "github.com/Sirupsen/logrus" "github.com/joho/godotenv" + "github.com/sirupsen/logrus" "github.com/urfave/cli" ) @@ -117,11 +117,10 @@ func main() { Usage: "source env file", }, cli.IntFlag{ - Name: "max-concurrency", - Usage: "customize number concurrent files to process", - Value: 100, + Name: "max-concurrency", + Usage: "customize number concurrent files to process", + Value: 100, EnvVar: "PLUGIN_MAX_CONCURRENCY", - }, } From fcc7aa71fdb95ac7e5ea2f2258b23fd5cbb38a24 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 9 Jan 2019 14:08:40 +0800 Subject: [PATCH 2/2] chore: fix golint error. (#50) --- plugin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.go b/plugin.go index 2834a21..079409c 100644 --- a/plugin.go +++ b/plugin.go @@ -180,7 +180,7 @@ func (p *Plugin) runJobs() { }(j) } - for _ = range p.jobs { + for range p.jobs { r := <-results if r.err != nil { fmt.Printf("ERROR: failed to %s %s to %s: %+v\n", r.j.action, r.j.local, r.j.remote, r.err)