diff --git a/.cfignore b/.cfignore index 93d1107..069a7a0 100644 --- a/.cfignore +++ b/.cfignore @@ -1,5 +1,5 @@ /* -!/s3manager +!/bin/s3manager !/web/ !/deployments/cf/ diff --git a/.gitignore b/.gitignore index 0b36a85..18b166a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Binaries for programs and plugins -/s3manager +bin/ *.exe *.exe~ *.dll diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..9755621 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,17 @@ +linters: + enable-all: true + disable: + - lll + - dupl + - scopelint + +linters-settings: + govet: + check-shadowing: true + maligned: + suggest-new: true + misspell: + locale: US + gocritic: + disabled-checks: + - unlambda # Until https://github.com/go-critic/go-critic/issues/716 is fixed diff --git a/.travis.yml b/.travis.yml index 4efc69b..18275f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,7 @@ env: - GO111MODULE=on before_install: - - go get -u github.com/golangci/golangci-lint/cmd/golangci-lint - - go get -u github.com/go-critic/go-critic/... + - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin install: - go mod download diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4a1c668 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM golang:1 as builder +WORKDIR /usr/src/app +COPY . ./ +RUN CGO_ENABLED=0 go build -ldflags="-s -w" -a -installsuffix cgo -o bin/s3manager ./cmd/s3manager + +FROM scratch +WORKDIR /usr/app +COPY --from=builder /usr/src/app/bin/s3manager ./ +COPY --from=builder /usr/src/app/web ./ +EXPOSE 8080 +ENTRYPOINT ["./s3manager"] + diff --git a/Makefile b/Makefile index eac9678..d264124 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,20 @@ -.PHONY: all lint test build-docker deploy-cf +.PHONY: all lint test build-docker deploy-cf clean all: - go build ./cmd/s3manager + go build -o bin/s3manager ./cmd/s3manager lint: - golangci-lint run --enable-all --disable lll - gocritic check-project . + golangci-lint run test: go test -race -cover ./... build-docker: - docker build -f build/docker/Dockerfile -t s3manager . + docker build -t s3manager . deploy-cf: - GOOS=linux go build -ldflags="-s -w" ./cmd/s3manager + GOOS=linux go build -ldflags="-s -w" -o bin/s3manager ./cmd/s3manager cf push -f deployments/cf/manifest.yml + +clean: + rm -rf bin/* diff --git a/README.md b/README.md index f5de6e5..f969549 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ A Web GUI written in Go to manage S3 buckets from any provider. ## Build Docker Image +The image is available on [Docker Hub](https://hub.docker.com/r/mastertinner/s3manager/) + 1. Run `make build-docker` ## Run on Cloud Foundry diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile deleted file mode 100644 index d72b4a5..0000000 --- a/build/docker/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM golang:1 - -WORKDIR /app -COPY . . - -RUN go build -ldflags="-s -w" ./cmd/s3manager - -EXPOSE 8080 - -ENTRYPOINT ["./s3manager"] diff --git a/go.mod b/go.mod index 062fcb4..0a5a8a7 100644 --- a/go.mod +++ b/go.mod @@ -2,17 +2,17 @@ module github.com/mastertinner/s3manager require ( github.com/go-ini/ini v1.39.0 // indirect - github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect + github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect github.com/jtolds/gls v4.2.1+incompatible // indirect - github.com/mastertinner/adapters v0.0.0-20181023191747-06c362ad5906 + github.com/mastertinner/adapters v0.0.0-20181121203223-10e5e0d7f25e github.com/matryer/is v1.2.0 github.com/matryer/way v0.0.0-20180416093233-9632d0c407b0 - github.com/minio/minio-go v6.0.8+incompatible + github.com/minio/minio-go v6.0.10+incompatible github.com/mitchellh/go-homedir v1.0.0 // indirect github.com/pkg/errors v0.8.0 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect - github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a // indirect - golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e // indirect - golang.org/x/sys v0.0.0-20181023152157-44b849a8bc13 // indirect + github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c // indirect + golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85 // indirect + golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 // indirect gopkg.in/ini.v1 v1.39.0 // indirect ) diff --git a/go.sum b/go.sum index c0ec757..dae2ea6 100644 --- a/go.sum +++ b/go.sum @@ -2,37 +2,37 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/go-ini/ini v1.39.0 h1:/CyW/jTlZLjuzy52jc1XnhJm6IUKEuunpJFpecywNeI= github.com/go-ini/ini v1.39.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg= +github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/mastertinner/adapters v0.0.0-20181023191747-06c362ad5906 h1:ARlgzlesbqKoOwS564hoi4Mm0Qsb14Op+g3YOwEPYY4= -github.com/mastertinner/adapters v0.0.0-20181023191747-06c362ad5906/go.mod h1:QBIsA5vS5xigujCa9GeHCjoKanlDQ70rmwCGoJkfioQ= +github.com/mastertinner/adapters v0.0.0-20181121203223-10e5e0d7f25e h1:QjLE1u6V1cU2IHKtRKS96Z/Ms4HWlCIBrpw4G5n+1R8= +github.com/mastertinner/adapters v0.0.0-20181121203223-10e5e0d7f25e/go.mod h1:YMSBjFFDhNq6yjZWw6yvZxcUAdi52OJ2likfIfcvp7Y= github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/matryer/way v0.0.0-20180416093233-9632d0c407b0 h1:KWiqy3hl8yCUPAq1frD0DKXKyn7d9h2nVhj2r5ISq2o= github.com/matryer/way v0.0.0-20180416093233-9632d0c407b0/go.mod h1:stiJZfMq1xZPqvIyt2VsYMgLul8vf1nmL0D3KU70dEc= -github.com/minio/minio-go v6.0.8+incompatible h1:RBJrzsmxk259C1CvZ9clro73HBPA3zBwFwVePlkom78= -github.com/minio/minio-go v6.0.8+incompatible/go.mod h1:7guKYtitv8dktvNUGrhzmNlA5wrAABTQXCoesZdFQO8= +github.com/minio/minio-go v6.0.10+incompatible h1:cAdZRAXBaqI0hU06emlG+6S3wAh52Wr3xRtCK3R7EHc= +github.com/minio/minio-go v6.0.10+incompatible/go.mod h1:7guKYtitv8dktvNUGrhzmNlA5wrAABTQXCoesZdFQO8= github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a h1:JSvGDIbmil4Ui/dDdFBExb7/cmkNjyX5F97oglmvCDo= -github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= -golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e h1:IzypfodbhbnViNUO/MEh0FzCUooG97cIGfdggUrUSyU= -golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c h1:Ho+uVpkel/udgjbwB5Lktg9BtvJSh2DT0Hi6LPSyI2w= +github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= +golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85 h1:et7+NAX3lLIk5qUCTA9QelBjGE/NkhzYw/mhnr0s7nI= +golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519 h1:x6rhz8Y9CjbgQkccRGmELH6K+LJj7tOoh3XWeC1yaQM= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20181023152157-44b849a8bc13 h1:ICvJQ9FL9kAAfwGwpoAmcE1O51M0zE++iVRxQ3xyiGE= -golang.org/x/sys v0.0.0-20181023152157-44b849a8bc13/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a h1:gOpx8G595UYyvj8UK4+OFyY4rx037g3fmfhe5SasG3U= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU= +golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/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= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/ini.v1 v1.39.0 h1:Jf2sFGT+sAd7i+4ftUN1Jz90uw8XNH8NXbbOY16taA8= gopkg.in/ini.v1 v1.39.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=