mirror of
https://github.com/thegeeklab/drone-s3-sync.git
synced 2024-07-02 21:00:51 +02:00
Compare commits
No commits in common. "main" and "v2.0.2" have entirely different histories.
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!dist/
|
352
.drone.jsonnet
Normal file
352
.drone.jsonnet
Normal file
|
@ -0,0 +1,352 @@
|
||||||
|
local PipelineTest = {
|
||||||
|
kind: 'pipeline',
|
||||||
|
name: 'test',
|
||||||
|
platform: {
|
||||||
|
os: 'linux',
|
||||||
|
arch: 'amd64',
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
name: 'deps',
|
||||||
|
image: 'golang:1.18',
|
||||||
|
commands: [
|
||||||
|
'make deps',
|
||||||
|
],
|
||||||
|
volumes: [
|
||||||
|
{
|
||||||
|
name: 'godeps',
|
||||||
|
path: '/go',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'lint',
|
||||||
|
image: 'golang:1.18',
|
||||||
|
commands: [
|
||||||
|
'make lint',
|
||||||
|
],
|
||||||
|
volumes: [
|
||||||
|
{
|
||||||
|
name: 'godeps',
|
||||||
|
path: '/go',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test',
|
||||||
|
image: 'golang:1.18',
|
||||||
|
commands: [
|
||||||
|
'make test',
|
||||||
|
],
|
||||||
|
volumes: [
|
||||||
|
{
|
||||||
|
name: 'godeps',
|
||||||
|
path: '/go',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
volumes: [
|
||||||
|
{
|
||||||
|
name: 'godeps',
|
||||||
|
temp: {},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
local PipelineBuildBinaries = {
|
||||||
|
kind: 'pipeline',
|
||||||
|
name: 'build-binaries',
|
||||||
|
platform: {
|
||||||
|
os: 'linux',
|
||||||
|
arch: 'amd64',
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
name: 'build',
|
||||||
|
image: 'techknowlogick/xgo:go-1.18.x',
|
||||||
|
commands: [
|
||||||
|
'make release',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'executable',
|
||||||
|
image: 'alpine',
|
||||||
|
commands: [
|
||||||
|
'$(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'changelog-generate',
|
||||||
|
image: 'thegeeklab/git-chglog',
|
||||||
|
commands: [
|
||||||
|
'git fetch -tq',
|
||||||
|
'git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'changelog-format',
|
||||||
|
image: 'thegeeklab/alpine-tools',
|
||||||
|
commands: [
|
||||||
|
'prettier CHANGELOG.md',
|
||||||
|
'prettier -w CHANGELOG.md',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'publish',
|
||||||
|
image: 'plugins/github-release',
|
||||||
|
settings: {
|
||||||
|
overwrite: true,
|
||||||
|
api_key: {
|
||||||
|
from_secret: 'github_token',
|
||||||
|
},
|
||||||
|
files: ['dist/*'],
|
||||||
|
title: '${DRONE_TAG}',
|
||||||
|
note: 'CHANGELOG.md',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
ref: [
|
||||||
|
'refs/tags/**',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
depends_on: [
|
||||||
|
'test',
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
local PipelineBuildContainer(arch='amd64') = {
|
||||||
|
kind: 'pipeline',
|
||||||
|
name: 'build-container-' + arch,
|
||||||
|
platform: {
|
||||||
|
os: 'linux',
|
||||||
|
arch: arch,
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
name: 'build',
|
||||||
|
image: 'golang:1.18',
|
||||||
|
commands: [
|
||||||
|
'make build',
|
||||||
|
'ls -l dist/drone-s3-sync',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'dryrun',
|
||||||
|
image: 'thegeeklab/drone-docker:19',
|
||||||
|
settings: {
|
||||||
|
dry_run: true,
|
||||||
|
dockerfile: 'docker/Dockerfile.' + arch,
|
||||||
|
repo: 'thegeeklab/${DRONE_REPO_NAME}',
|
||||||
|
},
|
||||||
|
depends_on: ['build'],
|
||||||
|
when: {
|
||||||
|
ref: ['refs/pull/**'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'publish-dockerhub',
|
||||||
|
image: 'thegeeklab/drone-docker:19',
|
||||||
|
settings: {
|
||||||
|
auto_tag: true,
|
||||||
|
auto_tag_suffix: arch,
|
||||||
|
dockerfile: 'docker/Dockerfile.' + arch,
|
||||||
|
repo: 'thegeeklab/${DRONE_REPO_NAME}',
|
||||||
|
username: { from_secret: 'docker_username' },
|
||||||
|
password: { from_secret: 'docker_password' },
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**'],
|
||||||
|
},
|
||||||
|
depends_on: ['dryrun'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'publish-quay',
|
||||||
|
image: 'thegeeklab/drone-docker:19',
|
||||||
|
settings: {
|
||||||
|
auto_tag: true,
|
||||||
|
auto_tag_suffix: arch,
|
||||||
|
dockerfile: 'docker/Dockerfile.' + arch,
|
||||||
|
registry: 'quay.io',
|
||||||
|
repo: 'quay.io/thegeeklab/${DRONE_REPO_NAME}',
|
||||||
|
username: { from_secret: 'quay_username' },
|
||||||
|
password: { from_secret: 'quay_password' },
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**'],
|
||||||
|
},
|
||||||
|
depends_on: ['dryrun'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
depends_on: [
|
||||||
|
'test',
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
local PipelineDocs = {
|
||||||
|
kind: 'pipeline',
|
||||||
|
name: 'docs',
|
||||||
|
platform: {
|
||||||
|
os: 'linux',
|
||||||
|
arch: 'amd64',
|
||||||
|
},
|
||||||
|
concurrency: {
|
||||||
|
limit: 1,
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
name: 'markdownlint',
|
||||||
|
image: 'thegeeklab/markdownlint-cli',
|
||||||
|
commands: [
|
||||||
|
"markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'spellcheck',
|
||||||
|
image: 'node:lts-alpine',
|
||||||
|
commands: [
|
||||||
|
'npm install -g spellchecker-cli',
|
||||||
|
"spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions",
|
||||||
|
],
|
||||||
|
environment: {
|
||||||
|
FORCE_COLOR: true,
|
||||||
|
NPM_CONFIG_LOGLEVEL: 'error',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'publish',
|
||||||
|
image: 'plugins/gh-pages',
|
||||||
|
settings: {
|
||||||
|
username: { from_secret: 'github_username' },
|
||||||
|
password: { from_secret: 'github_token' },
|
||||||
|
pages_directory: '_docs/',
|
||||||
|
target_branch: 'docs',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
ref: ['refs/heads/main'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
depends_on: [
|
||||||
|
'build-binaries',
|
||||||
|
'build-container-amd64',
|
||||||
|
'build-container-arm64',
|
||||||
|
'build-container-arm',
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
local PipelineNotifications = {
|
||||||
|
kind: 'pipeline',
|
||||||
|
name: 'notifications',
|
||||||
|
platform: {
|
||||||
|
os: 'linux',
|
||||||
|
arch: 'amd64',
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
image: 'plugins/manifest',
|
||||||
|
name: 'manifest-dockerhub',
|
||||||
|
settings: {
|
||||||
|
ignore_missing: true,
|
||||||
|
auto_tag: true,
|
||||||
|
username: { from_secret: 'docker_username' },
|
||||||
|
password: { from_secret: 'docker_password' },
|
||||||
|
spec: 'docker/manifest.tmpl',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
status: ['success'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
image: 'plugins/manifest',
|
||||||
|
name: 'manifest-quay',
|
||||||
|
settings: {
|
||||||
|
ignore_missing: true,
|
||||||
|
auto_tag: true,
|
||||||
|
username: { from_secret: 'quay_username' },
|
||||||
|
password: { from_secret: 'quay_password' },
|
||||||
|
spec: 'docker/manifest-quay.tmpl',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
status: ['success'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pushrm-dockerhub',
|
||||||
|
image: 'chko/docker-pushrm:1',
|
||||||
|
environment: {
|
||||||
|
DOCKER_PASS: {
|
||||||
|
from_secret: 'docker_password',
|
||||||
|
},
|
||||||
|
DOCKER_USER: {
|
||||||
|
from_secret: 'docker_username',
|
||||||
|
},
|
||||||
|
PUSHRM_FILE: 'README.md',
|
||||||
|
PUSHRM_SHORT: 'Drone plugin to synchronize a directory with an S3 bucket',
|
||||||
|
PUSHRM_TARGET: 'thegeeklab/${DRONE_REPO_NAME}',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
status: ['success'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pushrm-quay',
|
||||||
|
image: 'chko/docker-pushrm:1',
|
||||||
|
environment: {
|
||||||
|
APIKEY__QUAY_IO: {
|
||||||
|
from_secret: 'quay_token',
|
||||||
|
},
|
||||||
|
PUSHRM_FILE: 'README.md',
|
||||||
|
PUSHRM_TARGET: 'quay.io/thegeeklab/${DRONE_REPO_NAME}',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
status: ['success'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'matrix',
|
||||||
|
image: 'thegeeklab/drone-matrix',
|
||||||
|
settings: {
|
||||||
|
homeserver: { from_secret: 'matrix_homeserver' },
|
||||||
|
roomid: { from_secret: 'matrix_roomid' },
|
||||||
|
template: 'Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}',
|
||||||
|
username: { from_secret: 'matrix_username' },
|
||||||
|
password: { from_secret: 'matrix_password' },
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
status: ['success', 'failure'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
depends_on: [
|
||||||
|
'docs',
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**'],
|
||||||
|
status: ['success', 'failure'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
[
|
||||||
|
PipelineTest,
|
||||||
|
PipelineBuildBinaries,
|
||||||
|
PipelineBuildContainer(arch='amd64'),
|
||||||
|
PipelineBuildContainer(arch='arm64'),
|
||||||
|
PipelineBuildContainer(arch='arm'),
|
||||||
|
PipelineDocs,
|
||||||
|
PipelineNotifications,
|
||||||
|
]
|
462
.drone.yml
Normal file
462
.drone.yml
Normal file
|
@ -0,0 +1,462 @@
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: test
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: deps
|
||||||
|
image: golang:1.18
|
||||||
|
commands:
|
||||||
|
- make deps
|
||||||
|
volumes:
|
||||||
|
- name: godeps
|
||||||
|
path: /go
|
||||||
|
|
||||||
|
- name: lint
|
||||||
|
image: golang:1.18
|
||||||
|
commands:
|
||||||
|
- make lint
|
||||||
|
volumes:
|
||||||
|
- name: godeps
|
||||||
|
path: /go
|
||||||
|
|
||||||
|
- name: test
|
||||||
|
image: golang:1.18
|
||||||
|
commands:
|
||||||
|
- make test
|
||||||
|
volumes:
|
||||||
|
- name: godeps
|
||||||
|
path: /go
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: godeps
|
||||||
|
temp: {}
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
- refs/pull/**
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: build-binaries
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: techknowlogick/xgo:go-1.18.x
|
||||||
|
commands:
|
||||||
|
- make release
|
||||||
|
|
||||||
|
- name: executable
|
||||||
|
image: alpine
|
||||||
|
commands:
|
||||||
|
- $(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help
|
||||||
|
|
||||||
|
- name: changelog-generate
|
||||||
|
image: thegeeklab/git-chglog
|
||||||
|
commands:
|
||||||
|
- git fetch -tq
|
||||||
|
- git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}
|
||||||
|
|
||||||
|
- name: changelog-format
|
||||||
|
image: thegeeklab/alpine-tools
|
||||||
|
commands:
|
||||||
|
- prettier CHANGELOG.md
|
||||||
|
- prettier -w CHANGELOG.md
|
||||||
|
|
||||||
|
- name: publish
|
||||||
|
image: plugins/github-release
|
||||||
|
settings:
|
||||||
|
api_key:
|
||||||
|
from_secret: github_token
|
||||||
|
files:
|
||||||
|
- dist/*
|
||||||
|
note: CHANGELOG.md
|
||||||
|
overwrite: true
|
||||||
|
title: ${DRONE_TAG}
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/tags/**
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
- refs/pull/**
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- test
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: build-container-amd64
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: golang:1.18
|
||||||
|
commands:
|
||||||
|
- make build
|
||||||
|
- ls -l dist/drone-s3-sync
|
||||||
|
|
||||||
|
- name: dryrun
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
dockerfile: docker/Dockerfile.amd64
|
||||||
|
dry_run: true
|
||||||
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/pull/**
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
|
|
||||||
|
- name: publish-dockerhub
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: amd64
|
||||||
|
dockerfile: docker/Dockerfile.amd64
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
|
- dryrun
|
||||||
|
|
||||||
|
- name: publish-quay
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: amd64
|
||||||
|
dockerfile: docker/Dockerfile.amd64
|
||||||
|
password:
|
||||||
|
from_secret: quay_password
|
||||||
|
registry: quay.io
|
||||||
|
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
username:
|
||||||
|
from_secret: quay_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
|
- dryrun
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
- refs/pull/**
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- test
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: build-container-arm64
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: arm64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: golang:1.18
|
||||||
|
commands:
|
||||||
|
- make build
|
||||||
|
- ls -l dist/drone-s3-sync
|
||||||
|
|
||||||
|
- name: dryrun
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
dockerfile: docker/Dockerfile.arm64
|
||||||
|
dry_run: true
|
||||||
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/pull/**
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
|
|
||||||
|
- name: publish-dockerhub
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: arm64
|
||||||
|
dockerfile: docker/Dockerfile.arm64
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
|
- dryrun
|
||||||
|
|
||||||
|
- name: publish-quay
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: arm64
|
||||||
|
dockerfile: docker/Dockerfile.arm64
|
||||||
|
password:
|
||||||
|
from_secret: quay_password
|
||||||
|
registry: quay.io
|
||||||
|
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
username:
|
||||||
|
from_secret: quay_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
|
- dryrun
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
- refs/pull/**
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- test
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: build-container-arm
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: arm
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: golang:1.18
|
||||||
|
commands:
|
||||||
|
- make build
|
||||||
|
- ls -l dist/drone-s3-sync
|
||||||
|
|
||||||
|
- name: dryrun
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
dockerfile: docker/Dockerfile.arm
|
||||||
|
dry_run: true
|
||||||
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/pull/**
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
|
|
||||||
|
- name: publish-dockerhub
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: arm
|
||||||
|
dockerfile: docker/Dockerfile.arm
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
|
- dryrun
|
||||||
|
|
||||||
|
- name: publish-quay
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: arm
|
||||||
|
dockerfile: docker/Dockerfile.arm
|
||||||
|
password:
|
||||||
|
from_secret: quay_password
|
||||||
|
registry: quay.io
|
||||||
|
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
username:
|
||||||
|
from_secret: quay_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
|
- dryrun
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
- refs/pull/**
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- test
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: docs
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
limit: 1
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: markdownlint
|
||||||
|
image: thegeeklab/markdownlint-cli
|
||||||
|
commands:
|
||||||
|
- markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'
|
||||||
|
|
||||||
|
- name: spellcheck
|
||||||
|
image: node:lts-alpine
|
||||||
|
commands:
|
||||||
|
- npm install -g spellchecker-cli
|
||||||
|
- spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions
|
||||||
|
environment:
|
||||||
|
FORCE_COLOR: true
|
||||||
|
NPM_CONFIG_LOGLEVEL: error
|
||||||
|
|
||||||
|
- name: publish
|
||||||
|
image: plugins/gh-pages
|
||||||
|
settings:
|
||||||
|
pages_directory: _docs/
|
||||||
|
password:
|
||||||
|
from_secret: github_token
|
||||||
|
target_branch: docs
|
||||||
|
username:
|
||||||
|
from_secret: github_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
- refs/pull/**
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- build-binaries
|
||||||
|
- build-container-amd64
|
||||||
|
- build-container-arm64
|
||||||
|
- build-container-arm
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: notifications
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: manifest-dockerhub
|
||||||
|
image: plugins/manifest
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
ignore_missing: true
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
spec: docker/manifest.tmpl
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
when:
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
|
||||||
|
- name: manifest-quay
|
||||||
|
image: plugins/manifest
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
ignore_missing: true
|
||||||
|
password:
|
||||||
|
from_secret: quay_password
|
||||||
|
spec: docker/manifest-quay.tmpl
|
||||||
|
username:
|
||||||
|
from_secret: quay_username
|
||||||
|
when:
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
|
||||||
|
- name: pushrm-dockerhub
|
||||||
|
image: chko/docker-pushrm:1
|
||||||
|
environment:
|
||||||
|
DOCKER_PASS:
|
||||||
|
from_secret: docker_password
|
||||||
|
DOCKER_USER:
|
||||||
|
from_secret: docker_username
|
||||||
|
PUSHRM_FILE: README.md
|
||||||
|
PUSHRM_SHORT: Drone plugin to synchronize a directory with an S3 bucket
|
||||||
|
PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
when:
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
|
||||||
|
- name: pushrm-quay
|
||||||
|
image: chko/docker-pushrm:1
|
||||||
|
environment:
|
||||||
|
APIKEY__QUAY_IO:
|
||||||
|
from_secret: quay_token
|
||||||
|
PUSHRM_FILE: README.md
|
||||||
|
PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
when:
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
|
||||||
|
- name: matrix
|
||||||
|
image: thegeeklab/drone-matrix
|
||||||
|
settings:
|
||||||
|
homeserver:
|
||||||
|
from_secret: matrix_homeserver
|
||||||
|
password:
|
||||||
|
from_secret: matrix_password
|
||||||
|
roomid:
|
||||||
|
from_secret: matrix_roomid
|
||||||
|
template: "Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}"
|
||||||
|
username:
|
||||||
|
from_secret: matrix_username
|
||||||
|
when:
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
- failure
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
- failure
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- docs
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: signature
|
||||||
|
hmac: dc305412e0b8b116d59630f50063f5b0a38441bf4a4e685f9bcb0e5ad9784cc7
|
||||||
|
|
||||||
|
...
|
5
.github/settings.yml
vendored
5
.github/settings.yml
vendored
|
@ -52,17 +52,14 @@ branches:
|
||||||
strict: false
|
strict: false
|
||||||
contexts:
|
contexts:
|
||||||
- continuous-integration/drone/pr
|
- continuous-integration/drone/pr
|
||||||
enforce_admins: true
|
enforce_admins: null
|
||||||
required_linear_history: true
|
|
||||||
restrictions: null
|
restrictions: null
|
||||||
- name: docs
|
- name: docs
|
||||||
protection:
|
protection:
|
||||||
required_pull_request_reviews: null
|
required_pull_request_reviews: null
|
||||||
required_status_checks: null
|
required_status_checks: null
|
||||||
enforce_admins: true
|
enforce_admins: true
|
||||||
required_linear_history: true
|
|
||||||
restrictions:
|
restrictions:
|
||||||
apps: []
|
|
||||||
users: []
|
users: []
|
||||||
teams:
|
teams:
|
||||||
- bot
|
- bot
|
||||||
|
|
106
.golangci.yml
106
.golangci.yml
|
@ -1,91 +1,25 @@
|
||||||
linters:
|
linters:
|
||||||
|
enable:
|
||||||
|
- gosimple
|
||||||
|
- deadcode
|
||||||
|
- typecheck
|
||||||
|
- govet
|
||||||
|
- errcheck
|
||||||
|
- staticcheck
|
||||||
|
- unused
|
||||||
|
- structcheck
|
||||||
|
- varcheck
|
||||||
|
- dupl
|
||||||
|
- gofmt
|
||||||
|
- misspell
|
||||||
|
- gocritic
|
||||||
|
- bidichk
|
||||||
|
- ineffassign
|
||||||
|
- revive
|
||||||
|
- gofumpt
|
||||||
|
- depguard
|
||||||
enable-all: false
|
enable-all: false
|
||||||
disable-all: true
|
disable-all: true
|
||||||
enable:
|
|
||||||
- errcheck
|
|
||||||
- gosimple
|
|
||||||
- govet
|
|
||||||
- ineffassign
|
|
||||||
- staticcheck
|
|
||||||
- typecheck
|
|
||||||
- unused
|
|
||||||
- asasalint
|
|
||||||
- asciicheck
|
|
||||||
- bidichk
|
|
||||||
- bodyclose
|
|
||||||
- containedctx
|
|
||||||
- contextcheck
|
|
||||||
- decorder
|
|
||||||
- dogsled
|
|
||||||
- dupl
|
|
||||||
- dupword
|
|
||||||
- durationcheck
|
|
||||||
- errchkjson
|
|
||||||
- errname
|
|
||||||
- errorlint
|
|
||||||
- execinquery
|
|
||||||
- exhaustive
|
|
||||||
- exportloopref
|
|
||||||
- forcetypeassert
|
|
||||||
- ginkgolinter
|
|
||||||
- gocheckcompilerdirectives
|
|
||||||
- gochecknoglobals
|
|
||||||
- gochecknoinits
|
|
||||||
- gocognit
|
|
||||||
- goconst
|
|
||||||
- gocritic
|
|
||||||
- gocyclo
|
|
||||||
- godot
|
|
||||||
- godox
|
|
||||||
- goerr113
|
|
||||||
- gofmt
|
|
||||||
- gofumpt
|
|
||||||
- goheader
|
|
||||||
- goimports
|
|
||||||
- gomnd
|
|
||||||
- gomoddirectives
|
|
||||||
- gomodguard
|
|
||||||
- goprintffuncname
|
|
||||||
- gosec
|
|
||||||
- grouper
|
|
||||||
- importas
|
|
||||||
- interfacebloat
|
|
||||||
- ireturn
|
|
||||||
- lll
|
|
||||||
- loggercheck
|
|
||||||
- maintidx
|
|
||||||
- makezero
|
|
||||||
- misspell
|
|
||||||
- musttag
|
|
||||||
- nakedret
|
|
||||||
- nestif
|
|
||||||
- nilerr
|
|
||||||
- nilnil
|
|
||||||
- nlreturn
|
|
||||||
- noctx
|
|
||||||
- nolintlint
|
|
||||||
- nonamedreturns
|
|
||||||
- nosprintfhostport
|
|
||||||
- prealloc
|
|
||||||
- predeclared
|
|
||||||
- promlinter
|
|
||||||
- reassign
|
|
||||||
- revive
|
|
||||||
# - rowserrcheck
|
|
||||||
# - sqlclosecheck
|
|
||||||
# - structcheck
|
|
||||||
- stylecheck
|
|
||||||
- tagliatelle
|
|
||||||
- tenv
|
|
||||||
- testableexamples
|
|
||||||
- thelper
|
|
||||||
- tparallel
|
|
||||||
- unconvert
|
|
||||||
- unparam
|
|
||||||
- usestdlibvars
|
|
||||||
# - wastedassign
|
|
||||||
- whitespace
|
|
||||||
- wsl
|
|
||||||
fast: false
|
fast: false
|
||||||
|
|
||||||
run:
|
run:
|
||||||
|
@ -94,4 +28,4 @@ run:
|
||||||
linters-settings:
|
linters-settings:
|
||||||
gofumpt:
|
gofumpt:
|
||||||
extra-rules: true
|
extra-rules: true
|
||||||
lang-version: "1.20"
|
lang-version: "1.18"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
## Security
|
## Security
|
||||||
|
|
||||||
If you think you have found a **security issue**, please do not mention it in this repository.
|
If you think you have found a **security issue**, please do not mention it in this repository.
|
||||||
Instead, send an email to `security@thegeeklab.de` with as many details as possible so it can be handled confidential.
|
Instead, send an email to security@thegeeklab.de with as many details as possible so it can be handled confidential.
|
||||||
|
|
||||||
## Bug Reports and Feature Requests
|
## Bug Reports and Feature Requests
|
||||||
|
|
||||||
|
|
15
Makefile
15
Makefile
|
@ -1,7 +1,7 @@
|
||||||
# renovate: datasource=github-releases depName=mvdan/gofumpt
|
# renovate: datasource=github-releases depName=mvdan/gofumpt
|
||||||
GOFUMPT_PACKAGE_VERSION := v0.5.0
|
GOFUMPT_PACKAGE_VERSION := v0.3.1
|
||||||
# renovate: datasource=github-releases depName=golangci/golangci-lint
|
# renovate: datasource=github-releases depName=golangci/golangci-lint
|
||||||
GOLANGCI_LINT_PACKAGE_VERSION := v1.54.1
|
GOLANGCI_LINT_PACKAGE_VERSION := v1.46.2
|
||||||
|
|
||||||
EXECUTABLE := drone-s3-sync
|
EXECUTABLE := drone-s3-sync
|
||||||
|
|
||||||
|
@ -19,15 +19,10 @@ GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(G
|
||||||
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
||||||
|
|
||||||
GENERATE ?=
|
GENERATE ?=
|
||||||
XGO_VERSION := go-1.20.x
|
XGO_VERSION := go-1.18.x
|
||||||
XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm-7,linux/arm64
|
XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm-7,linux/arm64
|
||||||
|
|
||||||
TARGETOS ?= linux
|
TAGS ?= netgo
|
||||||
TARGETARCH ?= amd64
|
|
||||||
ifneq ("$(TARGETVARIANT)","")
|
|
||||||
GOARM ?= $(subst v,,$(TARGETVARIANT))
|
|
||||||
endif
|
|
||||||
TAGS ?= netgo,osusergo
|
|
||||||
|
|
||||||
ifndef VERSION
|
ifndef VERSION
|
||||||
ifneq ($(DRONE_TAG),)
|
ifneq ($(DRONE_TAG),)
|
||||||
|
@ -74,7 +69,7 @@ test:
|
||||||
build: $(DIST)/$(EXECUTABLE)
|
build: $(DIST)/$(EXECUTABLE)
|
||||||
|
|
||||||
$(DIST)/$(EXECUTABLE): $(SOURCES)
|
$(DIST)/$(EXECUTABLE): $(SOURCES)
|
||||||
GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) GOARM=$(GOARM) $(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
|
$(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
|
||||||
|
|
||||||
$(DIST_DIRS):
|
$(DIST_DIRS):
|
||||||
mkdir -p $(DIST_DIRS)
|
mkdir -p $(DIST_DIRS)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# drone-s3-sync
|
# drone-s3-sync
|
||||||
|
|
||||||
DISCONTINUED: Drone plugin to synchronize a directory with an S3 bucket
|
Drone plugin to synchronize a directory with an S3 bucket
|
||||||
|
|
||||||
[![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)
|
[![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)
|
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/drone-s3-sync)
|
||||||
|
@ -10,13 +10,11 @@ DISCONTINUED: Drone plugin to synchronize a directory with an S3 bucket
|
||||||
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/drone-s3-sync)
|
[![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)
|
[![License: MIT](https://img.shields.io/github/license/thegeeklab/drone-s3-sync)](https://github.com/thegeeklab/drone-s3-sync/blob/main/LICENSE)
|
||||||
|
|
||||||
> **DISCONTINUED:** As I don't use Drone CI anymore, this project is unmaintained. If you are interested in a free and open source CI system check out [Woodpecker CI](https://woodpecker-ci.org/).
|
Drone plugin to synchronize a directory with an S3 bucket. You can find the full documentation at You can find the full documentation at [https://drone-plugin-index.geekdocs.de](https://drone-plugin-index.geekdocs.de/plugins/drone-s3-sync).
|
||||||
|
|
||||||
Drone plugin to synchronize a directory with an S3 bucket. You can find the full documentation at [https://drone-plugin-index.geekdocs.de](https://drone-plugin-index.geekdocs.de/plugins/drone-s3-sync).
|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
Special thanks to all [contributors](https://github.com/thegeeklab/drone-s3-sync/graphs/contributors). If you would like to contribute, please see the [instructions](https://github.com/thegeeklab/drone-s3-sync/blob/main/CONTRIBUTING.md).
|
Special thanks goes to all [contributors](https://github.com/thegeeklab/drone-s3-sync/graphs/contributors). If you would like to contribute, please see the [instructions](https://github.com/thegeeklab/drone-s3-sync/blob/main/CONTRIBUTING.md).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ steps:
|
||||||
|
|
||||||
<!-- prettier-ignore-start -->
|
<!-- prettier-ignore-start -->
|
||||||
<!-- spellchecker-disable -->
|
<!-- spellchecker-disable -->
|
||||||
{{< propertylist name=drone-s3-sync.data sort=name >}}
|
{{< propertylist name=drone-s3-sync.data >}}
|
||||||
<!-- spellchecker-enable -->
|
<!-- spellchecker-enable -->
|
||||||
<!-- prettier-ignore-end -->
|
<!-- prettier-ignore-end -->
|
||||||
|
|
||||||
|
|
|
@ -1,94 +1,94 @@
|
||||||
---
|
---
|
||||||
properties:
|
properties:
|
||||||
- name: endpoint
|
endpoint:
|
||||||
description: Endpoint for the s3 connection.
|
description: Endpoint for the s3 connection.
|
||||||
type: string
|
type: string
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: access-key
|
access-key:
|
||||||
description: S3 access key.
|
description: S3 access key.
|
||||||
type: string
|
type: string
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: secret-key
|
secret-key:
|
||||||
description: S3 secret key.
|
description: S3 secret key.
|
||||||
type: string
|
type: string
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: path-style
|
path-style:
|
||||||
description: Enable path style for bucket paths.
|
description: Enable path style for bucket paths.
|
||||||
type: bool
|
type: bool
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: bucket
|
bucket:
|
||||||
description: Name of the bucket.
|
description: Name of the bucket.
|
||||||
type: string
|
type: string
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- name: region
|
region:
|
||||||
description: S3 region.
|
description: S3 region.
|
||||||
defaultValue: us-east-1
|
defaultValue: us-east-1
|
||||||
type: string
|
type: string
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: source
|
source:
|
||||||
description: Upload source path.
|
description: Upload source path.
|
||||||
defaultValue: .
|
defaultValue: .
|
||||||
type: string
|
type: string
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: target
|
target:
|
||||||
description: Upload target path.
|
description: Upload target path.
|
||||||
defaultValue: /
|
defaultValue: /
|
||||||
type: string
|
type: string
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: delete
|
delete:
|
||||||
description: Delete locally removed files from the target.
|
description: Delete locally removed files from the target.
|
||||||
type: bool
|
type: bool
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: acl
|
acl:
|
||||||
description: Access control list.
|
description: Access control list.
|
||||||
type: map
|
type: map
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: content-type
|
content-type:
|
||||||
description: Content-type settings for uploads.
|
description: Content-type settings for uploads.
|
||||||
type: map
|
type: map
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: content-encoding
|
content-encoding:
|
||||||
description: Content-encoding settings for uploads.
|
description: Content-encoding settings for uploads.
|
||||||
type: map
|
type: map
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: cache_control
|
cache_control:
|
||||||
description: Cache-control settings for uploads.
|
description: Cache-control settings for uploads.
|
||||||
type: map
|
type: map
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: metadata
|
metadata:
|
||||||
description: Additional metadata for uploads.
|
description: Additional metadata for uploads.
|
||||||
type: map
|
type: map
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: redirects
|
redirects:
|
||||||
description: Redirects to create.
|
description: Redirects to create.
|
||||||
type: map
|
type: map
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: cloudfront-distribution
|
cloudfront-distribution:
|
||||||
description: ID of cloudfront distribution to invalidate.
|
description: ID of cloudfront distribution to invalidate.
|
||||||
type: string
|
type: string
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: dry_run
|
dry_run:
|
||||||
description: Dry run disables API calls.
|
description: Dry run disables API calls.
|
||||||
type: bool
|
type: bool
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- name: max_concurrency
|
max_concurrency:
|
||||||
description: Customize number of concurrent files to process.
|
description: Customize number of concurrent files to process.
|
||||||
defaultValue: 100
|
defaultValue: 100
|
||||||
type: int
|
type: int
|
||||||
|
|
|
@ -136,7 +136,6 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
Name: "max-concurrency",
|
Name: "max-concurrency",
|
||||||
Usage: "customize number concurrent files to process",
|
Usage: "customize number concurrent files to process",
|
||||||
//nolint:gomnd
|
|
||||||
Value: 100,
|
Value: 100,
|
||||||
EnvVars: []string{"PLUGIN_MAX_CONCURRENCY"},
|
EnvVars: []string{"PLUGIN_MAX_CONCURRENCY"},
|
||||||
Destination: &settings.MaxConcurrency,
|
Destination: &settings.MaxConcurrency,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
@ -12,14 +11,11 @@ import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:gochecknoglobals
|
|
||||||
var (
|
var (
|
||||||
BuildVersion = "devel"
|
BuildVersion = "devel"
|
||||||
BuildDate = "00000000"
|
BuildDate = "00000000"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrTypeAssertionFailed = errors.New("type assertion failed")
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
settings := &plugin.Settings{}
|
settings := &plugin.Settings{}
|
||||||
|
|
||||||
|
@ -48,42 +44,12 @@ func run(settings *plugin.Settings) cli.ActionFunc {
|
||||||
return func(ctx *cli.Context) error {
|
return func(ctx *cli.Context) error {
|
||||||
urfave.LoggingFromContext(ctx)
|
urfave.LoggingFromContext(ctx)
|
||||||
|
|
||||||
acl, ok := ctx.Generic("acl").(*StringMapFlag)
|
settings.ACL = ctx.Generic("acl").(*StringMapFlag).Get()
|
||||||
if !ok {
|
settings.CacheControl = ctx.Generic("cache-control").(*StringMapFlag).Get()
|
||||||
return fmt.Errorf("%w: failed to read acl input", ErrTypeAssertionFailed)
|
settings.ContentType = ctx.Generic("content-type").(*StringMapFlag).Get()
|
||||||
}
|
settings.ContentEncoding = ctx.Generic("content-encoding").(*StringMapFlag).Get()
|
||||||
|
settings.Metadata = ctx.Generic("metadata").(*DeepStringMapFlag).Get()
|
||||||
cacheControl, ok := ctx.Generic("cache-control").(*StringMapFlag)
|
settings.Redirects = ctx.Generic("redirects").(*MapFlag).Get()
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("%w: failed to read cache-control input", ErrTypeAssertionFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
contentType, ok := ctx.Generic("content-type").(*StringMapFlag)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("%w: failed to read content-type input", ErrTypeAssertionFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
contentEncoding, ok := ctx.Generic("content-encoding").(*StringMapFlag)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("%w: failed to read content-encoding input", ErrTypeAssertionFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
metadata, ok := ctx.Generic("metadata").(*DeepStringMapFlag)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("%w: failed to read metadata input", ErrTypeAssertionFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
redirects, ok := ctx.Generic("redirects").(*MapFlag)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("%w: failed to read redirects input", ErrTypeAssertionFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.ACL = acl.Get()
|
|
||||||
settings.CacheControl = cacheControl.Get()
|
|
||||||
settings.ContentType = contentType.Get()
|
|
||||||
settings.ContentEncoding = contentEncoding.Get()
|
|
||||||
settings.Metadata = metadata.Get()
|
|
||||||
settings.Redirects = redirects.Get()
|
|
||||||
|
|
||||||
plugin := plugin.New(
|
plugin := plugin.New(
|
||||||
*settings,
|
*settings,
|
||||||
|
|
|
@ -18,11 +18,9 @@ func (d *DeepStringMapFlag) Get() map[string]map[string]string {
|
||||||
|
|
||||||
func (d *DeepStringMapFlag) Set(value string) error {
|
func (d *DeepStringMapFlag) Set(value string) error {
|
||||||
d.parts = map[string]map[string]string{}
|
d.parts = map[string]map[string]string{}
|
||||||
|
|
||||||
err := json.Unmarshal([]byte(value), &d.parts)
|
err := json.Unmarshal([]byte(value), &d.parts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
single := map[string]string{}
|
single := map[string]string{}
|
||||||
|
|
||||||
err := json.Unmarshal([]byte(value), &single)
|
err := json.Unmarshal([]byte(value), &single)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -48,12 +46,10 @@ func (s *StringMapFlag) Get() map[string]string {
|
||||||
|
|
||||||
func (s *StringMapFlag) Set(value string) error {
|
func (s *StringMapFlag) Set(value string) error {
|
||||||
s.parts = map[string]string{}
|
s.parts = map[string]string{}
|
||||||
|
|
||||||
err := json.Unmarshal([]byte(value), &s.parts)
|
err := json.Unmarshal([]byte(value), &s.parts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.parts["*"] = value
|
s.parts["*"] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +67,5 @@ func (m *MapFlag) Get() map[string]string {
|
||||||
|
|
||||||
func (m *MapFlag) Set(value string) error {
|
func (m *MapFlag) Set(value string) error {
|
||||||
m.parts = map[string]string{}
|
m.parts = map[string]string{}
|
||||||
|
|
||||||
return json.Unmarshal([]byte(value), &m.parts)
|
return json.Unmarshal([]byte(value), &m.parts)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,4 @@
|
||||||
FROM --platform=$BUILDPLATFORM golang:1.20@sha256:839ba88412b5d3e12d66ed4774a85fc6e6c644dce8074ab82c798e5db27d4a09 as build
|
FROM alpine:3.16@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c
|
||||||
|
|
||||||
ARG TARGETOS
|
|
||||||
ARG TARGETARCH
|
|
||||||
|
|
||||||
ADD . /src
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
RUN make build
|
|
||||||
|
|
||||||
FROM alpine:3.18@sha256:7144f7bab3d4c2648d7e59409f15ec52a18006a128c733fcff20d3a4a54ba44a
|
|
||||||
|
|
||||||
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
|
@ -17,5 +7,6 @@ LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-s3-sync"
|
||||||
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-s3-sync"
|
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-s3-sync"
|
||||||
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-s3-sync"
|
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-s3-sync"
|
||||||
|
|
||||||
COPY --from=build /src/dist/drone-s3-sync /bin/drone-s3-sync
|
ADD dist/drone-s3-sync /bin/
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/drone-s3-sync"]
|
ENTRYPOINT ["/bin/drone-s3-sync"]
|
12
docker/Dockerfile.arm
Normal file
12
docker/Dockerfile.arm
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
FROM arm32v7/alpine:3.16@sha256:0615cdd745d0b78e7e6ac3a7b1f02e4daefa664eae0324120955f4e4c91bea3f
|
||||||
|
|
||||||
|
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
|
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
|
LABEL org.opencontainers.image.title="drone-s3-sync"
|
||||||
|
LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-s3-sync"
|
||||||
|
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-s3-sync"
|
||||||
|
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-s3-sync"
|
||||||
|
|
||||||
|
ADD dist/drone-s3-sync /bin/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/drone-s3-sync"]
|
12
docker/Dockerfile.arm64
Normal file
12
docker/Dockerfile.arm64
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
FROM arm64v8/alpine:3.16@sha256:c3c58223e2af75154c4a7852d6924b4cc51a00c821553bbd9b3319481131b2e0
|
||||||
|
|
||||||
|
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
|
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
|
LABEL org.opencontainers.image.title="drone-s3-sync"
|
||||||
|
LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-s3-sync"
|
||||||
|
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-s3-sync"
|
||||||
|
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-s3-sync"
|
||||||
|
|
||||||
|
ADD dist/drone-s3-sync /bin/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/drone-s3-sync"]
|
24
docker/manifest-quay.tmpl
Normal file
24
docker/manifest-quay.tmpl
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
image: quay.io/thegeeklab/drone-s3-sync:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||||
|
{{#if build.tags}}
|
||||||
|
tags:
|
||||||
|
{{#each build.tags}}
|
||||||
|
- {{this}}
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
|
manifests:
|
||||||
|
- image: quay.io/thegeeklab/drone-s3-sync:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
|
||||||
|
platform:
|
||||||
|
architecture: amd64
|
||||||
|
os: linux
|
||||||
|
|
||||||
|
- image: quay.io/thegeeklab/drone-s3-sync:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm64
|
||||||
|
platform:
|
||||||
|
architecture: arm64
|
||||||
|
os: linux
|
||||||
|
variant: v8
|
||||||
|
|
||||||
|
- image: quay.io/thegeeklab/drone-s3-sync:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm
|
||||||
|
platform:
|
||||||
|
architecture: arm
|
||||||
|
os: linux
|
||||||
|
variant: v7
|
24
docker/manifest.tmpl
Normal file
24
docker/manifest.tmpl
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
image: thegeeklab/drone-s3-sync:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||||
|
{{#if build.tags}}
|
||||||
|
tags:
|
||||||
|
{{#each build.tags}}
|
||||||
|
- {{this}}
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
|
manifests:
|
||||||
|
- image: thegeeklab/drone-s3-sync:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
|
||||||
|
platform:
|
||||||
|
architecture: amd64
|
||||||
|
os: linux
|
||||||
|
|
||||||
|
- image: thegeeklab/drone-s3-sync:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm64
|
||||||
|
platform:
|
||||||
|
architecture: arm64
|
||||||
|
os: linux
|
||||||
|
variant: v8
|
||||||
|
|
||||||
|
- image: thegeeklab/drone-s3-sync:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm
|
||||||
|
platform:
|
||||||
|
architecture: arm
|
||||||
|
os: linux
|
||||||
|
variant: v7
|
16
go.mod
16
go.mod
|
@ -1,20 +1,22 @@
|
||||||
module github.com/thegeeklab/drone-s3-sync
|
module github.com/thegeeklab/drone-s3-sync
|
||||||
|
|
||||||
go 1.20
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aws/aws-sdk-go v1.44.302
|
github.com/aws/aws-sdk-go v1.44.20
|
||||||
github.com/joho/godotenv v1.5.1
|
github.com/joho/godotenv v1.4.0
|
||||||
github.com/ryanuber/go-glob v1.0.0
|
github.com/ryanuber/go-glob v1.0.0
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.8.1
|
||||||
github.com/thegeeklab/drone-plugin-lib/v2 v2.3.4
|
github.com/thegeeklab/drone-plugin-lib/v2 v2.0.0
|
||||||
github.com/urfave/cli/v2 v2.25.7
|
github.com/urfave/cli/v2 v2.8.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
|
github.com/stretchr/testify v1.4.0 // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||||
golang.org/x/sys v0.2.0 // indirect
|
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
|
||||||
)
|
)
|
||||||
|
|
66
go.sum
66
go.sum
|
@ -1,5 +1,5 @@
|
||||||
github.com/aws/aws-sdk-go v1.44.302 h1:ST3ko6GrJKn3Xi+nAvxjG3uk/V1pW8KC52WLeIxqqNk=
|
github.com/aws/aws-sdk-go v1.44.20 h1:nllTRN24EfhDSeKsNbIc6HoC8Ogd2NCJTRB8l84kDlM=
|
||||||
github.com/aws/aws-sdk-go v1.44.302/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
|
github.com/aws/aws-sdk-go v1.44.20/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
@ -9,8 +9,8 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y
|
||||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
|
||||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
@ -18,51 +18,31 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
|
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
|
||||||
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
|
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
|
||||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
github.com/thegeeklab/drone-plugin-lib/v2 v2.3.4 h1:Quzrike/xRAR0izxQ0d+ocJyIUm4h1497Oyo9grcRzg=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/thegeeklab/drone-plugin-lib/v2 v2.3.4/go.mod h1:qWVUZCmwL0Ntwa/hvyqM03EeIr1ReBR2XJsmIc7MGus=
|
github.com/thegeeklab/drone-plugin-lib/v2 v2.0.0 h1:ejM1fIkGhn9sy7HTidRiQhZJuEfUNF6sO9ko090PYvM=
|
||||||
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
|
github.com/thegeeklab/drone-plugin-lib/v2 v2.0.0/go.mod h1:cXNc+dmGLA748rAnXVBsTFG1UO+A/0XlV5jUEf/ahgk=
|
||||||
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
github.com/urfave/cli/v2 v2.8.1 h1:CGuYNZF9IKZY/rfBe3lJpccSoIY1ytfvmgQT90cNOl4=
|
||||||
|
github.com/urfave/cli/v2 v2.8.1/go.mod h1:Z41J9TPoffeoqP0Iza0YbAhGvymRdZAd2uPmZ5JxRdY=
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
|
||||||
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
|
|
||||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/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-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60=
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
|
||||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
|
|
||||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
||||||
|
|
140
plugin/aws.go
140
plugin/aws.go
|
@ -1,9 +1,7 @@
|
||||||
package plugin
|
package plugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
//nolint:gosec
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"mime"
|
"mime"
|
||||||
|
@ -30,20 +28,20 @@ type AWS struct {
|
||||||
plugin *Plugin
|
plugin *Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAWS(plugin *Plugin) AWS {
|
func NewAWS(p *Plugin) AWS {
|
||||||
sessCfg := &aws.Config{
|
sessCfg := &aws.Config{
|
||||||
S3ForcePathStyle: aws.Bool(plugin.settings.PathStyle),
|
S3ForcePathStyle: aws.Bool(p.settings.PathStyle),
|
||||||
Region: aws.String(plugin.settings.Region),
|
Region: aws.String(p.settings.Region),
|
||||||
}
|
}
|
||||||
|
|
||||||
if plugin.settings.Endpoint != "" {
|
if p.settings.Endpoint != "" {
|
||||||
sessCfg.Endpoint = &plugin.settings.Endpoint
|
sessCfg.Endpoint = &p.settings.Endpoint
|
||||||
sessCfg.DisableSSL = aws.Bool(strings.HasPrefix(plugin.settings.Endpoint, "http://"))
|
sessCfg.DisableSSL = aws.Bool(strings.HasPrefix(p.settings.Endpoint, "http://"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// allowing to use the instance role or provide a key and secret
|
// allowing to use the instance role or provide a key and secret
|
||||||
if plugin.settings.AccessKey != "" && plugin.settings.SecretKey != "" {
|
if p.settings.AccessKey != "" && p.settings.SecretKey != "" {
|
||||||
sessCfg.Credentials = credentials.NewStaticCredentials(plugin.settings.AccessKey, plugin.settings.SecretKey, "")
|
sessCfg.Credentials = credentials.NewStaticCredentials(p.settings.AccessKey, p.settings.SecretKey, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
sess, _ := session.NewSession(sessCfg)
|
sess, _ := session.NewSession(sessCfg)
|
||||||
|
@ -53,13 +51,11 @@ func NewAWS(plugin *Plugin) AWS {
|
||||||
r := make([]string, 1)
|
r := make([]string, 1)
|
||||||
l := make([]string, 1)
|
l := make([]string, 1)
|
||||||
|
|
||||||
return AWS{c, cf, r, l, plugin}
|
return AWS{c, cf, r, l, p}
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gocognit,gocyclo,maintidx
|
|
||||||
func (a *AWS) Upload(local, remote string) error {
|
func (a *AWS) Upload(local, remote string) error {
|
||||||
plugin := a.plugin
|
p := a.plugin
|
||||||
|
|
||||||
if local == "" {
|
if local == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -72,11 +68,9 @@ func (a *AWS) Upload(local, remote string) error {
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
var acl string
|
var acl string
|
||||||
|
for pattern := range p.settings.ACL {
|
||||||
for pattern := range plugin.settings.ACL {
|
|
||||||
if match := glob.Glob(pattern, local); match {
|
if match := glob.Glob(pattern, local); match {
|
||||||
acl = plugin.settings.ACL[pattern]
|
acl = p.settings.ACL[pattern]
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,11 +82,9 @@ func (a *AWS) Upload(local, remote string) error {
|
||||||
fileExt := filepath.Ext(local)
|
fileExt := filepath.Ext(local)
|
||||||
|
|
||||||
var contentType string
|
var contentType string
|
||||||
|
for patternExt := range p.settings.ContentType {
|
||||||
for patternExt := range plugin.settings.ContentType {
|
|
||||||
if patternExt == fileExt {
|
if patternExt == fileExt {
|
||||||
contentType = plugin.settings.ContentType[patternExt]
|
contentType = p.settings.ContentType[patternExt]
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,58 +94,43 @@ func (a *AWS) Upload(local, remote string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var contentEncoding string
|
var contentEncoding string
|
||||||
|
for patternExt := range p.settings.ContentEncoding {
|
||||||
for patternExt := range plugin.settings.ContentEncoding {
|
|
||||||
if patternExt == fileExt {
|
if patternExt == fileExt {
|
||||||
contentEncoding = plugin.settings.ContentEncoding[patternExt]
|
contentEncoding = p.settings.ContentEncoding[patternExt]
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var cacheControl string
|
var cacheControl string
|
||||||
|
for pattern := range p.settings.CacheControl {
|
||||||
for pattern := range plugin.settings.CacheControl {
|
|
||||||
if match := glob.Glob(pattern, local); match {
|
if match := glob.Glob(pattern, local); match {
|
||||||
cacheControl = plugin.settings.CacheControl[pattern]
|
cacheControl = p.settings.CacheControl[pattern]
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata := map[string]*string{}
|
metadata := map[string]*string{}
|
||||||
|
for pattern := range p.settings.Metadata {
|
||||||
for pattern := range plugin.settings.Metadata {
|
|
||||||
if match := glob.Glob(pattern, local); match {
|
if match := glob.Glob(pattern, local); match {
|
||||||
for k, v := range plugin.settings.Metadata[pattern] {
|
for k, v := range p.settings.Metadata[pattern] {
|
||||||
metadata[k] = aws.String(v)
|
metadata[k] = aws.String(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var AWSErr awserr.Error
|
|
||||||
|
|
||||||
head, err := a.client.HeadObject(&s3.HeadObjectInput{
|
head, err := a.client.HeadObject(&s3.HeadObjectInput{
|
||||||
Bucket: aws.String(plugin.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Key: aws.String(remote),
|
Key: aws.String(remote),
|
||||||
})
|
})
|
||||||
if err != nil && errors.As(err, &AWSErr) {
|
if err != nil && err.(awserr.Error).Code() != "404" {
|
||||||
//nolint:errorlint,forcetypeassert
|
|
||||||
if err.(awserr.Error).Code() == "404" {
|
if err.(awserr.Error).Code() == "404" {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf(
|
logrus.Debugf("'%s' not found in bucket, uploading with content-type '%s' and permissions '%s'", local, contentType, acl)
|
||||||
"'%s' not found in bucket, uploading with content-type '%s' and permissions '%s'",
|
|
||||||
local,
|
|
||||||
contentType,
|
|
||||||
acl,
|
|
||||||
)
|
|
||||||
|
|
||||||
putObject := &s3.PutObjectInput{
|
putObject := &s3.PutObjectInput{
|
||||||
Bucket: aws.String(plugin.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Key: aws.String(remote),
|
Key: aws.String(remote),
|
||||||
Body: file,
|
Body: file,
|
||||||
ContentType: aws.String(contentType),
|
ContentType: aws.String(contentType),
|
||||||
|
@ -175,58 +152,48 @@ func (a *AWS) Upload(local, remote string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = a.client.PutObject(putObject)
|
_, err = a.client.PutObject(putObject)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gosec
|
|
||||||
hash := md5.New()
|
hash := md5.New()
|
||||||
_, _ = io.Copy(hash, file)
|
_, _ = io.Copy(hash, file)
|
||||||
sum := fmt.Sprintf("'%x'", hash.Sum(nil))
|
sum := fmt.Sprintf("'%x'", hash.Sum(nil))
|
||||||
|
|
||||||
//nolint:nestif
|
|
||||||
if sum == *head.ETag {
|
if sum == *head.ETag {
|
||||||
shouldCopy := false
|
shouldCopy := false
|
||||||
|
|
||||||
if head.ContentType == nil && contentType != "" {
|
if head.ContentType == nil && contentType != "" {
|
||||||
logrus.Debugf("content-type has changed from unset to %s", contentType)
|
logrus.Debugf("content-type has changed from unset to %s", contentType)
|
||||||
|
|
||||||
shouldCopy = true
|
shouldCopy = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !shouldCopy && head.ContentType != nil && contentType != *head.ContentType {
|
if !shouldCopy && head.ContentType != nil && contentType != *head.ContentType {
|
||||||
logrus.Debugf("content-type has changed from %s to %s", *head.ContentType, contentType)
|
logrus.Debugf("content-type has changed from %s to %s", *head.ContentType, contentType)
|
||||||
|
|
||||||
shouldCopy = true
|
shouldCopy = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !shouldCopy && head.ContentEncoding == nil && contentEncoding != "" {
|
if !shouldCopy && head.ContentEncoding == nil && contentEncoding != "" {
|
||||||
logrus.Debugf("Content-Encoding has changed from unset to %s", contentEncoding)
|
logrus.Debugf("Content-Encoding has changed from unset to %s", contentEncoding)
|
||||||
|
|
||||||
shouldCopy = true
|
shouldCopy = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !shouldCopy && head.ContentEncoding != nil && contentEncoding != *head.ContentEncoding {
|
if !shouldCopy && head.ContentEncoding != nil && contentEncoding != *head.ContentEncoding {
|
||||||
logrus.Debugf("Content-Encoding has changed from %s to %s", *head.ContentEncoding, contentEncoding)
|
logrus.Debugf("Content-Encoding has changed from %s to %s", *head.ContentEncoding, contentEncoding)
|
||||||
|
|
||||||
shouldCopy = true
|
shouldCopy = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !shouldCopy && head.CacheControl == nil && cacheControl != "" {
|
if !shouldCopy && head.CacheControl == nil && cacheControl != "" {
|
||||||
logrus.Debugf("cache-control has changed from unset to %s", cacheControl)
|
logrus.Debugf("cache-control has changed from unset to %s", cacheControl)
|
||||||
|
|
||||||
shouldCopy = true
|
shouldCopy = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !shouldCopy && head.CacheControl != nil && cacheControl != *head.CacheControl {
|
if !shouldCopy && head.CacheControl != nil && cacheControl != *head.CacheControl {
|
||||||
logrus.Debugf("cache-control has changed from %s to %s", *head.CacheControl, cacheControl)
|
logrus.Debugf("cache-control has changed from %s to %s", *head.CacheControl, cacheControl)
|
||||||
|
|
||||||
shouldCopy = true
|
shouldCopy = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !shouldCopy && len(head.Metadata) != len(metadata) {
|
if !shouldCopy && len(head.Metadata) != len(metadata) {
|
||||||
logrus.Debugf("count of metadata values has changed for %s", local)
|
logrus.Debugf("count of metadata values has changed for %s", local)
|
||||||
|
|
||||||
shouldCopy = true
|
shouldCopy = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,9 +202,7 @@ func (a *AWS) Upload(local, remote string) error {
|
||||||
if hv, ok := head.Metadata[k]; ok {
|
if hv, ok := head.Metadata[k]; ok {
|
||||||
if *v != *hv {
|
if *v != *hv {
|
||||||
logrus.Debugf("metadata values have changed for %s", local)
|
logrus.Debugf("metadata values have changed for %s", local)
|
||||||
|
|
||||||
shouldCopy = true
|
shouldCopy = true
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,7 +211,7 @@ func (a *AWS) Upload(local, remote string) error {
|
||||||
|
|
||||||
if !shouldCopy {
|
if !shouldCopy {
|
||||||
grant, err := a.client.GetObjectAcl(&s3.GetObjectAclInput{
|
grant, err := a.client.GetObjectAcl(&s3.GetObjectAclInput{
|
||||||
Bucket: aws.String(plugin.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Key: aws.String(remote),
|
Key: aws.String(remote),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -254,20 +219,18 @@ func (a *AWS) Upload(local, remote string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
previousACL := "private"
|
previousACL := "private"
|
||||||
|
for _, g := range grant.Grants {
|
||||||
for _, grant := range grant.Grants {
|
gt := *g.Grantee
|
||||||
grantee := *grant.Grantee
|
if gt.URI != nil {
|
||||||
if grantee.URI != nil {
|
if *gt.URI == "http://acs.amazonaws.com/groups/global/AllUsers" {
|
||||||
if *grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers" {
|
if *g.Permission == "READ" {
|
||||||
if *grant.Permission == "READ" {
|
|
||||||
previousACL = "public-read"
|
previousACL = "public-read"
|
||||||
} else if *grant.Permission == "WRITE" {
|
} else if *g.Permission == "WRITE" {
|
||||||
previousACL = "public-read-write"
|
previousACL = "public-read-write"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if *gt.URI == "http://acs.amazonaws.com/groups/global/AuthenticatedUsers" {
|
||||||
if *grantee.URI == "http://acs.amazonaws.com/groups/global/AuthenticatedUsers" {
|
if *g.Permission == "READ" {
|
||||||
if *grant.Permission == "READ" {
|
|
||||||
previousACL = "authenticated-read"
|
previousACL = "authenticated-read"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,23 +239,20 @@ func (a *AWS) Upload(local, remote string) error {
|
||||||
|
|
||||||
if previousACL != acl {
|
if previousACL != acl {
|
||||||
logrus.Debugf("permissions for '%s' have changed from '%s' to '%s'", remote, previousACL, acl)
|
logrus.Debugf("permissions for '%s' have changed from '%s' to '%s'", remote, previousACL, acl)
|
||||||
|
|
||||||
shouldCopy = true
|
shouldCopy = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !shouldCopy {
|
if !shouldCopy {
|
||||||
logrus.Debugf("skipping '%s' because hashes and metadata match", local)
|
logrus.Debugf("skipping '%s' because hashes and metadata match", local)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("updating metadata for '%s' content-type: '%s', ACL: '%s'", local, contentType, acl)
|
logrus.Debugf("updating metadata for '%s' content-type: '%s', ACL: '%s'", local, contentType, acl)
|
||||||
|
|
||||||
copyObject := &s3.CopyObjectInput{
|
copyObject := &s3.CopyObjectInput{
|
||||||
Bucket: aws.String(plugin.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Key: aws.String(remote),
|
Key: aws.String(remote),
|
||||||
CopySource: aws.String(fmt.Sprintf("%s/%s", plugin.settings.Bucket, remote)),
|
CopySource: aws.String(fmt.Sprintf("%s/%s", p.settings.Bucket, remote)),
|
||||||
ACL: aws.String(acl),
|
ACL: aws.String(acl),
|
||||||
ContentType: aws.String(contentType),
|
ContentType: aws.String(contentType),
|
||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
|
@ -313,7 +273,6 @@ func (a *AWS) Upload(local, remote string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = a.client.CopyObject(copyObject)
|
_, err = a.client.CopyObject(copyObject)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,9 +282,8 @@ func (a *AWS) Upload(local, remote string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("uploading '%s' with content-type '%s' and permissions '%s'", local, contentType, acl)
|
logrus.Debugf("uploading '%s' with content-type '%s' and permissions '%s'", local, contentType, acl)
|
||||||
|
|
||||||
putObject := &s3.PutObjectInput{
|
putObject := &s3.PutObjectInput{
|
||||||
Bucket: aws.String(plugin.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Key: aws.String(remote),
|
Key: aws.String(remote),
|
||||||
Body: file,
|
Body: file,
|
||||||
ContentType: aws.String(contentType),
|
ContentType: aws.String(contentType),
|
||||||
|
@ -347,13 +305,11 @@ func (a *AWS) Upload(local, remote string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = a.client.PutObject(putObject)
|
_, err = a.client.PutObject(putObject)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AWS) Redirect(path, location string) error {
|
func (a *AWS) Redirect(path, location string) error {
|
||||||
plugin := a.plugin
|
p := a.plugin
|
||||||
|
|
||||||
logrus.Debugf("adding redirect from '%s' to '%s'", path, location)
|
logrus.Debugf("adding redirect from '%s' to '%s'", path, location)
|
||||||
|
|
||||||
if a.plugin.settings.DryRun {
|
if a.plugin.settings.DryRun {
|
||||||
|
@ -361,18 +317,16 @@ func (a *AWS) Redirect(path, location string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := a.client.PutObject(&s3.PutObjectInput{
|
_, err := a.client.PutObject(&s3.PutObjectInput{
|
||||||
Bucket: aws.String(plugin.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Key: aws.String(path),
|
Key: aws.String(path),
|
||||||
ACL: aws.String("public-read"),
|
ACL: aws.String("public-read"),
|
||||||
WebsiteRedirectLocation: aws.String(location),
|
WebsiteRedirectLocation: aws.String(location),
|
||||||
})
|
})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AWS) Delete(remote string) error {
|
func (a *AWS) Delete(remote string) error {
|
||||||
plugin := a.plugin
|
p := a.plugin
|
||||||
|
|
||||||
logrus.Debugf("removing remote file '%s'", remote)
|
logrus.Debugf("removing remote file '%s'", remote)
|
||||||
|
|
||||||
if a.plugin.settings.DryRun {
|
if a.plugin.settings.DryRun {
|
||||||
|
@ -380,20 +334,17 @@ func (a *AWS) Delete(remote string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := a.client.DeleteObject(&s3.DeleteObjectInput{
|
_, err := a.client.DeleteObject(&s3.DeleteObjectInput{
|
||||||
Bucket: aws.String(plugin.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Key: aws.String(remote),
|
Key: aws.String(remote),
|
||||||
})
|
})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AWS) List(path string) ([]string, error) {
|
func (a *AWS) List(path string) ([]string, error) {
|
||||||
plugin := a.plugin
|
p := a.plugin
|
||||||
|
remote := make([]string, 1)
|
||||||
remote := make([]string, 0)
|
|
||||||
|
|
||||||
resp, err := a.client.ListObjects(&s3.ListObjectsInput{
|
resp, err := a.client.ListObjects(&s3.ListObjectsInput{
|
||||||
Bucket: aws.String(plugin.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Prefix: aws.String(path),
|
Prefix: aws.String(path),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -406,7 +357,7 @@ func (a *AWS) List(path string) ([]string, error) {
|
||||||
|
|
||||||
for *resp.IsTruncated {
|
for *resp.IsTruncated {
|
||||||
resp, err = a.client.ListObjects(&s3.ListObjectsInput{
|
resp, err = a.client.ListObjects(&s3.ListObjectsInput{
|
||||||
Bucket: aws.String(plugin.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Prefix: aws.String(path),
|
Prefix: aws.String(path),
|
||||||
Marker: aws.String(remote[len(remote)-1]),
|
Marker: aws.String(remote[len(remote)-1]),
|
||||||
})
|
})
|
||||||
|
@ -425,9 +376,7 @@ func (a *AWS) List(path string) ([]string, error) {
|
||||||
|
|
||||||
func (a *AWS) Invalidate(invalidatePath string) error {
|
func (a *AWS) Invalidate(invalidatePath string) error {
|
||||||
p := a.plugin
|
p := a.plugin
|
||||||
|
|
||||||
logrus.Debugf("invalidating '%s'", invalidatePath)
|
logrus.Debugf("invalidating '%s'", invalidatePath)
|
||||||
|
|
||||||
_, err := a.cfClient.CreateInvalidation(&cloudfront.CreateInvalidationInput{
|
_, err := a.cfClient.CreateInvalidation(&cloudfront.CreateInvalidationInput{
|
||||||
DistributionId: aws.String(p.settings.CloudFrontDistribution),
|
DistributionId: aws.String(p.settings.CloudFrontDistribution),
|
||||||
InvalidationBatch: &cloudfront.InvalidationBatch{
|
InvalidationBatch: &cloudfront.InvalidationBatch{
|
||||||
|
@ -440,6 +389,5 @@ func (a *AWS) Invalidate(invalidatePath string) error {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,13 +44,14 @@ type Result struct {
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var MissingAwsValuesMessage = "Must set 'bucket'"
|
||||||
|
|
||||||
// Validate handles the settings validation of the plugin.
|
// Validate handles the settings validation of the plugin.
|
||||||
func (p *Plugin) Validate() error {
|
func (p *Plugin) Validate() error {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error while retrieving working directory: %w", err)
|
return fmt.Errorf("error while retrieving working directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
p.settings.Source = filepath.Join(wd, p.settings.Source)
|
p.settings.Source = filepath.Join(wd, p.settings.Source)
|
||||||
p.settings.Target = strings.TrimPrefix(p.settings.Target, "/")
|
p.settings.Target = strings.TrimPrefix(p.settings.Target, "/")
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ func (p *Plugin) createSyncJobs() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
local := make([]string, 0)
|
local := make([]string, 1)
|
||||||
|
|
||||||
err = filepath.Walk(p.settings.Source, func(path string, info os.FileInfo, err error) error {
|
err = filepath.Walk(p.settings.Source, func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil || info.IsDir() {
|
if err != nil || info.IsDir() {
|
||||||
|
@ -121,16 +122,13 @@ func (p *Plugin) createSyncJobs() error {
|
||||||
action: "redirect",
|
action: "redirect",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.settings.Delete {
|
if p.settings.Delete {
|
||||||
for _, remote := range remote {
|
for _, r := range remote {
|
||||||
found := false
|
found := false
|
||||||
remotePath := strings.TrimPrefix(remote, p.settings.Target+"/")
|
rPath := strings.TrimPrefix(r, p.settings.Target+"/")
|
||||||
|
|
||||||
for _, l := range local {
|
for _, l := range local {
|
||||||
if l == remotePath {
|
if l == rPath {
|
||||||
found = true
|
found = true
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +136,7 @@ func (p *Plugin) createSyncJobs() error {
|
||||||
if !found {
|
if !found {
|
||||||
p.settings.Jobs = append(p.settings.Jobs, Job{
|
p.settings.Jobs = append(p.settings.Jobs, Job{
|
||||||
local: "",
|
local: "",
|
||||||
remote: remote,
|
remote: r,
|
||||||
action: "delete",
|
action: "delete",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -152,46 +150,41 @@ func (p *Plugin) runJobs() error {
|
||||||
client := p.settings.Client
|
client := p.settings.Client
|
||||||
jobChan := make(chan struct{}, p.settings.MaxConcurrency)
|
jobChan := make(chan struct{}, p.settings.MaxConcurrency)
|
||||||
results := make(chan *Result, len(p.settings.Jobs))
|
results := make(chan *Result, len(p.settings.Jobs))
|
||||||
|
|
||||||
var invalidateJob *Job
|
var invalidateJob *Job
|
||||||
|
|
||||||
logrus.Infof("Synchronizing with bucket '%s'", p.settings.Bucket)
|
logrus.Infof("Synchronizing with bucket '%s'", p.settings.Bucket)
|
||||||
|
for _, j := range p.settings.Jobs {
|
||||||
for _, job := range p.settings.Jobs {
|
|
||||||
jobChan <- struct{}{}
|
jobChan <- struct{}{}
|
||||||
|
go func(j Job) {
|
||||||
go func(job Job) {
|
|
||||||
var err error
|
var err error
|
||||||
|
switch j.action {
|
||||||
switch job.action {
|
|
||||||
case "upload":
|
case "upload":
|
||||||
err = client.Upload(job.local, job.remote)
|
err = client.Upload(j.local, j.remote)
|
||||||
case "redirect":
|
case "redirect":
|
||||||
err = client.Redirect(job.local, job.remote)
|
err = client.Redirect(j.local, j.remote)
|
||||||
case "delete":
|
case "delete":
|
||||||
err = client.Delete(job.remote)
|
err = client.Delete(j.remote)
|
||||||
case "invalidateCloudFront":
|
case "invalidateCloudFront":
|
||||||
invalidateJob = &job
|
invalidateJob = &j
|
||||||
default:
|
default:
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
results <- &Result{job, err}
|
results <- &Result{j, err}
|
||||||
|
|
||||||
<-jobChan
|
<-jobChan
|
||||||
}(job)
|
}(j)
|
||||||
}
|
}
|
||||||
|
|
||||||
for range p.settings.Jobs {
|
for range p.settings.Jobs {
|
||||||
r := <-results
|
r := <-results
|
||||||
if r.err != nil {
|
if r.err != nil {
|
||||||
return fmt.Errorf("failed to %s %s to %s: %w", r.j.action, r.j.local, r.j.remote, r.err)
|
return fmt.Errorf("failed to %s %s to %s: %+v", r.j.action, r.j.local, r.j.remote, r.err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if invalidateJob != nil {
|
if invalidateJob != nil {
|
||||||
err := client.Invalidate(invalidateJob.remote)
|
err := client.Invalidate(invalidateJob.remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to %s %s to %s: %w", invalidateJob.action, invalidateJob.local, invalidateJob.remote, err)
|
return fmt.Errorf("failed to %s %s to %s: %+v", invalidateJob.action, invalidateJob.local, invalidateJob.remote, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ type Plugin struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// New initializes a plugin from the given Settings, Pipeline, and Network.
|
// New initializes a plugin from the given Settings, Pipeline, and Network.
|
||||||
func New(settings Settings, pipeline drone.Pipeline, network drone.Network) *Plugin {
|
func New(settings Settings, pipeline drone.Pipeline, network drone.Network) drone.Plugin {
|
||||||
return &Plugin{
|
return &Plugin{
|
||||||
settings: settings,
|
settings: settings,
|
||||||
pipeline: pipeline,
|
pipeline: pipeline,
|
||||||
|
|
4
renovate.json
Normal file
4
renovate.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": ["github>thegeeklab/renovate-presets:golang"]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user