From a5178a89a59a8aa651b9ff26aa5c67a184cbc35f Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 3 May 2022 13:40:39 +0200 Subject: [PATCH] docs: add basic documentation --- _docs/_index.md | 105 ++++++++++++++++++++++++++++++++++++ cmd/drone-s3-sync/config.go | 19 +++---- plugin/impl.go | 6 --- 3 files changed, 112 insertions(+), 18 deletions(-) create mode 100644 _docs/_index.md diff --git a/_docs/_index.md b/_docs/_index.md new file mode 100644 index 0000000..f054444 --- /dev/null +++ b/_docs/_index.md @@ -0,0 +1,105 @@ +--- +title: drone-s3-sync +--- + +[![Build Status](https://img.shields.io/drone/build/thegeeklab/drone-s3-sync?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/drone-s3-sync) +[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/drone-s3-sync) +[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/drone-s3-sync) +[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/drone-s3-sync)](https://github.com/thegeeklab/drone-s3-sync/graphs/contributors) +[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/drone-s3-sync) +[![License: MIT](https://img.shields.io/github/license/thegeeklab/drone-s3-sync)](https://github.com/thegeeklab/drone-s3-sync/blob/main/LICENSE) + +Drone plugin to synchronize a directory with an S3 bucket. + + + +{{< toc >}} + + + +## Build + +Build the binary with the following command: + +```Shell +export GOOS=linux +export GOARCH=amd64 +export CGO_ENABLED=0 +export GO111MODULE=on + +make build +``` + +Build the Docker image with the following command: + +```Shell +docker build --file docker/Dockerfile.amd64 --tag thegeeklab/drone-s3-sync . +``` + +## Usage + +```Shell +docker run --rm \ + -e PLUGIN_BUCKET=my_bucket \ + -e AWS_ACCESS_KEY_ID=abc123 \ + -e AWS_SECRET_ACCESS_KEY=xyc789 \ + -v $(pwd):$(pwd) \ + -w $(pwd) \ + thegeeklab/drone-s3-sync +``` + +### Parameters + +endpoint +: endpoint for the s3 connection + +access-key +: s3 access key + +secret-key +: s3 secret key + +path-style +: use path style for bucket paths + +bucket +: name of the bucket + +region +: s3 region (default `us-east-1`) + +source +: upload source path (default `.`) + +target +: target path (default `/`) + +delete +: delete locally removed files from the target + +access +: access control settings + +content-type +: content-type settings for uploads + +content-encoding +: content-encoding settings for uploads + +cache_control +: cache-control settings for uploads + +metadata +: additional metadata for uploads + +redirects +: redirects to create + +cloudfront-distribution +: id of cloudfront distribution to invalidate + +dry_run +: dry run disables api calls + +max_concurrency +: customize number concurrent files to process (default `100`) diff --git a/cmd/drone-s3-sync/config.go b/cmd/drone-s3-sync/config.go index 6e775fa..7166ea8 100644 --- a/cmd/drone-s3-sync/config.go +++ b/cmd/drone-s3-sync/config.go @@ -11,19 +11,19 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag { &cli.StringFlag{ Name: "endpoint", Usage: "endpoint for the s3 connection", - EnvVars: []string{"PLUGIN_ENDPOINT", "S3_SYNC_ENDPOINT", "S3_ENDPOINT"}, + EnvVars: []string{"PLUGIN_ENDPOINT", "S3_ENDPOINT"}, Destination: &settings.Endpoint, }, &cli.StringFlag{ Name: "access-key", - Usage: "aws access key", - EnvVars: []string{"PLUGIN_ACCESS_KEY", "AWS_ACCESS_KEY_ID"}, + Usage: "s3 access key", + EnvVars: []string{"PLUGIN_ACCESS_KEY", "S3_ACCESS_KEY"}, Destination: &settings.AccessKey, }, &cli.StringFlag{ Name: "secret-key", - Usage: "aws secret key", - EnvVars: []string{"PLUGIN_SECRET_KEY", "AWS_SECRET_ACCESS_KEY"}, + Usage: "s3 secret key", + EnvVars: []string{"PLUGIN_SECRET_KEY", "S3_SECRET_KEY"}, Destination: &settings.SecretKey, }, &cli.BoolFlag{ @@ -34,13 +34,13 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag { }, &cli.StringFlag{ Name: "bucket", - Usage: "name of bucket", + Usage: "name of the bucket", EnvVars: []string{"PLUGIN_BUCKET"}, Destination: &settings.Bucket, }, &cli.StringFlag{ Name: "region", - Usage: "aws region", + Usage: "s3 region", Value: "us-east-1", EnvVars: []string{"PLUGIN_REGION"}, Destination: &settings.Region, @@ -113,11 +113,6 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag { EnvVars: []string{"DRY_RUN", "PLUGIN_DRY_RUN"}, Destination: &settings.DryRun, }, - &cli.StringFlag{ - Name: "env-file", - Usage: "source env file", - Destination: &settings.EnvFile, - }, &cli.IntFlag{ Name: "max-concurrency", Usage: "customize number concurrent files to process", diff --git a/plugin/impl.go b/plugin/impl.go index e192b99..0a2a6aa 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -6,7 +6,6 @@ import ( "path/filepath" "strings" - "github.com/joho/godotenv" "github.com/sirupsen/logrus" ) @@ -32,7 +31,6 @@ type Settings struct { Client AWS Jobs []Job MaxConcurrency int - EnvFile string } type Job struct { @@ -66,10 +64,6 @@ func (p *Plugin) Validate() error { // Execute provides the implementation of the plugin. func (p *Plugin) Execute() error { - if p.settings.EnvFile != "" { - _ = godotenv.Load(p.settings.EnvFile) - } - p.settings.Jobs = make([]Job, 1) p.settings.Client = NewAWS(p)