5 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
24 changed files with 903 additions and 814 deletions
+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',
],
},
}]
-254
View File
@@ -1,254 +0,0 @@
kind: pipeline
type: vm
name: testing
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps:
- name: lint
image: golang:1.19
pull: always
commands:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- golangci-lint version
- golangci-lint run
volumes:
- name: gopath
path: "/go"
- name: test
image: golang:1.19
commands:
- go test -cover ./...
volumes:
- name: gopath
path: "/go"
volumes:
- name: gopath
temp: {}
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
---
kind: pipeline
type: vm
name: linux-amd64
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps:
- name: environment
image: golang:1.19
pull: always
environment:
CGO_ENABLED: "0"
commands:
- go version
- go env
- name: build
image: golang:1.19
environment:
CGO_ENABLED: "0"
commands:
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/linux/amd64/drone-manifest .
- name: docker
image: plugins/docker
settings:
dockerfile: docker/Dockerfile.linux.amd64
repo: plugins/manifest
username:
from_secret: docker_username
password:
from_secret: docker_password
auto_tag: true
auto_tag_suffix: linux-amd64
depends_on:
- testing
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
---
kind: pipeline
type: vm
name: linux-arm64
platform:
os: linux
arch: arm64
pool:
use: ubuntu_arm64
steps:
- name: environment
image: golang:1.19
pull: always
environment:
CGO_ENABLED: "0"
commands:
- go version
- go env
- name: build
image: golang:1.19
environment:
CGO_ENABLED: "0"
commands:
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/linux/arm64/drone-manifest .
- name: docker
image: plugins/docker
settings:
dockerfile: docker/Dockerfile.linux.arm64
repo: plugins/manifest
username:
from_secret: docker_username
password:
from_secret: docker_password
auto_tag: true
auto_tag_suffix: linux-arm64
depends_on:
- testing
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
---
kind: pipeline
type: vm
name: windows-1809
platform:
os: windows
arch: amd64
pool:
use: windows
steps:
- name: environment
image: golang:1.19
pull: always
environment:
CGO_ENABLED: "0"
commands:
- go version
- go env
- name: build
image: golang:1.19
environment:
CGO_ENABLED: "0"
commands:
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/windows/amd64/drone-manifest.exe .
- name: docker
image: plugins/docker
settings:
dockerfile: docker/Dockerfile.windows.1809
repo: plugins/manifest
username:
from_secret: docker_username
password:
from_secret: docker_password
auto_tag: true
auto_tag_suffix: windows-1809-amd64
daemon_off: true
purge: false
when:
ref:
- refs/heads/master
- refs/tags/**
depends_on:
- testing
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
---
kind: pipeline
type: vm
name: windows-ltsc2022
platform:
os: windows
arch: amd64
pool:
use: windows-2022
steps:
- name: environment
image: golang:1.19
pull: always
environment:
CGO_ENABLED: "0"
commands:
- go version
- go env
- name: build
image: golang:1.19
environment:
CGO_ENABLED: "0"
commands:
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/windows/amd64/drone-manifest.exe .
- name: docker
image: plugins/docker
settings:
dockerfile: docker/Dockerfile.windows.ltsc2022
repo: plugins/manifest
username:
from_secret: docker_username
password:
from_secret: docker_password
auto_tag: true
auto_tag_suffix: windows-ltsc2022-amd64
daemon_off: true
purge: false
when:
ref:
- refs/heads/master
- refs/tags/**
depends_on:
- testing
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
---
kind: pipeline
type: vm
name: manifest
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps:
- name: manifest
image: plugins/manifest:linux-amd64
settings:
auto_tag: "true"
username:
from_secret: docker_username
password:
from_secret: docker_password
spec: docker/manifest.tmpl
ignore_missing: true
depends_on:
- linux-amd64
- linux-arm64
- windows-1809
- windows-ltsc2022
trigger:
ref:
- refs/heads/master
- refs/tags/**
+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
-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.
+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
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
FROM alpine:3.10 as base
FROM alpine:3.12 as base
ENV MANIFEST_TOOL_VERSION 1.0.2
@@ -16,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" ]
+19
View File
@@ -0,0 +1,19 @@
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/v${MANIFEST_TOOL_VERSION}/manifest-tool-linux-armv7 && \
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/arm/drone-manifest /bin/
ENTRYPOINT [ "/bin/drone-manifest" ]
+2 -2
View File
@@ -1,4 +1,4 @@
FROM alpine:3.10 as base
FROM alpine:3.12 as base
ENV MANIFEST_TOOL_VERSION 1.0.2
@@ -16,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" ]
+5 -11
View File
@@ -1,22 +1,16 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1809 as download
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN mkdir C:\app
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest 'https://github.com/estesp/manifest-tool/releases/download/v1.0.3/manifest-tool-windows-amd64.exe' -OutFile 'c:\app\manifest-tool.exe'
FROM plugins/base:windows-1809-amd64
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
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=download /app/manifest-tool.exe C:/bin/docker.exe
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" ]
-22
View File
@@ -1,22 +0,0 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:ltsc2022 as download
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN mkdir C:\app
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest 'https://github.com/estesp/manifest-tool/releases/download/v1.0.3/manifest-tool-windows-amd64.exe' -OutFile 'c:\app\manifest-tool.exe'
FROM plugins/base:windows-ltsc2022-amd64@sha256:0f90d5bceb432f1ee6f93cf44eed6a38c322834edd55df8a6648c9e6f15131f4
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
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=download /app/manifest-tool.exe C:/bin/docker.exe
ADD release/windows/amd64/drone-manifest.exe C:/bin/drone-manifest.exe
ENTRYPOINT [ "C:\\bin\\drone-manifest.exe" ]
+25 -12
View File
@@ -1,31 +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
- 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
- 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}}windows-1809-amd64
- 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
-
image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
platform:
architecture: amd64
os: windows
version: ltsc2022
+5 -23
View File
@@ -1,29 +1,11 @@
module github.com/drone-plugins/drone-manifest
go 1.19
go 1.14
require (
github.com/coreos/go-semver v0.3.0
github.com/drone/drone-template-lib v1.0.1-0.20201006172840-a58a3f26ebca
github.com/pkg/errors v0.9.1
github.com/urfave/cli v1.22.10
)
require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.0 // indirect
github.com/Masterminds/sprig/v3 v3.1.0 // indirect
github.com/aymerick/raymond v2.0.2+incompatible // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/stretchr/testify v1.8.1 // indirect
golang.org/x/crypto v0.4.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
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
)
+39 -56
View File
@@ -1,72 +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/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.1.0 h1:Y2lUDsFKVRSYGojLJ1yLxSXdMmMYTYls0rCvoqmMUQk=
github.com/Masterminds/semver/v3 v3.1.0/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/Masterminds/sprig/v3 v3.1.0 h1:j7GpgZ7PdFqNsmncycTHsLmVPf5/3wJtlgW9TNDYD9Y=
github.com/Masterminds/sprig/v3 v3.1.0/go.mod h1:ONGMf7UfYGAbMXCZmQLy8x3lCDIPrEZE/rU8pmrbihA=
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/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/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/drone-template-lib v1.0.1-0.20201006172840-a58a3f26ebca h1:8kk7qaQJ1R3aIDMQ04NhKRZQZZgBE9veNYme2Wjudts=
github.com/drone/drone-template-lib v1.0.1-0.20201006172840-a58a3f26ebca/go.mod h1:4DHXhrDoAGam5Sx6LHygmi2tkhWt2dWXqNFLQNxmWTc=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/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/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
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/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/urfave/cli v1.22.10 h1:p8Fspmz3iTctJstry1PYS3HVdllxnEzTEsgIgtxTrCk=
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
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=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-217
View File
@@ -1,217 +0,0 @@
package main
import (
"log"
"os"
"github.com/drone-plugins/drone-manifest/tagging"
"github.com/urfave/cli"
)
var (
version = "unknown"
)
func main() {
app := cli.NewApp()
app.Name = "manifest plugin"
app.Usage = "manifest plugin"
app.Action = run
app.Version = version
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.BoolFlag{
Name: "insecure",
Usage: "enable allow insecure registry",
EnvVar: "PLUGIN_INSECURE",
},
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.BoolFlag{
Name: "dump",
Usage: "dump the spec to stdout for debug purposes",
EnvVar: "PLUGIN_DUMP",
},
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"),
},
Config: Config{
Username: c.String("username"),
Password: c.String("password"),
Insecure: c.Bool("insecure"),
Platforms: c.StringSlice("platforms"),
Target: c.String("target"),
Template: c.String("template"),
Spec: c.String("spec"),
IgnoreMissing: c.Bool("ignore-missing"),
Dump: c.Bool("dump"),
},
}
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()
}
-186
View File
@@ -1,186 +0,0 @@
package main
import (
"fmt"
"log"
"os"
"os/exec"
"runtime"
"strings"
"github.com/drone/drone-template-lib/template"
"github.com/pkg/errors"
)
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
}
Config struct {
Username string
Password string
Insecure bool
Platforms []string
Target string
Template string
Spec string
IgnoreMissing bool
Dump bool
}
Plugin struct {
Repo Repo
Build Build
Job Job
Config Config
}
)
func mainfestToolPath() string {
if runtime.GOOS == "windows" {
return "C:/bin/manifest-tool.exe"
}
return "/bin/manifest-tool"
}
func (p *Plugin) Exec() error {
args := []string{}
if p.Config.Username == "" && p.Config.Password != "" {
return errors.New("you must provide a username")
} else {
args = append(args, fmt.Sprintf("--username=%s", p.Config.Username))
}
if p.Config.Password == "" && p.Config.Username != "" {
return errors.New("you must provide a password")
} else {
args = append(args, fmt.Sprintf("--password=%s", p.Config.Password))
}
if p.Config.Insecure {
args = append(args, "--insecure")
}
args = append(args, "push")
if p.Config.Spec != "" {
var raw []byte
// if spec is not a valid file, assume inlining
if _, err := os.Stat(p.Config.Spec); os.IsNotExist(err) {
raw = []byte(p.Config.Spec)
} else { // otherwise read it
raw, err = os.ReadFile(p.Config.Spec)
if err != nil {
return errors.Wrap(err, "failed to read template")
}
}
spec, err := template.RenderTrim(string(raw), p)
if err != nil {
return errors.Wrap(err, "failed to render template")
}
tmpfile, err := os.CreateTemp(p.Build.Path, "manifest-")
if err != nil {
return errors.Wrap(err, "failed to create tempfile")
}
defer os.Remove(tmpfile.Name())
if _, err := tmpfile.Write([]byte(spec)); err != nil {
return errors.Wrap(err, "failed to write tempfile")
}
if err := tmpfile.Close(); err != nil {
return errors.Wrap(err, "failed to close tempfile")
}
if p.Config.Dump {
println(spec)
}
args = append(args, "from-spec")
args = append(args, tmpfile.Name())
log.Printf(
"pushing by spec",
)
} else {
args = append(args, "from-args")
if len(p.Config.Platforms) == 0 {
return errors.New("you must provide platforms")
} else {
args = append(args, fmt.Sprintf("--platforms=%s", strings.Join(p.Config.Platforms, ",")))
}
if p.Config.Target == "" {
return errors.New("you must provide a target")
} else {
args = append(args, fmt.Sprintf("--target=%s", p.Config.Target))
}
if p.Config.Template == "" {
return errors.New("you must provide a template")
} else {
args = append(args, fmt.Sprintf("--template=%s", 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 {
args = append(args, "--ignore-missing")
}
cmd := exec.Command(
mainfestToolPath(),
args...,
)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if p.Build.Path != "" {
cmd.Dir = p.Build.Path
}
return cmd.Run()
}
+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"
]
}