66 Commits

Author SHA1 Message Date
Don bd1a8b3bb3 Update to latest boilr plugin 2020-09-14 20:41:56 -07:00
Don 6412ed1a76 Remove old .drone.yml 2020-06-27 09:16:51 -07:00
Don ec87b9d453 Migrate to drone-plugin-lib 2020-06-27 09:15:53 -07:00
Don 14a42b98ec Add starlark build 2020-06-27 09:14:18 -07:00
Don 50aa8ee7b9 Update dockerfiles 2020-06-27 09:13:40 -07:00
Don 92722b712a Merge pull request #30 from luthermonson/tool-v1.0.2
upgrading to manifest-tool 1.0.2
2020-05-28 07:36:19 -07:00
Luther b3f7912112 upgrading to manifest-tool 1.0.2 2020-05-27 12:08:04 -07:00
Thomas Boerger 2fe5f563a3 Merge pull request #28 from sh0rez/master
feat: allow to pass spec inline
2020-01-06 20:40:28 +01:00
Thomas Boerger 53c0cbbcef Merge branch 'master' into master 2020-01-06 20:37:35 +01:00
Thomas Boerger 2b1f33534d Merge pull request #29 from c0va23/feature/insecure-registry
Allow insecure and/or anonymous registry
2019-11-26 13:06:30 +01:00
Dmitrij Fedorenko 82ade6b5aa Allow anonymous access to registry 2019-11-26 08:33:10 +03:00
Dmitrij Fedorenko fe8c467e70 Add setting "insecure" 2019-11-26 08:29:56 +03:00
Dmitrij Fedorenko b2ea804f53 Upgrade manifest tools 1.0.0 2019-11-26 08:29:56 +03:00
Dmitrij Fedorenko 4bae79aec2 Upgrade alpine to 3.10 2019-11-23 21:45:27 +03:00
Brad Rydzewski 4a15a55224 enable auto tagging 2019-08-22 14:09:26 -07:00
Brad Rydzewski fbe23cbcec option to dump spec file to debug 2019-08-22 13:54:15 -07:00
Brad Rydzewski 3f387227b5 bump template lib and fix manifest trimPrefix 2019-08-22 13:16:53 -07:00
Brad Rydzewski bd53675813 remove microbadger [ci skip] 2019-08-22 13:04:41 -07:00
Brad Rydzewski 3091c4a002 update manifest template 2019-08-22 13:02:25 -07:00
sh0rez 35d6bee743 feat: allow to pass spec inline
This allows to pass the contents from `spec` directly from `drone.yml`, for use
with autogenerated drone configurations.
2019-08-14 16:40:13 +02:00
Thomas Boerger f92bc07dad Merge pull request #26 from deitch/fix-push-args
add from-args
2019-06-21 09:20:18 +02:00
Avi Deitcher 5b15413fc2 add from-args 2019-06-06 14:34:53 +03:00
Don af2017d35c Fix 1803 image 2019-04-25 17:58:29 -07:00
Don 5e8ab59d01 Use base again 2019-04-25 17:55:08 -07:00
Don 18cf775bd3 Fix Tls for Github 2019-04-25 17:31:35 -07:00
Don aaa402cdff Modify shell 2019-04-25 17:19:11 -07:00
Don bed8b9a1b2 Try servercore 2019-04-25 17:11:26 -07:00
Don e957ab3e04 Use 1809 for testing on windows 2019-04-25 16:46:56 -07:00
Don b548a9c07b Update windows build 2019-04-25 16:45:09 -07:00
Thomas Boerger a9899d8548 Merge pull request #22 from drone-plugins/improve-config
Drop renovate, proper version definition, unified jsonnet config
2019-02-19 11:34:48 +01:00
Thomas Boerger 3c0ccca611 Use new template lib, fix manifest 2019-02-19 11:33:06 +01:00
Thomas Boerger 8ed1b321f5 Drop import of unused fmt package 2019-02-18 23:47:41 +01:00
Thomas Boerger f976bb1992 Unified documentation and readme 2019-02-15 11:58:33 +01:00
Thomas Boerger 99d6654f37 Add a reliable version and integrate libsonnet definition 2019-02-15 10:24:13 +01:00
Thomas Boerger 0a2a640285 Drop renovate config, it is simply too noisy 2019-02-14 20:14:11 +01:00
Thomas Boerger 597acafbf7 Merge pull request #20 from appleboy/patch
feat(version): support 18.06.0 tag format
2019-02-12 15:01:41 +01:00
Bo-Yi Wu c2ba435fb8 feat(version): support 18.06.0 tag format 2019-02-12 18:42:32 +08:00
Thomas Boerger 7210ab5c16 Merge pull request #19 from drone-plugins/windows-dockerfiles
Add Windows Dockerfiles
2019-01-25 19:01:10 +01:00
Don 8b07050495 Use drive letters consistently 2019-01-25 09:45:05 -08:00
Don 120230dbd9 Add Windows Dockerfiles 2019-01-24 18:37:55 -08:00
Thomas Boerger 3b67f54e06 Merge pull request #18 from drone-plugins/upgrade-drone
Upgrade and switch to Drone 1.0.0
2019-01-23 11:06:39 +01:00
Thomas Boerger 14a12e1a63 Execute built binary as simple test 2019-01-22 23:12:20 +01:00
Thomas Boerger 74fe6c5c18 Add some basic issue template content 2019-01-21 21:02:09 +01:00
Thomas Boerger c9b38a9b94 Add probot settings config 2019-01-21 20:58:22 +01:00
Thomas Boerger d6a5823d13 Remove duplicated badge 2019-01-21 09:31:55 +01:00
Thomas Boerger 01a15fc1d3 Fix duplicated step names 2019-01-21 01:13:08 +01:00
Thomas Boerger 936bc709d6 Update badges within readme 2019-01-21 00:19:16 +01:00
Thomas Boerger 10252045dc Migrate configs to drone 1.0.0 and drop appveyor 2019-01-20 23:52:00 +01:00
Thomas Boerger 3490c0600d Add manifest template to docker folder 2019-01-20 22:21:25 +01:00
Thomas Boerger 7e39103352 Move dockerfiles to docker folder 2019-01-20 22:20:03 +01:00
renovate[bot] 0474975306 chore(deps): update module pkg/errors to v0.8.1 (#15)
This PR contains the following updates:

| Package | Type | Update | Change | References |
|---|---|---|---|---|
| github.com/pkg/errors | require | patch | `v0.8.0` -> `v0.8.1` | [source](https://togithub.com/pkg/errors) |

---

### Release Notes

<details>
<summary>pkg/errors</summary>

### [`v0.8.1`](https://togithub.com/pkg/errors/releases/v0.8.1)

[Compare Source](https://togithub.com/pkg/errors/compare/v0.8.0...v0.8.1)

pkg/errors 0.8.1 is a bug fix release for errors 0.8.0. It will be the last version to support Go 1.8 and below. pkg/errors 0.9 and above will require Go 1.9 for the new `runtime.CallersFrames` API.

pkg/errors 0.8.1 also adds one new feature, `errors.WithMessagef`. Ideally this would be held over til 0.9, but that complicates the switch to `runtime.CallersFrames`.

### Improvements

-   Added `errors.WithMessagef`. Thanks [@&#8203;chemicL](https://togithub.com/chemicL).

### Bugs fixed

-   `.travis.yml`. Adjust Go versions. Thanks [@&#8203;AlekSi](https://togithub.com/AlekSi), [@&#8203;dvrkps](https://togithub.com/dvrkps), [@&#8203;HaraldNordgren](https://togithub.com/HaraldNordgren), and [@&#8203;komuw](https://togithub.com/komuw) 
-   Fixed gofmt. Thanks [@&#8203;tariq1890](https://togithub.com/tariq1890) 
-   Copyedit the package documentation. Thanks [@&#8203;seh](https://togithub.com/seh), [@&#8203;TomSweeneyRedHat](https://togithub.com/TomSweeneyRedHat), [@&#8203;nicksnyder](https://togithub.com/nicksnyder), and [@&#8203;beono](https://togithub.com/beono) 
-   Remove unreachable code. Thanks [@&#8203;philoserf](https://togithub.com/philoserf) and [@&#8203;haya14busa](https://togithub.com/haya14busa) 
-   Move benchmark error sink to global variable. Thanks [@&#8203;bradleyfalzon](https://togithub.com/bradleyfalzon) 
-   Fix minor newline consistency issues in test files. Thanks [@&#8203;nmiyake](https://togithub.com/nmiyake) 
-   Add doc comment for exported Format func. Thanks [@&#8203;mrhwick](https://togithub.com/mrhwick) and [@&#8203;ihrwein](https://togithub.com/ihrwein)

</details>

---

### Renovate configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻️ **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#drone-plugins/drone-manifest).
2019-01-20 00:17:28 +08:00
Thomas Boerger 6c39a668da Merge pull request #12 from drone-plugins/renovate/configure
Configure Renovate
2019-01-19 11:58:14 +01:00
Thomas Boerger f311aa4112 Update renovate.json 2019-01-19 11:02:07 +01:00
Renovate Bot 1375e1d81a Add renovate.json 2019-01-19 02:57:16 +00:00
Bo-Yi Wu 9db5d7d3b3 feat(vendor): switch dep to go module (#11)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-01-11 11:49:20 +08:00
Thomas Boerger 5e6f1d304f Merge pull request #8 from drone-plugins/simplify-and-fix
Read spec and drop command package
2018-10-21 17:13:22 +02:00
Thomas Boerger ce1bc302b6 Merge branch 'master' into simplify-and-fix 2018-10-19 09:29:28 +02:00
Bo-Yi Wu c557b76905 update golang to 1.11 (#9) 2018-09-24 15:17:18 +08:00
Thomas Boerger ce5f88637a Updated dependencies 2018-09-23 21:40:21 +02:00
Thomas Boerger 8cd76befa0 Read spec and drop command package 2018-09-23 21:40:21 +02:00
Thomas Boerger f58ce02997 Merge pull request #7 from drone-plugins/appleboy-patch-1
Provide a password using STDIN
2018-09-22 19:22:53 +02:00
Bo-Yi Wu 0659f84908 Provide a password using STDIN 2018-06-30 20:55:44 +08:00
Thomas Boerger 98a19daff5 Merge pull request #6 from drone-plugins/template-lib
Use new template lib
2018-04-25 07:22:59 +02:00
Thomas Boerger 09b2a0b327 Print out dep status 2018-04-22 09:58:25 +02:00
Thomas Boerger 46a67c3a0c Use new template lib 2018-04-15 01:31:57 +02:00
Thomas Boerger d5e2e58801 Dropped unused struct 2018-04-15 01:26:08 +02:00
37 changed files with 1068 additions and 1013 deletions
-68
View File
@@ -1,68 +0,0 @@
version: '{build}'
image: 'Visual Studio 2017'
platform: 'x64'
clone_folder: 'c:\gopath\src\github.com\drone-plugins\drone-manifest'
max_jobs: 1
environment:
GOPATH: c:\gopath
DOCKER_USERNAME:
secure: '4YzzahbEiMZQJpOCOd1LAw=='
DOCKER_PASSWORD:
secure: 'VqO/G3Zfslu6zSLdwHKO+Q=='
install:
- ps: |
docker version
go version
- ps: |
$env:Path = "c:\gopath\bin;$env:Path"
build_script:
- ps: |
go get -u github.com/golang/dep/cmd/dep
dep ensure
if ( $env:APPVEYOR_REPO_TAG -eq 'false' ) {
go build -ldflags "-X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-manifest.exe
} else {
$version = $env:APPVEYOR_REPO_TAG_NAME.substring(1)
go build -ldflags "-X main.version=$version -X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-manifest.exe
}
docker pull microsoft/nanoserver:10.0.14393.1593
docker build -f Dockerfile.windows -t plugins/manifest:windows-amd64 .
test_script:
- ps: |
docker run --rm plugins/manifest:windows-amd64 --version
deploy_script:
- ps: |
$ErrorActionPreference = 'Stop';
if ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) {
Write-Host Nothing to deploy.
} else {
docker login --username $env:DOCKER_USERNAME --password $env:DOCKER_PASSWORD
if ( $env:APPVEYOR_REPO_TAG -eq 'true' ) {
$major,$minor,$patch = $env:APPVEYOR_REPO_TAG_NAME.substring(1).split('.')
docker push plugins/manifest:windows-amd64
docker tag plugins/manifest:windows-amd64 plugins/manifest:$major.$minor.$patch-windows-amd64
docker push plugins/manifest:$major.$minor.$patch-windows-amd64
docker tag plugins/manifest:windows-amd64 plugins/manifest:$major.$minor-windows-amd64
docker push plugins/manifest:$major.$minor-windows-amd64
docker tag plugins/manifest:windows-amd64 plugins/manifest:$major-windows-amd64
docker push plugins/manifest:$major-windows-amd64
} else {
if ( $env:APPVEYOR_REPO_BRANCH -eq 'master' ) {
docker push plugins/manifest:windows-amd64
}
}
}
+357
View File
@@ -0,0 +1,357 @@
def main(ctx):
before = testing(ctx)
stages = [
linux(ctx, 'amd64'),
linux(ctx, 'arm64'),
linux(ctx, 'arm'),
windows(ctx, '1903'),
windows(ctx, '1809'),
]
after = manifest(ctx) + gitter(ctx)
for b in before:
for s in stages:
s['depends_on'].append(b['name'])
for s in stages:
for a in after:
a['depends_on'].append(s['name'])
return before + stages + after
def testing(ctx):
return [{
'kind': 'pipeline',
'type': 'docker',
'name': 'testing',
'platform': {
'os': 'linux',
'arch': 'amd64',
},
'steps': [
{
'name': 'staticcheck',
'image': 'golang:1.14',
'pull': 'always',
'commands': [
'go run honnef.co/go/tools/cmd/staticcheck ./...',
],
'volumes': [
{
'name': 'gopath',
'path': '/go',
},
],
},
{
'name': 'lint',
'image': 'golang:1.14',
'pull': 'always',
'commands': [
'go run golang.org/x/lint/golint -set_exit_status ./...',
],
'volumes': [
{
'name': 'gopath',
'path': '/go',
},
],
},
{
'name': 'vet',
'image': 'golang:1.14',
'pull': 'always',
'commands': [
'go vet ./...',
],
'volumes': [
{
'name': 'gopath',
'path': '/go',
},
],
},
{
'name': 'test',
'image': 'golang:1.14',
'pull': 'always',
'commands': [
'go test -cover ./...',
],
'volumes': [
{
'name': 'gopath',
'path': '/go',
},
],
},
],
'volumes': [
{
'name': 'gopath',
'temp': {},
},
],
'trigger': {
'ref': [
'refs/heads/master',
'refs/tags/**',
'refs/pull/**',
],
},
}]
def linux(ctx, arch):
docker = {
'dockerfile': 'docker/Dockerfile.linux.%s' % (arch),
'repo': 'plugins/manifest',
'username': {
'from_secret': 'docker_username',
},
'password': {
'from_secret': 'docker_password',
},
}
if ctx.build.event == 'pull_request':
docker.update({
'dry_run': True,
'tags': 'linux-%s' % (arch),
})
else:
docker.update({
'auto_tag': True,
'auto_tag_suffix': 'linux-%s' % (arch),
})
if ctx.build.event == 'tag':
build = [
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-manifest ./cmd/drone-manifest' % (ctx.build.ref.replace("refs/tags/v", ""), arch),
]
else:
build = [
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-manifest ./cmd/drone-manifest' % (ctx.build.commit[0:8], arch),
]
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'linux-%s' % (arch),
'platform': {
'os': 'linux',
'arch': arch,
},
'steps': [
{
'name': 'environment',
'image': 'golang:1.14',
'pull': 'always',
'environment': {
'CGO_ENABLED': '0',
},
'commands': [
'go version',
'go env',
],
},
{
'name': 'build',
'image': 'golang:1.14',
'pull': 'always',
'environment': {
'CGO_ENABLED': '0',
},
'commands': build,
},
{
'name': 'executable',
'image': 'golang:1.14',
'pull': 'always',
'commands': [
'./release/linux/%s/drone-manifest --help' % (arch),
],
},
{
'name': 'docker',
'image': 'plugins/docker',
'pull': 'always',
'settings': docker,
},
],
'depends_on': [],
'trigger': {
'ref': [
'refs/heads/master',
'refs/tags/**',
'refs/pull/**',
],
},
}
def windows(ctx, version):
docker = [
'echo $env:PASSWORD | docker login --username $env:USERNAME --password-stdin',
]
if ctx.build.event == 'tag':
build = [
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/windows/amd64/drone-manifest.exe ./cmd/drone-manifest' % (ctx.build.ref.replace("refs/tags/v", "")),
]
docker = docker + [
'docker build --pull -f docker/Dockerfile.windows.%s -t plugins/manifest:%s-windows-%s-amd64 .' % (version, ctx.build.ref.replace("refs/tags/v", ""), version),
'docker run --rm plugins/manifest:%s-windows-%s-amd64 --help' % (ctx.build.ref.replace("refs/tags/v", ""), version),
'docker push plugins/manifest:%s-windows-%s-amd64' % (ctx.build.ref.replace("refs/tags/v", ""), version),
]
else:
build = [
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/windows/amd64/drone-manifest.exe ./cmd/drone-manifest' % (ctx.build.commit[0:8]),
]
docker = docker + [
'docker build --pull -f docker/Dockerfile.windows.%s -t plugins/manifest:windows-%s-amd64 .' % (version, version),
'docker run --rm plugins/manifest:windows-%s-amd64 --help' % (version),
'docker push plugins/manifest:windows-%s-amd64' % (version),
]
return {
'kind': 'pipeline',
'type': 'ssh',
'name': 'windows-%s' % (version),
'platform': {
'os': 'windows',
},
'server': {
'host': {
'from_secret': 'windows_server_%s' % (version),
},
'user': {
'from_secret': 'windows_username',
},
'password': {
'from_secret': 'windows_password',
},
},
'steps': [
{
'name': 'environment',
'environment': {
'CGO_ENABLED': '0',
},
'commands': [
'go version',
'go env',
],
},
{
'name': 'build',
'environment': {
'CGO_ENABLED': '0',
},
'commands': build,
},
{
'name': 'executable',
'commands': [
'./release/windows/amd64/drone-manifest.exe --help',
],
},
{
'name': 'docker',
'environment': {
'USERNAME': {
'from_secret': 'docker_username',
},
'PASSWORD': {
'from_secret': 'docker_password',
},
},
'commands': docker,
},
],
'depends_on': [],
'trigger': {
'ref': [
'refs/heads/master',
'refs/tags/**',
],
},
}
def manifest(ctx):
return [{
'kind': 'pipeline',
'type': 'docker',
'name': 'manifest',
'steps': [
{
'name': 'manifest',
'image': 'plugins/manifest',
'pull': 'always',
'settings': {
'auto_tag': 'true',
'username': {
'from_secret': 'docker_username',
},
'password': {
'from_secret': 'docker_password',
},
'spec': 'docker/manifest.tmpl',
'ignore_missing': 'true',
},
},
{
'name': 'microbadger',
'image': 'plugins/webhook',
'pull': 'always',
'settings': {
'urls': {
'from_secret': 'microbadger_url',
},
},
},
],
'depends_on': [],
'trigger': {
'ref': [
'refs/heads/master',
'refs/tags/**',
],
},
}]
def gitter(ctx):
return [{
'kind': 'pipeline',
'type': 'docker',
'name': 'gitter',
'clone': {
'disable': True,
},
'steps': [
{
'name': 'gitter',
'image': 'plugins/gitter',
'pull': 'always',
'settings': {
'webhook': {
'from_secret': 'gitter_webhook',
}
},
},
],
'depends_on': [
'manifest',
],
'trigger': {
'ref': [
'refs/heads/master',
'refs/tags/**',
],
'status': [
'failure',
],
},
}]
-148
View File
@@ -1,148 +0,0 @@
workspace:
base: /go
path: src/github.com/drone-plugins/drone-manifest
pipeline:
deps:
image: golang:1.10
pull: true
commands:
- go get -u github.com/golang/dep/cmd/dep
- dep ensure
test:
image: golang:1.10
pull: true
commands:
- go vet ./...
- go test -cover ./...
build_linux_amd64:
image: golang:1.10
pull: true
group: build
environment:
- GOOS=linux
- GOARCH=amd64
- CGO_ENABLED=0
commands:
- |
if test "${DRONE_TAG}" = ""; then
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-manifest
else
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-manifest
fi
build_linux_i386:
image: golang:1.10
pull: true
group: build
environment:
- GOOS=linux
- GOARCH=386
- CGO_ENABLED=0
commands:
- |
if test "${DRONE_TAG}" = ""; then
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-manifest
else
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-manifest
fi
build_linux_arm64:
image: golang:1.10
pull: true
group: build
environment:
- GOOS=linux
- GOARCH=arm64
- CGO_ENABLED=0
commands:
- |
if test "${DRONE_TAG}" = ""; then
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-manifest
else
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-manifest
fi
build_linux_arm:
image: golang:1.10
pull: true
group: build
environment:
- GOOS=linux
- GOARCH=arm
- CGO_ENABLED=0
- GOARM=7
commands:
- |
if test "${DRONE_TAG}" = ""; then
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-manifest
else
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-manifest
fi
publish_linux_amd64:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: plugins/manifest
auto_tag: true
auto_tag_suffix: linux-amd64
dockerfile: Dockerfile
when:
event: [ push, tag ]
publish_linux_i386:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: plugins/manifest
auto_tag: true
auto_tag_suffix: linux-i386
dockerfile: Dockerfile.i386
when:
event: [ push, tag ]
publish_linux_arm64:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: plugins/manifest
auto_tag: true
auto_tag_suffix: linux-arm64
dockerfile: Dockerfile.arm64
when:
event: [ push, tag ]
publish_linux_arm:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: plugins/manifest
auto_tag: true
auto_tag_suffix: linux-arm
dockerfile: Dockerfile.arm
when:
event: [ push, tag ]
manifests:
image: plugins/manifest:1
pull: true
secrets: [ docker_username, docker_password ]
spec: manifest.tmpl
auto_tag: true
ignore_missing: true
when:
event: [ push, tag ]
microbadger:
image: plugins/webhook:1
pull: true
secrets: [ webhook_url ]
when:
status: [ success ]
+9
View File
@@ -0,0 +1,9 @@
<!-- PLEASE READ BEFORE DELETING
Bugs or Issues? Due to the high number of false positive issues we receive,
please do not create a GitHub issue until you have discussed and verified
with community support at:
https://discourse.drone.io/
-->
+73
View File
@@ -0,0 +1,73 @@
repository:
name: drone-manifest
description: Drone plugin to push Docker manifests
homepage: http://plugins.drone.io/drone-plugins/drone-manifest
topics: drone, drone-plugin
private: false
has_issues: true
has_wiki: false
has_downloads: false
default_branch: master
allow_squash_merge: true
allow_merge_commit: true
allow_rebase_merge: true
labels:
- name: bug
color: d73a4a
description: Something isn't working
- name: duplicate
color: cfd3d7
description: This issue or pull request already exists
- name: enhancement
color: a2eeef
description: New feature or request
- name: good first issue
color: 7057ff
description: Good for newcomers
- name: help wanted
color: 008672
description: Extra attention is needed
- name: invalid
color: e4e669
description: This doesn't seem right
- name: question
color: d876e3
description: Further information is requested
- name: renovate
color: e99695
description: Automated action from Renovate
- name: wontfix
color: ffffff
description: This will not be worked on
teams:
- name: Admins
permission: admin
- name: Captain
permission: admin
- name: Maintainers
permission: push
branches:
- name: master
protection:
required_pull_request_reviews:
required_approving_review_count: 1
dismiss_stale_reviews: false
require_code_owner_reviews: false
dismissal_restrictions:
teams:
- Admins
- Captain
required_status_checks:
strict: true
contexts:
- continuous-integration/drone/pr
enforce_admins: false
restrictions:
users: []
teams: []
+3 -28
View File
@@ -1,30 +1,5 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof
release/
vendor/
/release/
/drone-manifest*
coverage.out
drone-manifest
.drone.yml
-17
View File
@@ -1,17 +0,0 @@
FROM alpine:3.6 as base
RUN apk add --no-cache curl && \
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-386 && \
chmod +x /bin/manifest-tool
FROM plugins/base:multiarch
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
org.label-schema.name="Drone Manifest" \
org.label-schema.vendor="Drone.IO Community" \
org.label-schema.schema-version="1.0"
COPY --from=base /bin/manifest-tool /bin/
ADD release/linux/i386/drone-manifest /bin/
ENTRYPOINT ["/bin/drone-manifest"]
-14
View File
@@ -1,14 +0,0 @@
# escape=`
FROM microsoft/nanoserver:10.0.14393.1593
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Manifest" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Invoke-WebRequest 'https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-windows-amd64.exe' -OutFile 'c:\Windows\System32\manifest-tool.exe';
ADD release\drone-manifest.exe c:\drone-manifest.exe
ENTRYPOINT [ "c:\\drone-manifest.exe" ]
Generated
-33
View File
@@ -1,33 +0,0 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
name = "github.com/aymerick/raymond"
packages = [".","ast","lexer","parser"]
revision = "a2232af10b53ef1ae5a767f5178db3a6c1dab655"
version = "v2.0.1"
[[projects]]
name = "github.com/coreos/go-semver"
packages = ["semver"]
revision = "8ab6407b697782a06568d4b7f1db25550ec2e4c6"
version = "v0.2.0"
[[projects]]
name = "github.com/pkg/errors"
packages = ["."]
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
version = "v0.8.0"
[[projects]]
branch = "master"
name = "github.com/urfave/cli"
packages = ["."]
revision = "75104e932ac2ddb944a6ea19d9f9f26316ff1145"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "a89f1c3cf068c93fd8bf83840a119df2915c502193ca71a2b5ae4b6a6cfa4d70"
solver-name = "gps-cdcl"
solver-version = 1
-15
View File
@@ -1,15 +0,0 @@
[[constraint]]
name = "github.com/aymerick/raymond"
version = "2.0.1"
[[constraint]]
name = "github.com/coreos/go-semver"
version = "0.2.0"
[[constraint]]
name = "github.com/pkg/errors"
version = "0.8.0"
[[constraint]]
branch = "master"
name = "github.com/urfave/cli"
-1
View File
@@ -199,4 +199,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+19 -11
View File
@@ -1,34 +1,42 @@
# drone-manifest
[![Build Status](http://beta.drone.io/api/badges/drone-plugins/drone-manifest/status.svg)](http://beta.drone.io/drone-plugins/drone-manifest)
[![Build Status](http://cloud.drone.io/api/badges/drone-plugins/drone-manifest/status.svg)](http://cloud.drone.io/drone-plugins/drone-manifest)
[![Gitter chat](https://badges.gitter.im/drone/drone.png)](https://gitter.im/drone/drone)
[![Join the discussion at https://discourse.drone.io](https://img.shields.io/badge/discourse-forum-orange.svg)](https://discourse.drone.io)
[![Drone questions at https://stackoverflow.com](https://img.shields.io/badge/drone-stackoverflow-orange.svg)](https://stackoverflow.com/questions/tagged/drone.io)
[![](https://images.microbadger.com/badges/image/plugins/manifest.svg)](https://microbadger.com/images/plugins/manifest "Get your own image badge on microbadger.com")
[![Go Doc](https://godoc.org/github.com/drone-plugins/drone-manifest?status.svg)](http://godoc.org/github.com/drone-plugins/drone-manifest)
[![Go Report](https://goreportcard.com/badge/github.com/drone-plugins/drone-manifest)](https://goreportcard.com/report/github.com/drone-plugins/drone-manifest)
[![](https://images.microbadger.com/badges/image/plugins/manifest.svg)](https://microbadger.com/images/plugins/manifest "Get your own image badge on microbadger.com")
Drone plugin to push Docker manifest to a registry for multi-architecture mappings. For the usage information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/drone-plugins/drone-manifest/).
## Build
Build the binary with the following commands:
Build the binary with the following command:
```
go build
```console
export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on
go build -v -a -tags netgo -o release/linux/amd64/drone-manifest
```
## Docker
Build the Docker image with the following commands:
Build the Docker image with the following command:
```
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-manifest
docker build --rm -t plugins/manifest .
```console
docker build \
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
--file docker/Dockerfile.linux.amd64 --tag plugins/manifest .
```
### Usage
## Usage
```
```console
docker run --rm \
-e PLUGIN_PLATFORMS=linux/amd64,linux/arm,linux/arm64 \
-e PLUGIN_TEMPLATE=organization/project-ARCH:1.0.0 \
+78
View File
@@ -0,0 +1,78 @@
// Copyright (c) 2020, the Drone Plugins project authors.
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license that can be
// found in the LICENSE file.
package main
import (
"github.com/drone-plugins/drone-manifest/plugin"
"github.com/urfave/cli/v2"
)
// settingsFlags has the cli.Flags for the plugin.Settings.
func settingsFlags(settings *plugin.Settings) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "username",
Usage: "username for registry",
EnvVars: []string{"PLUGIN_USERNAME", "MANIFEST_USERNAME", "DOCKER_USERNAME"},
Destination: &settings.Username,
},
&cli.StringFlag{
Name: "password",
Usage: "password for registry",
EnvVars: []string{"PLUGIN_PASSWORD", "MANIFEST_PASSWORD", "DOCKER_PASSWORD"},
Destination: &settings.Password,
},
&cli.BoolFlag{
Name: "insecure",
Usage: "enable allow insecure registry",
EnvVars: []string{"PLUGIN_INSECURE"},
Destination: &settings.Insecure,
},
&cli.StringSliceFlag{
Name: "platforms",
Usage: "platforms for manifests",
EnvVars: []string{"PLUGIN_PLATFORMS"},
Destination: &settings.Platforms,
},
&cli.StringFlag{
Name: "target",
Usage: "target for manifests",
EnvVars: []string{"PLUGIN_TARGET"},
Destination: &settings.Target,
},
&cli.StringFlag{
Name: "template",
Usage: "template for manifests",
EnvVars: []string{"PLUGIN_TEMPLATE"},
Destination: &settings.Template,
},
&cli.StringFlag{
Name: "spec",
Usage: "path to manifest spec",
EnvVars: []string{"PLUGIN_SPEC"},
Destination: &settings.Spec,
},
&cli.BoolFlag{
Name: "ignore-missing",
Usage: "ignore missing images",
EnvVars: []string{"PLUGIN_IGNORE_MISSING"},
Destination: &settings.IgnoreMissing,
},
&cli.StringSliceFlag{
Name: "tags",
Usage: "list of additional tags",
EnvVars: []string{"PLUGIN_TAG", "PLUGIN_TAGS"},
FilePath: ".tags",
Destination: &settings.Tags,
},
&cli.BoolFlag{
Name: "tags.auto",
Usage: "automatically build tags",
EnvVars: []string{"PLUGIN_DEFAULT_TAGS", "PLUGIN_AUTO_TAG"},
Destination: &settings.AutoTag,
},
}
}
+70
View File
@@ -0,0 +1,70 @@
// Copyright (c) 2020, the Drone Plugins project authors.
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license that can be
// found in the LICENSE file.
// DO NOT MODIFY THIS FILE DIRECTLY
package main
import (
"os"
"github.com/drone-plugins/drone-manifest/plugin"
"github.com/drone-plugins/drone-plugin-lib/errors"
"github.com/drone-plugins/drone-plugin-lib/urfave"
"github.com/joho/godotenv"
"github.com/urfave/cli/v2"
)
var version = "unknown"
func main() {
settings := &plugin.Settings{}
if _, err := os.Stat("/run/drone/env"); err == nil {
godotenv.Overload("/run/drone/env")
}
app := &cli.App{
Name: "drone-manifest",
Usage: "push a docker manifest",
Version: version,
Flags: append(settingsFlags(settings), urfave.Flags()...),
Action: run(settings),
}
if err := app.Run(os.Args); err != nil {
errors.HandleExit(err)
}
}
func run(settings *plugin.Settings) cli.ActionFunc {
return func(ctx *cli.Context) error {
urfave.LoggingFromContext(ctx)
plugin := plugin.New(
*settings,
urfave.PipelineFromContext(ctx),
urfave.NetworkFromContext(ctx),
)
if err := plugin.Validate(); err != nil {
if e, ok := err.(errors.ExitCoder); ok {
return e
}
return errors.ExitMessagef("validation failed: %w", err)
}
if err := plugin.Execute(); err != nil {
if e, ok := err.(errors.ExitCoder); ok {
return e
}
return errors.ExitMessagef("execution failed: %w", err)
}
return nil
}
}
-102
View File
@@ -1,102 +0,0 @@
package command
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"strings"
"github.com/pkg/errors"
)
type Command struct {
username string
password string
spec string
platforms []string
target string
template string
path string
ignoreMissing bool
}
func New(opts ...Option) *Command {
c := &Command{}
for _, opt := range opts {
opt(c)
}
return c
}
func (c *Command) Exec() error {
args := []string{}
if c.username != "" {
args = append(args, fmt.Sprintf("--username=%s", c.username))
}
if c.password != "" {
args = append(args, fmt.Sprintf("--password=%s", c.password))
}
args = append(args, "push")
if c.spec != "" {
tmpfile, err := ioutil.TempFile(c.path, "manifest-")
if err != nil {
return errors.Wrap(err, "failed to create tempfile")
}
defer os.Remove(tmpfile.Name())
if _, err := tmpfile.Write([]byte(c.spec)); err != nil {
return errors.Wrap(err, "failed to write tempfile")
}
if err := tmpfile.Close(); err != nil {
return errors.Wrap(err, "failed to close temp file")
}
args = append(args, "from-spec")
args = append(args, tmpfile.Name())
} else {
args = append(args, "from-args")
if len(c.platforms) != 0 {
args = append(args, fmt.Sprintf("--platforms=%s", strings.Join(c.platforms, ",")))
}
if c.target != "" {
args = append(args, fmt.Sprintf("--target=%s", c.target))
}
if c.template != "" {
args = append(args, fmt.Sprintf("--template=%s", c.template))
}
}
if c.ignoreMissing {
args = append(args, "--ignore-missing")
}
cmd := exec.Command(
"manifest-tool",
args...,
)
buf := bytes.NewBufferString("")
cmd.Stdout = io.MultiWriter(os.Stdout, buf)
cmd.Stderr = io.MultiWriter(os.Stderr, buf)
if c.path != "" {
cmd.Dir = c.path
}
return cmd.Run()
}
-51
View File
@@ -1,51 +0,0 @@
package command
type Option func(*Command)
func WithUsername(val string) Option {
return func(t *Command) {
t.username = val
}
}
func WithPassword(val string) Option {
return func(t *Command) {
t.password = val
}
}
func WithSpec(val string) Option {
return func(t *Command) {
t.spec = val
}
}
func WithPlatforms(val []string) Option {
return func(t *Command) {
t.platforms = val
}
}
func WithTarget(val string) Option {
return func(t *Command) {
t.target = val
}
}
func WithTemplate(val string) Option {
return func(t *Command) {
t.template = val
}
}
func WithPath(val string) Option {
return func(t *Command) {
t.path = val
}
}
func IgnoreMissing() Option {
return func(t *Command) {
t.ignoreMissing = true
}
}
+5 -3
View File
@@ -1,7 +1,9 @@
FROM alpine:3.6 as base
FROM alpine:3.12 as base
ENV MANIFEST_TOOL_VERSION 1.0.2
RUN apk add --no-cache curl && \
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64 && \
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v${MANIFEST_TOOL_VERSION}/manifest-tool-linux-amd64 && \
chmod +x /bin/manifest-tool
FROM plugins/base:multiarch
@@ -14,4 +16,4 @@ LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
COPY --from=base /bin/manifest-tool /bin/
ADD release/linux/amd64/drone-manifest /bin/
ENTRYPOINT ["/bin/drone-manifest"]
ENTRYPOINT [ "/bin/drone-manifest" ]
@@ -1,7 +1,9 @@
FROM alpine:3.6 as base
FROM alpine:3.12 as base
ENV MANIFEST_TOOL_VERSION 1.0.2
RUN apk add --no-cache curl && \
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-armv7 && \
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v${MANIFEST_TOOL_VERSION}/manifest-tool-linux-armv7 && \
chmod +x /bin/manifest-tool
FROM plugins/base:multiarch
@@ -14,4 +16,4 @@ LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
COPY --from=base /bin/manifest-tool /bin/
ADD release/linux/arm/drone-manifest /bin/
ENTRYPOINT ["/bin/drone-manifest"]
ENTRYPOINT [ "/bin/drone-manifest" ]
@@ -1,7 +1,9 @@
FROM alpine:3.6 as base
FROM alpine:3.12 as base
ENV MANIFEST_TOOL_VERSION 1.0.2
RUN apk add --no-cache curl && \
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-arm64 && \
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v${MANIFEST_TOOL_VERSION}/manifest-tool-linux-arm64 && \
chmod +x /bin/manifest-tool
FROM plugins/base:multiarch
@@ -14,4 +16,4 @@ LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
COPY --from=base /bin/manifest-tool /bin/
ADD release/linux/arm64/drone-manifest /bin/
ENTRYPOINT ["/bin/drone-manifest"]
ENTRYPOINT [ "/bin/drone-manifest" ]
+16
View File
@@ -0,0 +1,16 @@
# escape=`
FROM plugins/base:windows-1809-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Manifest" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ENV MANIFEST_TOOL_VERSION 1.0.2
RUN New-Item -ItemType directory -Path 'C:/bin'; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
Invoke-WebRequest ('https://github.com/estesp/manifest-tool/releases/download/v{0}/manifest-tool-windows-amd64.exe' -f $env:MANIFEST_TOOL_VERSION) -OutFile 'C:/bin/manifest-tool.exe';
ADD release/windows/amd64/drone-manifest.exe C:/bin/drone-manifest.exe
ENTRYPOINT [ "C:\\bin\\drone-manifest.exe" ]
+16
View File
@@ -0,0 +1,16 @@
# escape=`
FROM plugins/base:windows-1903-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Manifest" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ENV MANIFEST_TOOL_VERSION 1.0.2
RUN New-Item -ItemType directory -Path 'C:/bin'; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
Invoke-WebRequest ('https://github.com/estesp/manifest-tool/releases/download/v{0}/manifest-tool-windows-amd64.exe' -f $env:MANIFEST_TOOL_VERSION) -OutFile 'C:/bin/manifest-tool.exe';
ADD release/windows/amd64/drone-manifest.exe C:/bin/drone-manifest.exe
ENTRYPOINT [ "C:\\bin\\drone-manifest.exe" ]
+16
View File
@@ -0,0 +1,16 @@
# escape=`
FROM plugins/base:windows-1909-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Manifest" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ENV MANIFEST_TOOL_VERSION 1.0.2
RUN New-Item -ItemType directory -Path 'C:/bin'; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
Invoke-WebRequest ('https://github.com/estesp/manifest-tool/releases/download/v{0}/manifest-tool-windows-amd64.exe' -f $env:MANIFEST_TOOL_VERSION) -OutFile 'C:/bin/manifest-tool.exe';
ADD release/windows/amd64/drone-manifest.exe C:/bin/drone-manifest.exe
ENTRYPOINT [ "C:\\bin\\drone-manifest.exe" ]
+16
View File
@@ -0,0 +1,16 @@
# escape=`
FROM plugins/base:windows-2004-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Manifest" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ENV MANIFEST_TOOL_VERSION 1.0.2
RUN New-Item -ItemType directory -Path 'C:/bin'; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
Invoke-WebRequest ('https://github.com/estesp/manifest-tool/releases/download/v{0}/manifest-tool-windows-amd64.exe' -f $env:MANIFEST_TOOL_VERSION) -OutFile 'C:/bin/manifest-tool.exe';
ADD release/windows/amd64/drone-manifest.exe C:/bin/drone-manifest.exe
ENTRYPOINT [ "C:\\bin\\drone-manifest.exe" ]
+44
View File
@@ -0,0 +1,44 @@
image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
- image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
architecture: arm64
os: linux
variant: v8
- image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
architecture: arm
os: linux
variant: v7
- image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-2004-amd64
platform:
architecture: amd64
os: windows
version: 2004
- image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
platform:
architecture: amd64
os: windows
version: 1909
- image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
platform:
architecture: amd64
os: windows
version: 1903
- image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform:
architecture: amd64
os: windows
version: 1809
+11
View File
@@ -0,0 +1,11 @@
module github.com/drone-plugins/drone-manifest
go 1.14
require (
github.com/coreos/go-semver v0.3.0
github.com/drone-plugins/drone-plugin-lib v0.3.1
github.com/drone/drone-template-lib v1.0.0
github.com/joho/godotenv v1.3.0
github.com/urfave/cli/v2 v2.2.0
)
+55
View File
@@ -0,0 +1,55 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/sprig v2.18.0+incompatible h1:QoGhlbC6pter1jxKnjMFxT8EqsLuDE6FEcNbWEpw+lI=
github.com/Masterminds/sprig v2.18.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/bouk/monkey v1.0.0 h1:k6z8fLlPhETfn5l9rlWVE7Q6B23DoaqosTdArvNQRdc=
github.com/bouk/monkey v1.0.0/go.mod h1:PG/63f4XEUlVyW1ttIeOJmJhhe1+t9EC/je3eTjvFhE=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/drone-plugins/drone-plugin-lib v0.3.1 h1:Br43wRnot2CpDGKPIKOnIxkTsuII5q4xxKROirs5hxc=
github.com/drone-plugins/drone-plugin-lib v0.3.1/go.mod h1:ZUKtwSoUmeCj7DXMS3WktDdMAWudW7O6dYAZZRISv4M=
github.com/drone/drone-template-lib v1.0.0 h1:PNBBfUhifRnrPCoWBlTitk3jipXdv8u8WLbIf7h7j00=
github.com/drone/drone-template-lib v1.0.0/go.mod h1:Hqy1tgqPH5mtbFOZmow19l4jOkZvp+WZ00cB4W3MJhg=
github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s=
github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=
github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4=
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/tkuchiki/faketime v0.0.0-20170607100027-a4500a4f4643 h1:ii/sHfgFMByozryLeiDmn1ClZ/Pena4NgpJ4P7UuX9o=
github.com/tkuchiki/faketime v0.0.0-20170607100027-a4500a4f4643/go.mod h1:RXY/TXAwGGL36IKDjrHFMcjpUrEiyWSEtLhFPw3UWF0=
github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 h1:ng3VDlRp5/DHpSWl02R4rM9I+8M2rhmsuLwAMmkLQWE=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-210
View File
@@ -1,210 +0,0 @@
package main
import (
"fmt"
"log"
"os"
"github.com/drone-plugins/drone-manifest/tagging"
"github.com/urfave/cli"
)
var (
version = "0.0.0"
build = "0"
)
func main() {
app := cli.NewApp()
app.Name = "manifest plugin"
app.Usage = "manifest plugin"
app.Version = fmt.Sprintf("%s+%s", version, build)
app.Action = run
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "username",
Usage: "username for registry",
EnvVar: "PLUGIN_USERNAME,MANIFEST_USERNAME,DOCKER_USERNAME",
},
cli.StringFlag{
Name: "password",
Usage: "password for registry",
EnvVar: "PLUGIN_PASSWORD,MANIFEST_PASSWORD,DOCKER_PASSWORD",
},
cli.StringSliceFlag{
Name: "platforms",
Usage: "platforms for manifests",
EnvVar: "PLUGIN_PLATFORMS",
},
cli.StringFlag{
Name: "target",
Usage: "target for manifests",
EnvVar: "PLUGIN_TARGET",
},
cli.StringFlag{
Name: "template",
Usage: "template for manifests",
EnvVar: "PLUGIN_TEMPLATE",
},
cli.StringFlag{
Name: "spec",
Usage: "path to manifest spec",
EnvVar: "PLUGIN_SPEC",
},
cli.BoolFlag{
Name: "ignore-missing",
Usage: "ignore missing images",
EnvVar: "PLUGIN_IGNORE_MISSING",
},
cli.StringSliceFlag{
Name: "tags",
Usage: "list of additional tags",
Value: &cli.StringSlice{},
EnvVar: "PLUGIN_TAG,PLUGIN_TAGS",
FilePath: ".tags",
},
cli.BoolFlag{
Name: "tags.auto",
Usage: "automatically build tags",
EnvVar: "PLUGIN_DEFAULT_TAGS,PLUGIN_AUTO_TAG",
},
cli.StringFlag{
Name: "path",
Usage: "git clone path",
EnvVar: "DRONE_WORKSPACE",
},
cli.StringFlag{
Name: "repo.owner",
Usage: "repository owner",
EnvVar: "DRONE_REPO_OWNER",
},
cli.StringFlag{
Name: "repo.name",
Usage: "repository name",
EnvVar: "DRONE_REPO_NAME",
},
cli.StringFlag{
Name: "repo.branch",
Usage: "repository default branch",
EnvVar: "DRONE_REPO_BRANCH",
},
cli.StringFlag{
Name: "commit.sha",
Usage: "git commit sha",
EnvVar: "DRONE_COMMIT_SHA",
Value: "00000000",
},
cli.StringFlag{
Name: "commit.ref",
Usage: "git commit ref",
EnvVar: "DRONE_COMMIT_REF",
},
cli.StringFlag{
Name: "commit.branch",
Value: "master",
Usage: "git commit branch",
EnvVar: "DRONE_COMMIT_BRANCH",
},
cli.StringFlag{
Name: "commit.pull",
Usage: "git pull request",
EnvVar: "DRONE_PULL_REQUEST",
},
cli.StringFlag{
Name: "build.event",
Value: "push",
Usage: "build event",
EnvVar: "DRONE_BUILD_EVENT",
},
cli.IntFlag{
Name: "build.number",
Usage: "build number",
EnvVar: "DRONE_BUILD_NUMBER",
},
cli.StringFlag{
Name: "build.status",
Usage: "build status",
Value: "success",
EnvVar: "DRONE_BUILD_STATUS",
},
cli.StringFlag{
Name: "build.link",
Usage: "build link",
EnvVar: "DRONE_BUILD_LINK",
},
cli.Int64Flag{
Name: "build.started",
Usage: "build started",
EnvVar: "DRONE_BUILD_STARTED",
},
cli.Int64Flag{
Name: "build.created",
Usage: "build created",
EnvVar: "DRONE_BUILD_CREATED",
},
cli.StringFlag{
Name: "build.tag",
Usage: "build tag",
EnvVar: "DRONE_TAG",
},
cli.Int64Flag{
Name: "job.started",
Usage: "job started",
EnvVar: "DRONE_JOB_STARTED",
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}
func run(c *cli.Context) error {
plugin := Plugin{
Repo: Repo{
Owner: c.String("repo.owner"),
Name: c.String("repo.name"),
Branch: c.String("repo.branch"),
},
Build: Build{
Path: c.String("path"),
Tag: c.String("build.tag"),
Number: c.Int("build.number"),
Event: c.String("build.event"),
Status: c.String("build.status"),
Commit: c.String("commit.sha"),
Ref: c.String("commit.ref"),
Branch: c.String("commit.branch"),
Pull: c.String("commit.pull"),
Started: c.Int64("build.started"),
Created: c.Int64("build.created"),
Tags: c.StringSlice("tags"),
},
Job: Job{
Started: c.Int64("job.started"),
},
Auto: Auto{
Tags: []string{"1.0", "1"},
},
Config: Config{
Username: c.String("username"),
Password: c.String("password"),
Platforms: c.StringSlice("platforms"),
Target: c.String("target"),
Template: c.String("template"),
Spec: c.String("spec"),
IgnoreMissing: c.Bool("ignore-missing"),
},
}
if c.Bool("tags.auto") {
if tagging.UseDefaultTag(c.String("commit.ref"), c.String("repo.branch")) {
plugin.Build.Tags = tagging.DefaultTags(c.String("commit.ref"))
} else {
log.Printf("skipping automated tags for %s", c.String("commit.ref"))
return nil
}
}
return plugin.Exec()
}
-33
View File
@@ -1,33 +0,0 @@
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
-
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
-
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-i386
platform:
architecture: 386
os: linux
-
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm64
platform:
architecture: arm64
os: linux
-
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm
platform:
architecture: arm
os: linux
-
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}windows-amd64
platform:
architecture: amd64
os: windows
-127
View File
@@ -1,127 +0,0 @@
package main
import (
"errors"
"log"
"strings"
"github.com/drone-plugins/drone-manifest/command"
)
type (
Repo struct {
Owner string
Name string
Branch string
}
Build struct {
Path string
Tag string
Event string
Number int
Commit string
Ref string
Branch string
Author string
Pull string
Message string
DeployTo string
Status string
Link string
Started int64
Created int64
Tags []string
}
Job struct {
Started int64
}
Auto struct {
Tags []string
}
Config struct {
Username string
Password string
Platforms []string
Target string
Template string
Spec string
IgnoreMissing bool
}
Plugin struct {
Repo Repo
Build Build
Job Job
Auto Auto
Config Config
}
)
func (p *Plugin) Exec() error {
opts := make([]command.Option, 0)
if p.Config.Username == "" {
return errors.New("you must provide a username")
} else {
opts = append(opts, command.WithUsername(p.Config.Username))
}
if p.Config.Password == "" {
return errors.New("you must provide a password")
} else {
opts = append(opts, command.WithPassword(p.Config.Password))
}
if p.Config.Spec != "" {
spec, err := RenderTrim(p.Config.Spec, p)
if err != nil {
return err
}
opts = append(opts, command.WithSpec(spec))
log.Printf(
"pushing by spec",
)
} else {
if len(p.Config.Platforms) == 0 {
return errors.New("you must provide platforms")
} else {
opts = append(opts, command.WithPlatforms(p.Config.Platforms))
}
if p.Config.Target == "" {
return errors.New("you must provide a target")
} else {
opts = append(opts, command.WithTarget(p.Config.Target))
}
if p.Config.Template == "" {
return errors.New("you must provide a template")
} else {
opts = append(opts, command.WithTemplate(p.Config.Template))
}
log.Printf(
"pushing %s to %s for %s",
p.Config.Template,
p.Config.Target,
strings.Join(p.Config.Platforms, ", "),
)
}
if p.Config.IgnoreMissing {
opts = append(opts, command.IgnoreMissing())
}
if p.Build.Path != "" {
opts = append(opts, command.WithPath(p.Build.Path))
}
return command.New(opts...).Exec()
}
+166
View File
@@ -0,0 +1,166 @@
// Copyright (c) 2020, the Drone Plugins project authors.
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license that can be
// found in the LICENSE file.
package plugin
import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"runtime"
"strings"
"github.com/drone-plugins/drone-manifest/tagging"
"github.com/drone/drone-template-lib/template"
"github.com/urfave/cli/v2"
)
// Settings for the plugin.
type Settings struct {
Username string
Password string
Insecure bool
Platforms cli.StringSlice
Target string
Template string
Spec string
IgnoreMissing bool
Tags cli.StringSlice
AutoTag bool
}
// Validate handles the settings validation of the plugin.
func (p *Plugin) Validate() error {
if p.settings.Username == "" && p.settings.Password != "" {
return errors.New("you must provide a username")
}
if p.settings.Password == "" && p.settings.Username != "" {
return errors.New("you must provide a password")
}
if p.settings.Spec == "" {
if len(p.settings.Platforms.Value()) == 0 {
return errors.New("you must provide platforms")
}
if p.settings.Target == "" {
return errors.New("you must provide a target")
}
if p.settings.Template == "" {
return errors.New("you must provide a template")
}
}
return nil
}
// Execute provides the implementation of the plugin.
func (p *Plugin) Execute() error {
// Anonymous struct for the templating engine
var t struct {
Build struct {
Tag string
Tags []string
}
}
// Determine the tags
t.Build.Tag = p.pipeline.Build.Tag
if p.settings.AutoTag {
if tagging.UseDefaultTag(p.pipeline.Commit.Ref, p.pipeline.Repo.Branch) {
t.Build.Tags = tagging.DefaultTags(p.pipeline.Commit.Ref)
} else {
log.Printf("skipping automated tags for %s", p.pipeline.Commit.Ref)
return nil
}
} else {
t.Build.Tags = p.settings.Tags.Value()
}
args := []string{
fmt.Sprintf("--username=%s", p.settings.Username),
fmt.Sprintf("--password=%s", p.settings.Password),
}
if p.settings.Insecure {
args = append(args, "--insecure")
}
args = append(args, "push")
if p.settings.Spec != "" {
var raw []byte
// if spec is not a valid file, assume inlining
if _, err := os.Stat(p.settings.Spec); os.IsNotExist(err) {
raw = []byte(p.settings.Spec)
} else { // otherwise read it
raw, err = ioutil.ReadFile(p.settings.Spec)
if err != nil {
return fmt.Errorf("failed to read template: %w", err)
}
}
spec, err := template.RenderTrim(string(raw), t)
if err != nil {
return fmt.Errorf("failed to render template: %w", err)
}
tmpfile, err := ioutil.TempFile("", "manifest-")
if err != nil {
return fmt.Errorf("failed to create tempfile: %w", err)
}
defer os.Remove(tmpfile.Name())
if _, err := tmpfile.Write([]byte(spec)); err != nil {
return fmt.Errorf("failed to write tempfile: %w", err)
}
if err := tmpfile.Close(); err != nil {
return fmt.Errorf("failed to close tempfile: %w", err)
}
args = append(args, "from-spec")
args = append(args, tmpfile.Name())
} else {
args = append(
args,
"from-args",
fmt.Sprintf("--platforms=%s", strings.Join(p.settings.Platforms.Value(), ",")),
fmt.Sprintf("--target=%s", p.settings.Target),
fmt.Sprintf("--template=%s", p.settings.Template),
)
}
if p.settings.IgnoreMissing {
args = append(args, "--ignore-missing")
}
cmd := exec.Command(
mainfestToolPath(),
args...,
)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
func mainfestToolPath() string {
if runtime.GOOS == "windows" {
return "C:/bin/manifest-tool.exe"
}
return "/bin/manifest-tool"
}
+18
View File
@@ -0,0 +1,18 @@
// Copyright (c) 2020, the Drone Plugins project authors.
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license that can be
// found in the LICENSE file.
package plugin
import (
"testing"
)
func TestValidate(t *testing.T) {
t.Skip()
}
func TestExecute(t *testing.T) {
t.Skip()
}
+26
View File
@@ -0,0 +1,26 @@
// Copyright (c) 2020, the Drone Plugins project authors.
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license that can be
// found in the LICENSE file.
package plugin
import (
"github.com/drone-plugins/drone-plugin-lib/drone"
)
// Plugin implements drone.Plugin to provide the plugin implementation.
type Plugin struct {
settings Settings
pipeline drone.Pipeline
network drone.Network
}
// New initializes a plugin from the given Settings, Pipeline, and Network.
func New(settings Settings, pipeline drone.Pipeline, network drone.Network) drone.Plugin {
return &Plugin{
settings: settings,
pipeline: pipeline,
network: network,
}
}
+14
View File
@@ -0,0 +1,14 @@
// Copyright (c) 2020, the Drone Plugins project authors.
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license that can be
// found in the LICENSE file.
package plugin
import (
"testing"
)
func TestPlugin(t *testing.T) {
t.Skip()
}
+26
View File
@@ -0,0 +1,26 @@
{
"extends": [
"config:base",
":automergeMinor",
":automergeDigest"
],
"enabledManagers": [
"dockerfile",
"gomod"
],
"dockerfile": {
"fileMatch": [
"docker/Dockerfile\\.linux\\.(arm|arm64|amd64|multiarch)",
"docker/Dockerfile\\.windows\\.(1809|1903|1909|2004)"
],
"pinDigests": true
},
"gomod": {
"postUpdateOptions": [
"gomodTidy"
]
},
"labels": [
"renovate"
]
}
+19 -5
View File
@@ -7,6 +7,16 @@ import (
"github.com/coreos/go-semver/semver"
)
func splitOff(input string, delim string) string {
parts := strings.SplitN(input, delim, 2)
if len(parts) == 2 {
return parts[0]
}
return input
}
// DefaultTags returns a set of default suggested tags.
func DefaultTags(ref string) []string {
if !strings.HasPrefix(ref, "refs/tags/") {
@@ -27,17 +37,21 @@ func DefaultTags(ref string) []string {
}
}
v = stripTagPrefix(ref)
v = splitOff(splitOff(v, "+"), "-")
dotParts := strings.SplitN(v, ".", 3)
if version.Major == 0 {
return []string{
fmt.Sprintf("%d.%d", version.Major, version.Minor),
fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch),
fmt.Sprintf("%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor),
fmt.Sprintf("%0*d.%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor, len(dotParts[2]), version.Patch),
}
}
return []string{
fmt.Sprint(version.Major),
fmt.Sprintf("%d.%d", version.Major, version.Minor),
fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch),
fmt.Sprintf("%0*d", len(dotParts[0]), version.Major),
fmt.Sprintf("%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor),
fmt.Sprintf("%0*d.%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor, len(dotParts[2]), version.Patch),
}
}
+1
View File
@@ -21,6 +21,7 @@ func TestDefaultTags(t *testing.T) {
// malformed or errors
{"refs/tags/x1.0.0", []string{"latest"}},
{"v1.0.0", []string{"latest"}},
{"refs/tags/v18.06.0", []string{"18", "18.06", "18.06.0"}},
}
for _, test := range tests {
-141
View File
@@ -1,141 +0,0 @@
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"
"unicode"
"unicode/utf8"
"github.com/aymerick/raymond"
)
func init() {
raymond.RegisterHelpers(funcs)
}
// Render parses and executes a template, returning the results in string format.
func Render(template string, payload interface{}) (s string, err error) {
u, err := url.Parse(template)
if err == nil {
switch u.Scheme {
case "http", "https":
res, err := http.Get(template)
if err != nil {
return s, err
}
defer res.Body.Close()
out, err := ioutil.ReadAll(res.Body)
if err != nil {
return s, err
}
template = string(out)
default:
out, err := ioutil.ReadFile(u.Path)
if err != nil {
return s, err
}
template = string(out)
}
}
return raymond.Render(template, payload)
}
// RenderTrim parses and executes a template, returning the results in string
// format. The result is trimmed to remove left and right padding and newlines
// that may be added unintentially in the template markup.
func RenderTrim(template string, playload interface{}) (string, error) {
out, err := Render(template, playload)
return strings.Trim(out, " \n"), err
}
var funcs = map[string]interface{}{
"uppercase": strings.ToUpper,
"lowercase": strings.ToLower,
"trimPrefix": strings.TrimPrefix,
"trimSuffix": strings.TrimSuffix,
"quote": strconv.Quote,
"join": strings.Join,
"uppercasefirst": uppercaseFirst,
"duration": toDuration,
"datetime": toDatetime,
"success": isSuccess,
"failure": isFailure,
"truncate": truncate,
"urlencode": urlencode,
"since": since,
}
func uppercaseFirst(s string) string {
a := []rune(s)
a[0] = unicode.ToUpper(a[0])
s = string(a)
return s
}
func toDuration(started, finished float64) string {
return fmt.Sprintln(time.Duration(finished-started) * time.Second)
}
func toDatetime(timestamp float64, layout, zone string) string {
if len(zone) == 0 {
return time.Unix(int64(timestamp), 0).Format(layout)
}
loc, err := time.LoadLocation(zone)
if err != nil {
return time.Unix(int64(timestamp), 0).Local().Format(layout)
}
return time.Unix(int64(timestamp), 0).In(loc).Format(layout)
}
func isSuccess(conditional bool, options *raymond.Options) string {
if !conditional {
return options.Inverse()
}
switch options.ParamStr(0) {
case "success":
return options.Fn()
default:
return options.Inverse()
}
}
func isFailure(conditional bool, options *raymond.Options) string {
if !conditional {
return options.Inverse()
}
switch options.ParamStr(0) {
case "failure", "error", "killed":
return options.Fn()
default:
return options.Inverse()
}
}
func truncate(s string, len int) string {
if utf8.RuneCountInString(s) <= len {
return s
}
runes := []rune(s)
return string(runes[:len])
}
func urlencode(options *raymond.Options) string {
return url.QueryEscape(options.Fn())
}
func since(start int64) string {
// NOTE: not using `time.Since()` because the fractional second component
// will give us something like "40m12.917523438s" vs "40m12s". We lose
// some precision, but the format is much more readable.
now := time.Unix(time.Now().Unix(), 0)
return fmt.Sprintln(now.Sub(time.Unix(start, 0)))
}