Allow to use non-encrypted connections
This commit is contained in:
parent
b76a60f6a6
commit
2b297148bd
9 changed files with 100 additions and 53 deletions
18
.github/workflows/main.yml
vendored
Normal file
18
.github/workflows/main.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
name: Lint and Test
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: "1.14"
|
||||
- name: Lint
|
||||
uses: reviewdog/action-golangci-lint@v1
|
||||
- name: Test
|
||||
run: make test
|
||||
- name: Build
|
||||
run: make build
|
18
.travis.yml
18
.travis.yml
|
@ -1,18 +0,0 @@
|
|||
language: go
|
||||
|
||||
go:
|
||||
- stable
|
||||
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
|
||||
before_install:
|
||||
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin
|
||||
|
||||
install:
|
||||
- go mod download
|
||||
|
||||
script:
|
||||
- make lint
|
||||
- make test
|
||||
- make
|
13
Dockerfile
13
Dockerfile
|
@ -1,13 +1,14 @@
|
|||
FROM golang:1 as builder
|
||||
RUN groupadd -r s3manager && useradd --no-log-init -r -g s3manager s3manager
|
||||
WORKDIR /usr/src/s3manager
|
||||
FROM golang:1 AS builder
|
||||
RUN groupadd -r app && useradd --no-log-init -r -g app app
|
||||
WORKDIR /app
|
||||
COPY . ./
|
||||
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -a -installsuffix cgo -o bin/s3manager ./cmd/s3manager
|
||||
|
||||
FROM scratch
|
||||
WORKDIR /usr/s3manager
|
||||
COPY --from=builder /usr/src/s3manager/bin/s3manager /usr/src/s3manager/web ./
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/bin/s3manager /app/web ./
|
||||
COPY --from=builder /app/web ./web/
|
||||
COPY --from=builder /etc/passwd /etc/passwd
|
||||
USER s3manager
|
||||
USER app
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["./s3manager"]
|
||||
|
|
35
README.md
35
README.md
|
@ -1,7 +1,7 @@
|
|||
# S3 Manager
|
||||
|
||||
[![Go Report Card](https://goreportcard.com/badge/github.com/mastertinner/s3manager?style=flat-square)](https://goreportcard.com/report/github.com/mastertinner/s3manager)
|
||||
[![Build Status](https://img.shields.io/travis/mastertinner/s3manager.svg?style=flat-square)](https://travis-ci.org/mastertinner/s3manager)
|
||||
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fmastertinner%2Fs3manager%2Fbadge&style=flat-square)](https://github.com/mastertinner/s3manager/actions)
|
||||
[![Docker Build](https://img.shields.io/docker/cloud/build/mastertinner/s3manager.svg?style=flat-square)](https://hub.docker.com/r/mastertinner/s3manager)
|
||||
|
||||
A Web GUI written in Go to manage S3 buckets from any provider.
|
||||
|
@ -10,31 +10,46 @@ A Web GUI written in Go to manage S3 buckets from any provider.
|
|||
|
||||
## Usage
|
||||
|
||||
### Configuration
|
||||
|
||||
The application can be configured with the following environment variables:
|
||||
|
||||
- `ENDPOINT`: The endpoint of your S3 server (defaults to `s3.amazonaws.com`)
|
||||
- `ACCESS_KEY_ID`: Your S3 access key ID (required)
|
||||
- `SECRET_ACCESS_KEY`: Your S3 secret access key (required)
|
||||
- `PORT`: The port the app should listen on (defaults to `8080`)
|
||||
- `USE_SSL`: Whether your S3 server uses SSL or not (defaults to `true`)
|
||||
- `PORT`: The port the s3manager app should listen on (defaults to `8080`)
|
||||
|
||||
Then simply run the binary.
|
||||
|
||||
## Build and Run Locally
|
||||
### Build and Run Locally
|
||||
|
||||
1. Run `make build`
|
||||
1. Execute the created binary and visit <http://localhost:8080>
|
||||
|
||||
## Run Tests
|
||||
### Deploy to Cloud Foundry
|
||||
|
||||
1. Modify `deployments/cf/*` to your liking
|
||||
1. Run `make deploy-cf`
|
||||
|
||||
## Development
|
||||
|
||||
### Lint Code
|
||||
|
||||
1. Run `make lint`
|
||||
|
||||
### Run Tests
|
||||
|
||||
1. Run `make test`
|
||||
|
||||
## Build Docker Image
|
||||
### Build Docker Image
|
||||
|
||||
The image is available on [Docker Hub](https://hub.docker.com/r/mastertinner/s3manager/)
|
||||
|
||||
1. Run `make build-docker`
|
||||
|
||||
## Deploy to Cloud Foundry
|
||||
### Run Locally for Testing
|
||||
|
||||
1. Modify `deployments/cf/*` to your liking
|
||||
1. Run `make deploy-cf`
|
||||
There is an example [docker-compose.yml](https://github.com/mastertinner/s3manager/blob/master/docker-compose.yml) file that spins up an S3 service and the s3manager. You can try it by issuing the following command:
|
||||
|
||||
```shell
|
||||
$ docker-compose up
|
||||
```
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/mastertinner/adapters/logging"
|
||||
"github.com/mastertinner/s3manager/internal/app/s3manager"
|
||||
|
@ -26,6 +27,11 @@ func main() {
|
|||
if !ok {
|
||||
log.Fatal("please provide SECRET_ACCESS_KEY")
|
||||
}
|
||||
useSSLEnvVar, ok := os.LookupEnv("USE_SSL")
|
||||
if !ok {
|
||||
useSSLEnvVar = "true"
|
||||
}
|
||||
useSSL := strings.ToLower(useSSLEnvVar) == "true"
|
||||
port, ok := os.LookupEnv("PORT")
|
||||
if !ok {
|
||||
port = "8080"
|
||||
|
@ -34,7 +40,7 @@ func main() {
|
|||
tmplDir := filepath.Join("web", "template")
|
||||
|
||||
// Set up S3 client
|
||||
s3, err := minio.New(endpoint, accessKeyID, secretAccessKey, true)
|
||||
s3, err := minio.New(endpoint, accessKeyID, secretAccessKey, useSSL)
|
||||
if err != nil {
|
||||
log.Fatalln(fmt.Errorf("error creating s3 client: %w", err))
|
||||
}
|
||||
|
|
19
docker-compose.yml
Normal file
19
docker-compose.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
version: "3"
|
||||
services:
|
||||
s3:
|
||||
image: minio/minio
|
||||
command: server /data
|
||||
environment:
|
||||
- MINIO_ACCESS_KEY=s3manager
|
||||
- MINIO_SECRET_KEY=s3manager
|
||||
s3manager:
|
||||
build: .
|
||||
ports:
|
||||
- 8080:8080
|
||||
environment:
|
||||
- ENDPOINT=s3:9000
|
||||
- ACCESS_KEY_ID=s3manager
|
||||
- SECRET_ACCESS_KEY=s3manager
|
||||
- USE_SSL=false
|
||||
depends_on:
|
||||
- s3
|
11
go.mod
11
go.mod
|
@ -3,16 +3,17 @@ module github.com/mastertinner/s3manager
|
|||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/go-ini/ini v1.55.0 // indirect
|
||||
github.com/go-ini/ini v1.56.0 // indirect
|
||||
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
|
||||
github.com/mastertinner/adapters v0.0.0-20200501180223-a43a05f61f85
|
||||
github.com/mastertinner/adapters v0.0.0-20200520112657-282882bd18d7
|
||||
github.com/matryer/is v1.3.0
|
||||
github.com/matryer/way v0.0.0-20180416093233-9632d0c407b0
|
||||
github.com/minio/minio-go v6.0.14+incompatible
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/smartystreets/assertions v1.1.0 // indirect
|
||||
github.com/smartystreets/goconvey v1.6.4 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 // indirect
|
||||
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 // indirect
|
||||
gopkg.in/ini.v1 v1.55.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 // indirect
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect
|
||||
gopkg.in/ini.v1 v1.56.0 // indirect
|
||||
)
|
||||
|
|
29
go.sum
29
go.sum
|
@ -1,7 +1,7 @@
|
|||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/go-ini/ini v1.55.0 h1:0wVcG9udk2C3TGgmdIGKK9ScOZHZB5nbG+gwji9fhhc=
|
||||
github.com/go-ini/ini v1.55.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
github.com/go-ini/ini v1.56.0 h1:6HjxSjqdmgnujDPhlzR4a44lxK3w03WPN8te0SoUSeM=
|
||||
github.com/go-ini/ini v1.56.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
|
@ -9,17 +9,19 @@ github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:x
|
|||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
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-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/mastertinner/adapters v0.0.0-20200501180223-a43a05f61f85 h1:upp4GHgTZgr8hSSZKp1cqtBgRayYKEGzp+KyxUeFrOY=
|
||||
github.com/mastertinner/adapters v0.0.0-20200501180223-a43a05f61f85/go.mod h1:mKxzM+XQeHujlYJz0UKtJ3mZvNWGjTpjqitbDCAK1mE=
|
||||
github.com/mastertinner/adapters v0.0.0-20200520112657-282882bd18d7 h1:jxlDYusV3HaidpeyqvJNjii5GurLQwG1i28XAA1Ob/0=
|
||||
github.com/mastertinner/adapters v0.0.0-20200520112657-282882bd18d7/go.mod h1:PR6FxcZO6b9xDwrgGg7ncH6cqdTRTPye9iky4lvMs/4=
|
||||
github.com/matryer/is v1.3.0 h1:9qiso3jaJrOe6qBRJRBt2Ldht05qDiFP9le0JOIhRSI=
|
||||
github.com/matryer/is v1.3.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
|
||||
github.com/matryer/way v0.0.0-20180416093233-9632d0c407b0 h1:KWiqy3hl8yCUPAq1frD0DKXKyn7d9h2nVhj2r5ISq2o=
|
||||
|
@ -36,23 +38,25 @@ github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIK
|
|||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 h1:IaQbIIB2X/Mp/DKctl6ROxz1KyMlKp4uyvL6+kQ7C88=
|
||||
golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 h1:cg5LA/zNPRzIXIWSCxQW10Rvpy94aQh3LT/ShoCpkHw=
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 h1:WQ8q63x+f/zpC8Ac1s9wLElVoHhm32p6tudrU72n1QA=
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 h1:eDrdRpKgkcCqKZQwyZRyeFZgfqt37SL7Kv3tok06cKE=
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 h1:5B6i6EAiSYyejWfvc5Rc9BbI3rzIsrrXfAQBWnYfn+w=
|
||||
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121 h1:rITEj+UZHYC927n8GT97eC3zrpzXdb/voyeOuVKS46o=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
|
@ -66,5 +70,6 @@ google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ
|
|||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
gopkg.in/ini.v1 v1.55.0 h1:E8yzL5unfpW3M6fz/eB7Cb5MQAYSZ7GKo4Qth+N2sgQ=
|
||||
gopkg.in/ini.v1 v1.55.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/ini.v1 v1.56.0 h1:DPMeDvGTM54DXbPkVIZsp19fp/I2K7zwA/itHYHKo8Y=
|
||||
gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
|
|
|
@ -4,5 +4,5 @@ import "errors"
|
|||
|
||||
var (
|
||||
errS3 = errors.New("mocked s3 error")
|
||||
errBucketDoesNotExist = errors.New("The specified bucket does not exist") // nolint: stylecheck
|
||||
errBucketDoesNotExist = errors.New("The specified bucket does not exist") //nolint:stylecheck
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue