forked from Ivasoft/drone-docker
Compare commits
5 Commits
v20.12.0
...
starlark-b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcc073cef3 | ||
|
|
ece57563b4 | ||
|
|
e33755c959 | ||
|
|
188d9c8543 | ||
|
|
af1bb6bcf2 |
272
.drone.star
Normal file
272
.drone.star
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
golang_image = "golang:1.15"
|
||||||
|
|
||||||
|
def main(ctx):
|
||||||
|
before = testing(ctx)
|
||||||
|
|
||||||
|
stages = [
|
||||||
|
linux(ctx, "amd64"),
|
||||||
|
linux(ctx, "arm64"),
|
||||||
|
linux(ctx, "arm"),
|
||||||
|
]
|
||||||
|
|
||||||
|
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):
|
||||||
|
step_volumes = [
|
||||||
|
{
|
||||||
|
"name": "gopath",
|
||||||
|
"path": "/go",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"kind": "pipeline",
|
||||||
|
"type": "docker",
|
||||||
|
"name": "testing",
|
||||||
|
"platform": {
|
||||||
|
"os": "linux",
|
||||||
|
"arch": "amd64",
|
||||||
|
},
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"name": "staticcheck",
|
||||||
|
"image": golang_image,
|
||||||
|
"pull": "always",
|
||||||
|
"commands": [
|
||||||
|
"go run honnef.co/go/tools/cmd/staticcheck ./...",
|
||||||
|
],
|
||||||
|
"volumes": step_volumes,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "lint",
|
||||||
|
"image": golang_image,
|
||||||
|
"pull": "always",
|
||||||
|
"commands": [
|
||||||
|
"go run golang.org/x/lint/golint -set_exit_status ./...",
|
||||||
|
],
|
||||||
|
"volumes": step_volumes,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vet",
|
||||||
|
"image": golang_image,
|
||||||
|
"commands": [
|
||||||
|
"go vet ./...",
|
||||||
|
],
|
||||||
|
"volumes": step_volumes,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "test",
|
||||||
|
"image": golang_image,
|
||||||
|
"commands": [
|
||||||
|
"go test -cover ./...",
|
||||||
|
],
|
||||||
|
"volumes": step_volumes,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"name": "gopath",
|
||||||
|
"temp": {},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"trigger": {
|
||||||
|
"ref": [
|
||||||
|
"refs/heads/master",
|
||||||
|
"refs/tags/**",
|
||||||
|
"refs/pull/**",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
def linux(ctx, arch):
|
||||||
|
steps = [
|
||||||
|
{
|
||||||
|
"name": "environment",
|
||||||
|
"image": golang_image,
|
||||||
|
"pull": "always",
|
||||||
|
"environment": {
|
||||||
|
"CGO_ENABLED": "0",
|
||||||
|
},
|
||||||
|
"commands": [
|
||||||
|
"go version",
|
||||||
|
"go env",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
steps.extend(linux_build(ctx, arch, "docker"))
|
||||||
|
steps.extend(linux_build(ctx, arch, "acr"))
|
||||||
|
steps.extend(linux_build(ctx, arch, "ecr"))
|
||||||
|
steps.extend(linux_build(ctx, arch, "gcr"))
|
||||||
|
steps.extend(linux_build(ctx, arch, "heroku"))
|
||||||
|
|
||||||
|
return {
|
||||||
|
"kind": "pipeline",
|
||||||
|
"type": "docker",
|
||||||
|
"name": "linux-%s" % (arch),
|
||||||
|
"platform": {
|
||||||
|
"os": "linux",
|
||||||
|
"arch": arch,
|
||||||
|
},
|
||||||
|
"steps": steps,
|
||||||
|
"depends_on": [],
|
||||||
|
"trigger": {
|
||||||
|
"ref": [
|
||||||
|
"refs/heads/master",
|
||||||
|
"refs/tags/**",
|
||||||
|
"refs/pull/**",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
def linux_build(ctx, arch, name):
|
||||||
|
docker = {
|
||||||
|
"dockerfile": "docker/%s/Dockerfile.linux.%s" % (name, arch),
|
||||||
|
"repo": "plugins/%s" % (name),
|
||||||
|
"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-%s ./cmd/drone-%s' % (ctx.build.ref.replace("refs/tags/v", ""), arch, name, name),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
build = [
|
||||||
|
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-%s ./cmd/drone-%s' % (ctx.build.commit[0:8], arch, name, name),
|
||||||
|
]
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"name": "build-%s" % (name),
|
||||||
|
"image": golang_image,
|
||||||
|
"environment": {
|
||||||
|
"CGO_ENABLED": "0",
|
||||||
|
},
|
||||||
|
"commands": build,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "docker-%s" % (name),
|
||||||
|
"image": "plugins/docker",
|
||||||
|
"pull": "always",
|
||||||
|
"settings": docker,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
def manifest(ctx):
|
||||||
|
steps = []
|
||||||
|
|
||||||
|
steps.extend(manifest_build(ctx, "docker"))
|
||||||
|
steps.extend(manifest_build(ctx, "acr"))
|
||||||
|
steps.extend(manifest_build(ctx, "ecr"))
|
||||||
|
steps.extend(manifest_build(ctx, "gcr"))
|
||||||
|
steps.extend(manifest_build(ctx, "heroku"))
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"kind": "pipeline",
|
||||||
|
"type": "docker",
|
||||||
|
"name": "manifest",
|
||||||
|
"steps": steps,
|
||||||
|
"depends_on": [],
|
||||||
|
"trigger": {
|
||||||
|
"ref": [
|
||||||
|
"refs/heads/master",
|
||||||
|
"refs/tags/**",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
def manifest_build(ctx, name):
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"name": "manifest-%s" % (name),
|
||||||
|
"image": "plugins/manifest",
|
||||||
|
"pull": "always",
|
||||||
|
"settings": {
|
||||||
|
"auto_tag": "true",
|
||||||
|
"username": {
|
||||||
|
"from_secret": "docker_username",
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"from_secret": "docker_password",
|
||||||
|
},
|
||||||
|
"spec": "docker/%s/manifest.tmpl" % (name),
|
||||||
|
"ignore_missing": "true",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "microbadger-%s" % (name),
|
||||||
|
"image": "plugins/webhook",
|
||||||
|
"pull": "always",
|
||||||
|
"settings": {
|
||||||
|
"urls": {
|
||||||
|
"from_secret": "microbadger_url",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
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",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
1644
.drone.yml
1644
.drone.yml
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
|||||||
since-tag=v19.03.8
|
|
||||||
|
|
||||||
78
CHANGELOG.md
78
CHANGELOG.md
@@ -1,78 +0,0 @@
|
|||||||
# Changelog
|
|
||||||
|
|
||||||
## [v20.12.0](https://github.com/drone-plugins/drone-docker/tree/v20.12.0) (2022-05-12)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v20.11.0...v20.12.0)
|
|
||||||
|
|
||||||
**Implemented enhancements:**
|
|
||||||
|
|
||||||
- Add support for multiple Buildkit secrets with env vars or files as source [\#359](https://github.com/drone-plugins/drone-docker/pull/359) ([ste93cry](https://github.com/ste93cry))
|
|
||||||
- \(DRON-237\) cards add link to image repo, minor cleanup [\#358](https://github.com/drone-plugins/drone-docker/pull/358) ([tphoney](https://github.com/tphoney))
|
|
||||||
- \(DRON-232\) enable build-kit for secrets consumption [\#356](https://github.com/drone-plugins/drone-docker/pull/356) ([tphoney](https://github.com/tphoney))
|
|
||||||
|
|
||||||
**Fixed bugs:**
|
|
||||||
|
|
||||||
- \(fix\) Update card.json with UX [\#355](https://github.com/drone-plugins/drone-docker/pull/355) ([tphoney](https://github.com/tphoney))
|
|
||||||
|
|
||||||
## [v20.11.0](https://github.com/drone-plugins/drone-docker/tree/v20.11.0) (2022-01-19)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v20.10.9.1...v20.11.0)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- new release to fix window semver error [\#354](https://github.com/drone-plugins/drone-docker/pull/354) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
|
||||||
- \(feat\) publish docker data to create drone card [\#347](https://github.com/drone-plugins/drone-docker/pull/347) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
|
||||||
|
|
||||||
## [v20.10.9.1](https://github.com/drone-plugins/drone-docker/tree/v20.10.9.1) (2022-01-13)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v20.10.9...v20.10.9.1)
|
|
||||||
|
|
||||||
**Implemented enhancements:**
|
|
||||||
|
|
||||||
- Serialize windows 1809 pipelines [\#348](https://github.com/drone-plugins/drone-docker/pull/348) ([shubham149](https://github.com/shubham149))
|
|
||||||
- Support for windows images for tags [\#346](https://github.com/drone-plugins/drone-docker/pull/346) ([shubham149](https://github.com/shubham149))
|
|
||||||
|
|
||||||
**Fixed bugs:**
|
|
||||||
|
|
||||||
- Fix ECR & GCR docker publish on windows [\#352](https://github.com/drone-plugins/drone-docker/pull/352) ([shubham149](https://github.com/shubham149))
|
|
||||||
- Fix windows docker builds [\#351](https://github.com/drone-plugins/drone-docker/pull/351) ([shubham149](https://github.com/shubham149))
|
|
||||||
- Fix powershell script to publish windows images [\#350](https://github.com/drone-plugins/drone-docker/pull/350) ([shubham149](https://github.com/shubham149))
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- release prep for 20.10.9.1 [\#353](https://github.com/drone-plugins/drone-docker/pull/353) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
|
||||||
|
|
||||||
## [v20.10.9](https://github.com/drone-plugins/drone-docker/tree/v20.10.9) (2021-11-03)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v19.03.9...v20.10.9)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- bump to version 20.10.9: [\#342](https://github.com/drone-plugins/drone-docker/pull/342) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
|
||||||
- Upgrade Docker dind to 20.10.9 for 64bit platforms [\#334](https://github.com/drone-plugins/drone-docker/pull/334) ([gzm0](https://github.com/gzm0))
|
|
||||||
|
|
||||||
## [v19.03.9](https://github.com/drone-plugins/drone-docker/tree/v19.03.9) (2021-10-13)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v19.03.8...v19.03.9)
|
|
||||||
|
|
||||||
**Implemented enhancements:**
|
|
||||||
|
|
||||||
- adding support for externalId [\#333](https://github.com/drone-plugins/drone-docker/pull/333) ([jimsheldon](https://github.com/jimsheldon))
|
|
||||||
- Add support for automatic opencontainer labels [\#313](https://github.com/drone-plugins/drone-docker/pull/313) ([codrut-fc](https://github.com/codrut-fc))
|
|
||||||
- add custom seccomp profile [\#312](https://github.com/drone-plugins/drone-docker/pull/312) ([xoxys](https://github.com/xoxys))
|
|
||||||
- ECR: adding setting to enable image scanning while repo creation [\#300](https://github.com/drone-plugins/drone-docker/pull/300) ([rvoitenko](https://github.com/rvoitenko))
|
|
||||||
|
|
||||||
**Fixed bugs:**
|
|
||||||
|
|
||||||
- Revert "Update seccomp to 20.10 docker" [\#325](https://github.com/drone-plugins/drone-docker/pull/325) ([bradrydzewski](https://github.com/bradrydzewski))
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- \(maint\) bump git to 1.13 for build and test [\#338](https://github.com/drone-plugins/drone-docker/pull/338) ([tphoney](https://github.com/tphoney))
|
|
||||||
- \(maint\) v19.03.9 release prep [\#337](https://github.com/drone-plugins/drone-docker/pull/337) ([tphoney](https://github.com/tphoney))
|
|
||||||
- \(maint\) CI, remove the dry run steps, due to rate limiting [\#323](https://github.com/drone-plugins/drone-docker/pull/323) ([tphoney](https://github.com/tphoney))
|
|
||||||
- Update seccomp to 20.10 docker [\#322](https://github.com/drone-plugins/drone-docker/pull/322) ([techknowlogick](https://github.com/techknowlogick))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
|
||||||
20
README.md
20
README.md
@@ -72,23 +72,3 @@ docker run --rm \
|
|||||||
--privileged \
|
--privileged \
|
||||||
plugins/docker --dry-run
|
plugins/docker --dry-run
|
||||||
```
|
```
|
||||||
|
|
||||||
## Release procedure
|
|
||||||
|
|
||||||
Run the changelog generator.
|
|
||||||
|
|
||||||
```BASH
|
|
||||||
docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u drone-plugins -p drone-docker -t <secret github token>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can generate a token by logging into your GitHub account and going to Settings -> Personal access tokens.
|
|
||||||
|
|
||||||
Next we tag the PR's with the fixes or enhancements labels. If the PR does not fufil the requirements, do not add a label.
|
|
||||||
|
|
||||||
Run the changelog generator again with the future version according to semver.
|
|
||||||
|
|
||||||
```BASH
|
|
||||||
docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u drone-plugins -p drone-docker -t <secret token> --future-release v1.0.0
|
|
||||||
```
|
|
||||||
|
|
||||||
Create your pull request for the release. Get it merged then tag the release.
|
|
||||||
88
card.go
88
card.go
@@ -1,88 +0,0 @@
|
|||||||
package docker
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/drone/drone-go/drone"
|
|
||||||
|
|
||||||
"github.com/inhies/go-bytesize"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (p Plugin) writeCard() error {
|
|
||||||
cmd := exec.Command("docker", "inspect", p.Build.Name)
|
|
||||||
data, err := cmd.CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
out := Card{}
|
|
||||||
if err := json.Unmarshal(data, &out); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
inspect := out[0]
|
|
||||||
inspect.SizeString = fmt.Sprint(bytesize.New(float64(inspect.Size)))
|
|
||||||
inspect.VirtualSizeString = fmt.Sprint(bytesize.New(float64(inspect.VirtualSize)))
|
|
||||||
inspect.Time = fmt.Sprint(inspect.Metadata.LastTagTime.Format(time.RFC3339))
|
|
||||||
// change slice of tags to slice of TagStruct
|
|
||||||
var sliceTagStruct []TagStruct
|
|
||||||
for _, tag := range inspect.RepoTags {
|
|
||||||
sliceTagStruct = append(sliceTagStruct, TagStruct{Tag: tag})
|
|
||||||
}
|
|
||||||
inspect.ParsedRepoTags = sliceTagStruct[1:] // remove the first tag which is always "hash:latest"
|
|
||||||
// create the url from repo and registry
|
|
||||||
inspect.URL = mapRegistryToURL(p.Daemon.Registry, p.Build.Repo)
|
|
||||||
cardData, _ := json.Marshal(inspect)
|
|
||||||
|
|
||||||
card := drone.CardInput{
|
|
||||||
Schema: "https://drone-plugins.github.io/drone-docker/card.json",
|
|
||||||
Data: cardData,
|
|
||||||
}
|
|
||||||
|
|
||||||
writeCard(p.CardPath, &card)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func writeCard(path string, card interface{}) {
|
|
||||||
data, _ := json.Marshal(card)
|
|
||||||
switch {
|
|
||||||
case path == "/dev/stdout":
|
|
||||||
writeCardTo(os.Stdout, data)
|
|
||||||
case path == "/dev/stderr":
|
|
||||||
writeCardTo(os.Stderr, data)
|
|
||||||
case path != "":
|
|
||||||
ioutil.WriteFile(path, data, 0644)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func writeCardTo(out io.Writer, data []byte) {
|
|
||||||
encoded := base64.StdEncoding.EncodeToString(data)
|
|
||||||
io.WriteString(out, "\u001B]1338;")
|
|
||||||
io.WriteString(out, encoded)
|
|
||||||
io.WriteString(out, "\u001B]0m")
|
|
||||||
io.WriteString(out, "\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
func mapRegistryToURL(registry, repo string) (url string) {
|
|
||||||
url = "https://"
|
|
||||||
var domain string
|
|
||||||
if strings.Contains(registry, "amazonaws.com") {
|
|
||||||
domain = "gallery.ecr.aws/"
|
|
||||||
} else if strings.Contains(registry, "gcr.io") {
|
|
||||||
domain = "console.cloud.google.com/gcr/images"
|
|
||||||
} else {
|
|
||||||
// default to docker hub
|
|
||||||
domain = "hub.docker.com/r/"
|
|
||||||
}
|
|
||||||
url = path.Join(url, domain, repo)
|
|
||||||
return url
|
|
||||||
}
|
|
||||||
@@ -7,9 +7,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
docker "github.com/drone-plugins/drone-docker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -43,12 +40,12 @@ func main() {
|
|||||||
os.Setenv("DOCKER_PASSWORD", password)
|
os.Setenv("DOCKER_PASSWORD", password)
|
||||||
|
|
||||||
// invoke the base docker plugin binary
|
// invoke the base docker plugin binary
|
||||||
cmd := exec.Command(docker.GetDroneDockerExecCmd())
|
cmd := exec.Command("drone-docker")
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@@ -51,7 +50,7 @@ func main() {
|
|||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "daemon.mirror",
|
Name: "daemon.mirror",
|
||||||
Usage: "docker daemon registry mirror",
|
Usage: "docker daemon registry mirror",
|
||||||
EnvVar: "PLUGIN_MIRROR,DOCKER_PLUGIN_MIRROR",
|
EnvVar: "PLUGIN_MIRROR",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "daemon.storage-driver",
|
Name: "daemon.storage-driver",
|
||||||
@@ -193,16 +192,6 @@ func main() {
|
|||||||
Usage: "label-schema labels",
|
Usage: "label-schema labels",
|
||||||
EnvVar: "PLUGIN_LABEL_SCHEMA",
|
EnvVar: "PLUGIN_LABEL_SCHEMA",
|
||||||
},
|
},
|
||||||
cli.BoolTFlag{
|
|
||||||
Name: "auto-label",
|
|
||||||
Usage: "auto-label true|false",
|
|
||||||
EnvVar: "PLUGIN_AUTO_LABEL",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "link",
|
|
||||||
Usage: "link https://example.com/org/repo-name",
|
|
||||||
EnvVar: "PLUGIN_REPO_LINK,DRONE_REPO_LINK",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "docker.registry",
|
Name: "docker.registry",
|
||||||
Usage: "docker registry",
|
Usage: "docker registry",
|
||||||
@@ -227,7 +216,7 @@ func main() {
|
|||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "docker.config",
|
Name: "docker.config",
|
||||||
Usage: "docker json dockerconfig content",
|
Usage: "docker json dockerconfig content",
|
||||||
EnvVar: "PLUGIN_CONFIG,DOCKER_PLUGIN_CONFIG",
|
EnvVar: "PLUGIN_CONFIG",
|
||||||
},
|
},
|
||||||
cli.BoolTFlag{
|
cli.BoolTFlag{
|
||||||
Name: "docker.purge",
|
Name: "docker.purge",
|
||||||
@@ -249,26 +238,6 @@ func main() {
|
|||||||
Usage: "additional host:IP mapping",
|
Usage: "additional host:IP mapping",
|
||||||
EnvVar: "PLUGIN_ADD_HOST",
|
EnvVar: "PLUGIN_ADD_HOST",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
|
||||||
Name: "secret",
|
|
||||||
Usage: "secret key value pair eg id=MYSECRET",
|
|
||||||
EnvVar: "PLUGIN_SECRET",
|
|
||||||
},
|
|
||||||
cli.StringSliceFlag{
|
|
||||||
Name: "secrets-from-env",
|
|
||||||
Usage: "secret key value pair eg secret_name=secret",
|
|
||||||
EnvVar: "PLUGIN_SECRETS_FROM_ENV",
|
|
||||||
},
|
|
||||||
cli.StringSliceFlag{
|
|
||||||
Name: "secrets-from-file",
|
|
||||||
Usage: "secret key value pairs eg secret_name=/path/to/secret",
|
|
||||||
EnvVar: "PLUGIN_SECRETS_FROM_FILE",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "drone-card-path",
|
|
||||||
Usage: "card path location to write to",
|
|
||||||
EnvVar: "DRONE_CARD_PATH",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
@@ -287,7 +256,6 @@ func run(c *cli.Context) error {
|
|||||||
Email: c.String("docker.email"),
|
Email: c.String("docker.email"),
|
||||||
Config: c.String("docker.config"),
|
Config: c.String("docker.config"),
|
||||||
},
|
},
|
||||||
CardPath: c.String("drone-card-path"),
|
|
||||||
Build: docker.Build{
|
Build: docker.Build{
|
||||||
Remote: c.String("remote.url"),
|
Remote: c.String("remote.url"),
|
||||||
Name: c.String("commit.sha"),
|
Name: c.String("commit.sha"),
|
||||||
@@ -304,12 +272,7 @@ func run(c *cli.Context) error {
|
|||||||
Repo: c.String("repo"),
|
Repo: c.String("repo"),
|
||||||
Labels: c.StringSlice("custom-labels"),
|
Labels: c.StringSlice("custom-labels"),
|
||||||
LabelSchema: c.StringSlice("label-schema"),
|
LabelSchema: c.StringSlice("label-schema"),
|
||||||
AutoLabel: c.BoolT("auto-label"),
|
|
||||||
Link: c.String("link"),
|
|
||||||
NoCache: c.Bool("no-cache"),
|
NoCache: c.Bool("no-cache"),
|
||||||
Secret: c.String("secret"),
|
|
||||||
SecretEnvs: c.StringSlice("secrets-from-env"),
|
|
||||||
SecretFiles: c.StringSlice("secrets-from-file"),
|
|
||||||
AddHost: c.StringSlice("add-host"),
|
AddHost: c.StringSlice("add-host"),
|
||||||
Quiet: c.Bool("quiet"),
|
Quiet: c.Bool("quiet"),
|
||||||
},
|
},
|
||||||
@@ -352,11 +315,3 @@ func run(c *cli.Context) error {
|
|||||||
|
|
||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetExecCmd() string {
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
return "C:/bin/drone-docker.exe"
|
|
||||||
}
|
|
||||||
|
|
||||||
return "drone-docker"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,15 +11,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
|
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
"github.com/aws/aws-sdk-go/service/ecr"
|
"github.com/aws/aws-sdk-go/service/ecr"
|
||||||
|
|
||||||
docker "github.com/drone-plugins/drone-docker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultRegion = "us-east-1"
|
const defaultRegion = "us-east-1"
|
||||||
@@ -40,8 +37,6 @@ func main() {
|
|||||||
lifecyclePolicy = getenv("PLUGIN_LIFECYCLE_POLICY")
|
lifecyclePolicy = getenv("PLUGIN_LIFECYCLE_POLICY")
|
||||||
repositoryPolicy = getenv("PLUGIN_REPOSITORY_POLICY")
|
repositoryPolicy = getenv("PLUGIN_REPOSITORY_POLICY")
|
||||||
assumeRole = getenv("PLUGIN_ASSUME_ROLE")
|
assumeRole = getenv("PLUGIN_ASSUME_ROLE")
|
||||||
externalId = getenv("PLUGIN_EXTERNAL_ID")
|
|
||||||
scanOnPush = parseBoolOrDefault(false, getenv("PLUGIN_SCAN_ON_PUSH"))
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// set the region
|
// set the region
|
||||||
@@ -61,7 +56,7 @@ func main() {
|
|||||||
log.Fatal(fmt.Sprintf("error creating aws session: %v", err))
|
log.Fatal(fmt.Sprintf("error creating aws session: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
svc := getECRClient(sess, assumeRole, externalId)
|
svc := getECRClient(sess, assumeRole)
|
||||||
username, password, defaultRegistry, err := getAuthInfo(svc)
|
username, password, defaultRegistry, err := getAuthInfo(svc)
|
||||||
|
|
||||||
if registry == "" {
|
if registry == "" {
|
||||||
@@ -77,14 +72,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if create {
|
if create {
|
||||||
err = ensureRepoExists(svc, trimHostname(repo, registry), scanOnPush)
|
err = ensureRepoExists(svc, trimHostname(repo, registry))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(fmt.Sprintf("error creating ECR repo: %v", err))
|
log.Fatal(fmt.Sprintf("error creating ECR repo: %v", err))
|
||||||
}
|
}
|
||||||
err = updateImageScannningConfig(svc, trimHostname(repo, registry), scanOnPush)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(fmt.Sprintf("error updating scan on push for ECR repo: %v", err))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if lifecyclePolicy != "" {
|
if lifecyclePolicy != "" {
|
||||||
@@ -113,11 +104,11 @@ func main() {
|
|||||||
os.Setenv("DOCKER_PASSWORD", password)
|
os.Setenv("DOCKER_PASSWORD", password)
|
||||||
|
|
||||||
// invoke the base docker plugin binary
|
// invoke the base docker plugin binary
|
||||||
cmd := exec.Command(docker.GetDroneDockerExecCmd())
|
cmd := exec.Command("drone-docker")
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
if err = cmd.Run(); err != nil {
|
if err = cmd.Run(); err != nil {
|
||||||
logrus.Fatal(err)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,10 +118,9 @@ func trimHostname(repo, registry string) string {
|
|||||||
return repo
|
return repo
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureRepoExists(svc *ecr.ECR, name string, scanOnPush bool) (err error) {
|
func ensureRepoExists(svc *ecr.ECR, name string) (err error) {
|
||||||
input := &ecr.CreateRepositoryInput{}
|
input := &ecr.CreateRepositoryInput{}
|
||||||
input.SetRepositoryName(name)
|
input.SetRepositoryName(name)
|
||||||
input.SetImageScanningConfiguration(&ecr.ImageScanningConfiguration{ScanOnPush: &scanOnPush})
|
|
||||||
_, err = svc.CreateRepository(input)
|
_, err = svc.CreateRepository(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == ecr.ErrCodeRepositoryAlreadyExistsException {
|
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == ecr.ErrCodeRepositoryAlreadyExistsException {
|
||||||
@@ -142,15 +132,6 @@ func ensureRepoExists(svc *ecr.ECR, name string, scanOnPush bool) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateImageScannningConfig(svc *ecr.ECR, name string, scanOnPush bool) (err error) {
|
|
||||||
input := &ecr.PutImageScanningConfigurationInput{}
|
|
||||||
input.SetRepositoryName(name)
|
|
||||||
input.SetImageScanningConfiguration(&ecr.ImageScanningConfiguration{ScanOnPush: &scanOnPush})
|
|
||||||
_, err = svc.PutImageScanningConfiguration(input)
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func uploadLifeCyclePolicy(svc *ecr.ECR, lifecyclePolicy string, name string) (err error) {
|
func uploadLifeCyclePolicy(svc *ecr.ECR, lifecyclePolicy string, name string) (err error) {
|
||||||
input := &ecr.PutLifecyclePolicyInput{}
|
input := &ecr.PutLifecyclePolicyInput{}
|
||||||
input.SetLifecyclePolicyText(lifecyclePolicy)
|
input.SetLifecyclePolicyText(lifecyclePolicy)
|
||||||
@@ -212,19 +193,11 @@ func getenv(key ...string) (s string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getECRClient(sess *session.Session, role string, externalId string) *ecr.ECR {
|
func getECRClient(sess *session.Session, role string) *ecr.ECR {
|
||||||
if role == "" {
|
if role == "" {
|
||||||
return ecr.New(sess)
|
return ecr.New(sess)
|
||||||
}
|
}
|
||||||
if externalId != "" {
|
return ecr.New(sess, &aws.Config{
|
||||||
return ecr.New(sess, &aws.Config{
|
Credentials: stscreds.NewCredentials(sess, role),
|
||||||
Credentials: stscreds.NewCredentials(sess, role, func(p *stscreds.AssumeRoleProvider) {
|
})
|
||||||
p.ExternalID = &externalId
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
return ecr.New(sess, &aws.Config{
|
|
||||||
Credentials: stscreds.NewCredentials(sess, role),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
docker "github.com/drone-plugins/drone-docker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// gcr default username
|
// gcr default username
|
||||||
@@ -57,12 +54,12 @@ func main() {
|
|||||||
os.Setenv("DOCKER_PASSWORD", password)
|
os.Setenv("DOCKER_PASSWORD", password)
|
||||||
|
|
||||||
// invoke the base docker plugin binary
|
// invoke the base docker plugin binary
|
||||||
cmd := exec.Command(docker.GetDroneDockerExecCmd())
|
cmd := exec.Command("drone-docker")
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
38
daemon.go
38
daemon.go
@@ -5,6 +5,7 @@ package docker
|
|||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
const dockerExe = "/usr/local/bin/docker"
|
const dockerExe = "/usr/local/bin/docker"
|
||||||
@@ -25,3 +26,40 @@ func (p Plugin) startDaemon() {
|
|||||||
cmd.Run()
|
cmd.Run()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// helper function to create the docker daemon command.
|
||||||
|
func commandDaemon(daemon Daemon) *exec.Cmd {
|
||||||
|
args := []string{
|
||||||
|
"--data-root", daemon.StoragePath,
|
||||||
|
"--host=unix:///var/run/docker.sock",
|
||||||
|
}
|
||||||
|
|
||||||
|
if daemon.StorageDriver != "" {
|
||||||
|
args = append(args, "-s", daemon.StorageDriver)
|
||||||
|
}
|
||||||
|
if daemon.Insecure && daemon.Registry != "" {
|
||||||
|
args = append(args, "--insecure-registry", daemon.Registry)
|
||||||
|
}
|
||||||
|
if daemon.IPv6 {
|
||||||
|
args = append(args, "--ipv6")
|
||||||
|
}
|
||||||
|
if len(daemon.Mirror) != 0 {
|
||||||
|
args = append(args, "--registry-mirror", daemon.Mirror)
|
||||||
|
}
|
||||||
|
if len(daemon.Bip) != 0 {
|
||||||
|
args = append(args, "--bip", daemon.Bip)
|
||||||
|
}
|
||||||
|
for _, dns := range daemon.DNS {
|
||||||
|
args = append(args, "--dns", dns)
|
||||||
|
}
|
||||||
|
for _, dnsSearch := range daemon.DNSSearch {
|
||||||
|
args = append(args, "--dns-search", dnsSearch)
|
||||||
|
}
|
||||||
|
if len(daemon.MTU) != 0 {
|
||||||
|
args = append(args, "--mtu", daemon.MTU)
|
||||||
|
}
|
||||||
|
if daemon.Experimental {
|
||||||
|
args = append(args, "--experimental")
|
||||||
|
}
|
||||||
|
return exec.Command(dockerdExe, args...)
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
package docker
|
package docker
|
||||||
|
|
||||||
const dockerExe = "C:\\bin\\docker.exe"
|
const dockerExe = "C:\\bin\\docker.exe"
|
||||||
const dockerdExe = ""
|
|
||||||
const dockerHome = "C:\\ProgramData\\docker\\"
|
const dockerHome = "C:\\ProgramData\\docker\\"
|
||||||
|
|
||||||
func (p Plugin) startDaemon() {
|
func (p Plugin) startDaemon() {
|
||||||
|
|||||||
227
docker.go
227
docker.go
@@ -6,7 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -54,52 +53,19 @@ type (
|
|||||||
Compress bool // Docker build compress
|
Compress bool // Docker build compress
|
||||||
Repo string // Docker build repository
|
Repo string // Docker build repository
|
||||||
LabelSchema []string // label-schema Label map
|
LabelSchema []string // label-schema Label map
|
||||||
AutoLabel bool // auto-label bool
|
|
||||||
Labels []string // Label map
|
Labels []string // Label map
|
||||||
Link string // Git repo link
|
|
||||||
NoCache bool // Docker build no-cache
|
NoCache bool // Docker build no-cache
|
||||||
Secret string // secret keypair
|
|
||||||
SecretEnvs []string // Docker build secrets with env var as source
|
|
||||||
SecretFiles []string // Docker build secrets with file as source
|
|
||||||
AddHost []string // Docker build add-host
|
AddHost []string // Docker build add-host
|
||||||
Quiet bool // Docker build quiet
|
Quiet bool // Docker build quiet
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin defines the Docker plugin parameters.
|
// Plugin defines the Docker plugin parameters.
|
||||||
Plugin struct {
|
Plugin struct {
|
||||||
Login Login // Docker login configuration
|
Login Login // Docker login configuration
|
||||||
Build Build // Docker build configuration
|
Build Build // Docker build configuration
|
||||||
Daemon Daemon // Docker daemon configuration
|
Daemon Daemon // Docker daemon configuration
|
||||||
Dryrun bool // Docker push is skipped
|
Dryrun bool // Docker push is skipped
|
||||||
Cleanup bool // Docker purge is enabled
|
Cleanup bool // Docker purge is enabled
|
||||||
CardPath string // Card path to write file to
|
|
||||||
}
|
|
||||||
|
|
||||||
Card []struct {
|
|
||||||
ID string `json:"Id"`
|
|
||||||
RepoTags []string `json:"RepoTags"`
|
|
||||||
ParsedRepoTags []TagStruct `json:"ParsedRepoTags"`
|
|
||||||
RepoDigests []interface{} `json:"RepoDigests"`
|
|
||||||
Parent string `json:"Parent"`
|
|
||||||
Comment string `json:"Comment"`
|
|
||||||
Created time.Time `json:"Created"`
|
|
||||||
Container string `json:"Container"`
|
|
||||||
DockerVersion string `json:"DockerVersion"`
|
|
||||||
Author string `json:"Author"`
|
|
||||||
Architecture string `json:"Architecture"`
|
|
||||||
Os string `json:"Os"`
|
|
||||||
Size int `json:"Size"`
|
|
||||||
VirtualSize int `json:"VirtualSize"`
|
|
||||||
Metadata struct {
|
|
||||||
LastTagTime time.Time `json:"LastTagTime"`
|
|
||||||
} `json:"Metadata"`
|
|
||||||
SizeString string
|
|
||||||
VirtualSizeString string
|
|
||||||
Time string
|
|
||||||
URL string `json:"URL"`
|
|
||||||
}
|
|
||||||
TagStruct struct {
|
|
||||||
Tag string `json:"Tag"`
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -112,55 +78,44 @@ func (p Plugin) Exec() error {
|
|||||||
|
|
||||||
// poll the docker daemon until it is started. This ensures the daemon is
|
// poll the docker daemon until it is started. This ensures the daemon is
|
||||||
// ready to accept connections before we proceed.
|
// ready to accept connections before we proceed.
|
||||||
for i := 0; ; i++ {
|
for i := 0; i < 15; i++ {
|
||||||
cmd := commandInfo()
|
cmd := commandInfo()
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if i == 15 {
|
|
||||||
fmt.Println("Unable to reach Docker Daemon after 15 attempts.")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
time.Sleep(time.Second * 1)
|
time.Sleep(time.Second * 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// for debugging purposes, log the type of authentication
|
// Create Auth Config File
|
||||||
// credentials that have been provided.
|
|
||||||
switch {
|
|
||||||
case p.Login.Password != "" && p.Login.Config != "":
|
|
||||||
fmt.Println("Detected registry credentials and registry credentials file")
|
|
||||||
case p.Login.Password != "":
|
|
||||||
fmt.Println("Detected registry credentials")
|
|
||||||
case p.Login.Config != "":
|
|
||||||
fmt.Println("Detected registry credentials file")
|
|
||||||
default:
|
|
||||||
fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// create Auth Config File
|
|
||||||
if p.Login.Config != "" {
|
if p.Login.Config != "" {
|
||||||
os.MkdirAll(dockerHome, 0600)
|
os.MkdirAll(dockerHome, 0600)
|
||||||
|
|
||||||
path := filepath.Join(dockerHome, "config.json")
|
path := filepath.Join(dockerHome, "config.json")
|
||||||
err := ioutil.WriteFile(path, []byte(p.Login.Config), 0600)
|
err := ioutil.WriteFile(path, []byte(p.Login.Config), 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error writing config.json: %s", err)
|
return fmt.Errorf("error writing config.json: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// login to the Docker registry
|
// login to the Docker registry
|
||||||
if p.Login.Password != "" {
|
if p.Login.Password != "" {
|
||||||
cmd := commandLogin(p.Login)
|
cmd := commandLogin(p.Login)
|
||||||
raw, err := cmd.CombinedOutput()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
out := string(raw)
|
return fmt.Errorf("error authenticating: %w", err)
|
||||||
out = strings.Replace(out, "WARNING! Using --password via the CLI is insecure. Use --password-stdin.", "", -1)
|
|
||||||
fmt.Println(out)
|
|
||||||
return fmt.Errorf("Error authenticating: exit status 1")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case p.Login.Password != "":
|
||||||
|
fmt.Println("Detected registry credentials")
|
||||||
|
case p.Login.Config != "":
|
||||||
|
fmt.Println("Detected registry credentials file")
|
||||||
|
default:
|
||||||
|
fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.")
|
||||||
|
}
|
||||||
|
|
||||||
if p.Build.Squash && !p.Daemon.Experimental {
|
if p.Build.Squash && !p.Daemon.Experimental {
|
||||||
fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...")
|
fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...")
|
||||||
p.Build.Squash = false
|
p.Build.Squash = false
|
||||||
@@ -188,6 +143,11 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.Cleanup {
|
||||||
|
cmds = append(cmds, commandRmi(p.Build.Name)) // docker rmi
|
||||||
|
cmds = append(cmds, commandPrune()) // docker system prune -f
|
||||||
|
}
|
||||||
|
|
||||||
// execute all commands in batch mode.
|
// execute all commands in batch mode.
|
||||||
for _, cmd := range cmds {
|
for _, cmd := range cmds {
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
@@ -206,26 +166,6 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// output the adaptive card
|
|
||||||
if err := p.writeCard(); err != nil {
|
|
||||||
fmt.Printf("Could not create adaptive card. %s\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// execute cleanup routines in batch mode
|
|
||||||
if p.Cleanup {
|
|
||||||
// clear the slice
|
|
||||||
cmds = nil
|
|
||||||
|
|
||||||
cmds = append(cmds, commandRmi(p.Build.Name)) // docker rmi
|
|
||||||
cmds = append(cmds, commandPrune()) // docker system prune -f
|
|
||||||
|
|
||||||
for _, cmd := range cmds {
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
trace(cmd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,19 +245,6 @@ func commandBuild(build Build) *exec.Cmd {
|
|||||||
for _, host := range build.AddHost {
|
for _, host := range build.AddHost {
|
||||||
args = append(args, "--add-host", host)
|
args = append(args, "--add-host", host)
|
||||||
}
|
}
|
||||||
if build.Secret != "" {
|
|
||||||
args = append(args, "--secret", build.Secret)
|
|
||||||
}
|
|
||||||
for _, secret := range build.SecretEnvs {
|
|
||||||
if arg, err := getSecretStringCmdArg(secret); err == nil {
|
|
||||||
args = append(args, "--secret", arg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, secret := range build.SecretFiles {
|
|
||||||
if arg, err := getSecretFileCmdArg(secret); err == nil {
|
|
||||||
args = append(args, "--secret", arg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if build.Target != "" {
|
if build.Target != "" {
|
||||||
args = append(args, "--target", build.Target)
|
args = append(args, "--target", build.Target)
|
||||||
}
|
}
|
||||||
@@ -325,22 +252,19 @@ func commandBuild(build Build) *exec.Cmd {
|
|||||||
args = append(args, "--quiet")
|
args = append(args, "--quiet")
|
||||||
}
|
}
|
||||||
|
|
||||||
if build.AutoLabel {
|
labelSchema := []string{
|
||||||
labelSchema := []string{
|
"schema-version=1.0",
|
||||||
fmt.Sprintf("created=%s", time.Now().Format(time.RFC3339)),
|
fmt.Sprintf("build-date=%s", time.Now().Format(time.RFC3339)),
|
||||||
fmt.Sprintf("revision=%s", build.Name),
|
fmt.Sprintf("vcs-ref=%s", build.Name),
|
||||||
fmt.Sprintf("source=%s", build.Remote),
|
fmt.Sprintf("vcs-url=%s", build.Remote),
|
||||||
fmt.Sprintf("url=%s", build.Link),
|
}
|
||||||
}
|
|
||||||
labelPrefix := "org.opencontainers.image"
|
|
||||||
|
|
||||||
if len(build.LabelSchema) > 0 {
|
if len(build.LabelSchema) > 0 {
|
||||||
labelSchema = append(labelSchema, build.LabelSchema...)
|
labelSchema = append(labelSchema, build.LabelSchema...)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, label := range labelSchema {
|
for _, label := range labelSchema {
|
||||||
args = append(args, "--label", fmt.Sprintf("%s.%s", labelPrefix, label))
|
args = append(args, "--label", fmt.Sprintf("org.label-schema.%s", label))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(build.Labels) > 0 {
|
if len(build.Labels) > 0 {
|
||||||
@@ -349,41 +273,9 @@ func commandBuild(build Build) *exec.Cmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to enable buildkit, for secret support
|
|
||||||
if build.Secret != "" || len(build.SecretEnvs) > 0 || len(build.SecretFiles) > 0 {
|
|
||||||
os.Setenv("DOCKER_BUILDKIT", "1")
|
|
||||||
}
|
|
||||||
return exec.Command(dockerExe, args...)
|
return exec.Command(dockerExe, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSecretStringCmdArg(kvp string) (string, error) {
|
|
||||||
return getSecretCmdArg(kvp, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func getSecretFileCmdArg(kvp string) (string, error) {
|
|
||||||
return getSecretCmdArg(kvp, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func getSecretCmdArg(kvp string, file bool) (string, error) {
|
|
||||||
delimIndex := strings.IndexByte(kvp, '=')
|
|
||||||
if delimIndex == -1 {
|
|
||||||
return "", fmt.Errorf("%s is not a valid secret", kvp)
|
|
||||||
}
|
|
||||||
|
|
||||||
key := kvp[:delimIndex]
|
|
||||||
value := kvp[delimIndex+1:]
|
|
||||||
|
|
||||||
if key == "" || value == "" {
|
|
||||||
return "", fmt.Errorf("%s is not a valid secret", kvp)
|
|
||||||
}
|
|
||||||
|
|
||||||
if file {
|
|
||||||
return fmt.Sprintf("id=%s,src=%s", key, value), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf("id=%s,env=%s", key, value), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper function to add proxy values from the environment
|
// helper function to add proxy values from the environment
|
||||||
func addProxyBuildArgs(build *Build) {
|
func addProxyBuildArgs(build *Build) {
|
||||||
addProxyValue(build, "http_proxy")
|
addProxyValue(build, "http_proxy")
|
||||||
@@ -444,47 +336,6 @@ func commandPush(build Build, tag string) *exec.Cmd {
|
|||||||
return exec.Command(dockerExe, "push", target)
|
return exec.Command(dockerExe, "push", target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function to create the docker daemon command.
|
|
||||||
func commandDaemon(daemon Daemon) *exec.Cmd {
|
|
||||||
args := []string{
|
|
||||||
"--data-root", daemon.StoragePath,
|
|
||||||
"--host=unix:///var/run/docker.sock",
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := os.Stat("/etc/docker/default.json"); err == nil {
|
|
||||||
args = append(args, "--seccomp-profile=/etc/docker/default.json")
|
|
||||||
}
|
|
||||||
|
|
||||||
if daemon.StorageDriver != "" {
|
|
||||||
args = append(args, "-s", daemon.StorageDriver)
|
|
||||||
}
|
|
||||||
if daemon.Insecure && daemon.Registry != "" {
|
|
||||||
args = append(args, "--insecure-registry", daemon.Registry)
|
|
||||||
}
|
|
||||||
if daemon.IPv6 {
|
|
||||||
args = append(args, "--ipv6")
|
|
||||||
}
|
|
||||||
if len(daemon.Mirror) != 0 {
|
|
||||||
args = append(args, "--registry-mirror", daemon.Mirror)
|
|
||||||
}
|
|
||||||
if len(daemon.Bip) != 0 {
|
|
||||||
args = append(args, "--bip", daemon.Bip)
|
|
||||||
}
|
|
||||||
for _, dns := range daemon.DNS {
|
|
||||||
args = append(args, "--dns", dns)
|
|
||||||
}
|
|
||||||
for _, dnsSearch := range daemon.DNSSearch {
|
|
||||||
args = append(args, "--dns-search", dnsSearch)
|
|
||||||
}
|
|
||||||
if len(daemon.MTU) != 0 {
|
|
||||||
args = append(args, "--mtu", daemon.MTU)
|
|
||||||
}
|
|
||||||
if daemon.Experimental {
|
|
||||||
args = append(args, "--experimental")
|
|
||||||
}
|
|
||||||
return exec.Command(dockerdExe, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper to check if args match "docker prune"
|
// helper to check if args match "docker prune"
|
||||||
func isCommandPrune(args []string) bool {
|
func isCommandPrune(args []string) bool {
|
||||||
return len(args) > 3 && args[2] == "prune"
|
return len(args) > 3 && args[2] == "prune"
|
||||||
@@ -508,11 +359,3 @@ func commandRmi(tag string) *exec.Cmd {
|
|||||||
func trace(cmd *exec.Cmd) {
|
func trace(cmd *exec.Cmd) {
|
||||||
fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " "))
|
fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDroneDockerExecCmd() string {
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
return "C:/bin/drone-docker.exe"
|
|
||||||
}
|
|
||||||
|
|
||||||
return "drone-docker"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# escape=`
|
# escape=`
|
||||||
FROM plugins/docker:windows-1809-amd64
|
FROM plugins/docker:windows-1803
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||||
org.label-schema.name="Drone ACR" `
|
org.label-schema.name="Drone ACR" `
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# escape=`
|
# escape=`
|
||||||
FROM plugins/docker:windows-1909-amd64
|
FROM plugins/docker:windows-1809
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||||
org.label-schema.name="Drone ACR" `
|
org.label-schema.name="Drone ACR" `
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# escape=`
|
|
||||||
FROM plugins/docker:windows-1803-amd64
|
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
|
||||||
org.label-schema.name="Drone ACR" `
|
|
||||||
org.label-schema.vendor="Drone.IO Community" `
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
ADD release/windows/amd64/drone-acr.exe C:/bin/drone-acr.exe
|
|
||||||
ENTRYPOINT [ "C:\\bin\\drone-acr.exe" ]
|
|
||||||
@@ -24,26 +24,14 @@ manifests:
|
|||||||
os: linux
|
os: linux
|
||||||
variant: v7
|
variant: v7
|
||||||
-
|
-
|
||||||
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
|
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: windows
|
os: windows
|
||||||
version: 1803
|
version: 1803
|
||||||
-
|
-
|
||||||
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: windows
|
os: windows
|
||||||
version: 1809
|
version: 1809
|
||||||
-
|
|
||||||
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: windows
|
|
||||||
version: 1903
|
|
||||||
-
|
|
||||||
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: windows
|
|
||||||
version: 1909
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM docker:20.10.9-dind
|
FROM docker:19.03.8-dind
|
||||||
|
|
||||||
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,5 @@ FROM arm32v6/docker:19.03.8-dind
|
|||||||
|
|
||||||
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
||||||
|
|
||||||
RUN apk --update add --virtual .build-deps curl && \
|
|
||||||
mkdir -p /etc/docker/ && \
|
|
||||||
curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/19.03/profiles/seccomp/default.json && \
|
|
||||||
sed -i 's/SCMP_ACT_ERRNO/SCMP_ACT_TRACE/g' /etc/docker/default.json && \
|
|
||||||
chmod 600 /etc/docker/default.json && \
|
|
||||||
apk del .build-deps && \
|
|
||||||
rm -rf /var/cache/apk/* && \
|
|
||||||
rm -rf /tmp/*
|
|
||||||
|
|
||||||
ADD release/linux/arm/drone-docker /bin/
|
ADD release/linux/arm/drone-docker /bin/
|
||||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]
|
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM arm64v8/docker:20.10.9-dind
|
FROM arm64v8/docker:19.03.8-dind
|
||||||
|
|
||||||
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ manifests:
|
|||||||
os: linux
|
os: linux
|
||||||
variant: v7
|
variant: v7
|
||||||
-
|
-
|
||||||
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
|
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: windows
|
os: windows
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# escape=`
|
# escape=`
|
||||||
FROM plugins/docker:windows-1809-amd64
|
FROM plugins/docker:windows-1803
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||||
org.label-schema.name="Drone ECR" `
|
org.label-schema.name="Drone ECR" `
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# escape=`
|
# escape=`
|
||||||
FROM plugins/docker:windows-1909-amd64
|
FROM plugins/docker:windows-1809
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||||
org.label-schema.name="Drone ECR" `
|
org.label-schema.name="Drone ECR" `
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# escape=`
|
|
||||||
FROM plugins/docker:windows-1803-amd64
|
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
|
||||||
org.label-schema.name="Drone ECR" `
|
|
||||||
org.label-schema.vendor="Drone.IO Community" `
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
ADD release/windows/amd64/drone-ecr.exe C:/bin/drone-ecr.exe
|
|
||||||
ENTRYPOINT [ "C:\\bin\\drone-ecr.exe" ]
|
|
||||||
@@ -24,26 +24,14 @@ manifests:
|
|||||||
os: linux
|
os: linux
|
||||||
variant: v7
|
variant: v7
|
||||||
-
|
-
|
||||||
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
|
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: windows
|
os: windows
|
||||||
version: 1803
|
version: 1803
|
||||||
-
|
-
|
||||||
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: windows
|
os: windows
|
||||||
version: 1809
|
version: 1809
|
||||||
-
|
|
||||||
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: windows
|
|
||||||
version: 1903
|
|
||||||
-
|
|
||||||
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: windows
|
|
||||||
version: 1909
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# escape=`
|
# escape=`
|
||||||
FROM plugins/docker:windows-1803-amd64
|
FROM plugins/docker:windows-1803
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||||
org.label-schema.name="Drone GCR" `
|
org.label-schema.name="Drone GCR" `
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# escape=`
|
# escape=`
|
||||||
FROM plugins/docker:windows-1809-amd64
|
FROM plugins/docker:windows-1809
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||||
org.label-schema.name="Drone GCR" `
|
org.label-schema.name="Drone GCR" `
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# escape=`
|
|
||||||
FROM plugins/docker:windows-1909-amd64
|
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
|
||||||
org.label-schema.name="Drone GCR" `
|
|
||||||
org.label-schema.vendor="Drone.IO Community" `
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
ADD release/windows/amd64/drone-gcr.exe C:/bin/drone-gcr.exe
|
|
||||||
ENTRYPOINT [ "C:\\bin\\drone-gcr.exe" ]
|
|
||||||
@@ -24,20 +24,14 @@ manifests:
|
|||||||
os: linux
|
os: linux
|
||||||
variant: v7
|
variant: v7
|
||||||
-
|
-
|
||||||
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
|
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: windows
|
os: windows
|
||||||
version: 1803
|
version: 1803
|
||||||
-
|
-
|
||||||
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: windows
|
os: windows
|
||||||
version: 1809
|
version: 1809
|
||||||
-
|
|
||||||
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: windows
|
|
||||||
version: 1909
|
|
||||||
|
|||||||
129
docker_test.go
129
docker_test.go
@@ -1,130 +1 @@
|
|||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
|
||||||
"os/exec"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestCommandBuild(t *testing.T) {
|
|
||||||
tcs := []struct {
|
|
||||||
name string
|
|
||||||
build Build
|
|
||||||
want *exec.Cmd
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "secret from env var",
|
|
||||||
build: Build{
|
|
||||||
Name: "plugins/drone-docker:latest",
|
|
||||||
Dockerfile: "Dockerfile",
|
|
||||||
Context: ".",
|
|
||||||
SecretEnvs: []string{
|
|
||||||
"foo_secret=FOO_SECRET_ENV_VAR",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
want: exec.Command(
|
|
||||||
dockerExe,
|
|
||||||
"build",
|
|
||||||
"--rm=true",
|
|
||||||
"-f",
|
|
||||||
"Dockerfile",
|
|
||||||
"-t",
|
|
||||||
"plugins/drone-docker:latest",
|
|
||||||
".",
|
|
||||||
"--secret id=foo_secret,env=FOO_SECRET_ENV_VAR",
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "secret from file",
|
|
||||||
build: Build{
|
|
||||||
Name: "plugins/drone-docker:latest",
|
|
||||||
Dockerfile: "Dockerfile",
|
|
||||||
Context: ".",
|
|
||||||
SecretFiles: []string{
|
|
||||||
"foo_secret=/path/to/foo_secret",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
want: exec.Command(
|
|
||||||
dockerExe,
|
|
||||||
"build",
|
|
||||||
"--rm=true",
|
|
||||||
"-f",
|
|
||||||
"Dockerfile",
|
|
||||||
"-t",
|
|
||||||
"plugins/drone-docker:latest",
|
|
||||||
".",
|
|
||||||
"--secret id=foo_secret,src=/path/to/foo_secret",
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "multiple mixed secrets",
|
|
||||||
build: Build{
|
|
||||||
Name: "plugins/drone-docker:latest",
|
|
||||||
Dockerfile: "Dockerfile",
|
|
||||||
Context: ".",
|
|
||||||
SecretEnvs: []string{
|
|
||||||
"foo_secret=FOO_SECRET_ENV_VAR",
|
|
||||||
"bar_secret=BAR_SECRET_ENV_VAR",
|
|
||||||
},
|
|
||||||
SecretFiles: []string{
|
|
||||||
"foo_secret=/path/to/foo_secret",
|
|
||||||
"bar_secret=/path/to/bar_secret",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
want: exec.Command(
|
|
||||||
dockerExe,
|
|
||||||
"build",
|
|
||||||
"--rm=true",
|
|
||||||
"-f",
|
|
||||||
"Dockerfile",
|
|
||||||
"-t",
|
|
||||||
"plugins/drone-docker:latest",
|
|
||||||
".",
|
|
||||||
"--secret id=foo_secret,env=FOO_SECRET_ENV_VAR",
|
|
||||||
"--secret id=bar_secret,env=BAR_SECRET_ENV_VAR",
|
|
||||||
"--secret id=foo_secret,src=/path/to/foo_secret",
|
|
||||||
"--secret id=bar_secret,src=/path/to/bar_secret",
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "invalid mixed secrets",
|
|
||||||
build: Build{
|
|
||||||
Name: "plugins/drone-docker:latest",
|
|
||||||
Dockerfile: "Dockerfile",
|
|
||||||
Context: ".",
|
|
||||||
SecretEnvs: []string{
|
|
||||||
"foo_secret=",
|
|
||||||
"=FOO_SECRET_ENV_VAR",
|
|
||||||
"",
|
|
||||||
},
|
|
||||||
SecretFiles: []string{
|
|
||||||
"foo_secret=",
|
|
||||||
"=/path/to/bar_secret",
|
|
||||||
"",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
want: exec.Command(
|
|
||||||
dockerExe,
|
|
||||||
"build",
|
|
||||||
"--rm=true",
|
|
||||||
"-f",
|
|
||||||
"Dockerfile",
|
|
||||||
"-t",
|
|
||||||
"plugins/drone-docker:latest",
|
|
||||||
".",
|
|
||||||
),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tc := range tcs {
|
|
||||||
tc := tc
|
|
||||||
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
|
||||||
cmd := commandBuild(tc.build)
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cmd.String(), tc.want.String()) {
|
|
||||||
t.Errorf("Got cmd %v, want %v", cmd, tc.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"Id": "sha256:3b0709c9afb41629c79c93355feed114d08a8c1bedd975eb53af08f4b867fd91",
|
|
||||||
"RepoTags": [
|
|
||||||
"798a0dae10d63d281eff4c06eaa12001ffd23740:latest",
|
|
||||||
"tphoney/test:latest"
|
|
||||||
],
|
|
||||||
"ParsedRepoTags": [
|
|
||||||
{
|
|
||||||
"Tag": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Tag": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Tag": "798a0dae10d63d281eff4c06eaa12001ffd23740:latest"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Tag": "tphoney/test:latest"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"RepoDigests": [
|
|
||||||
"tphoney/test@sha256:93f8b95aaae7d194208b72e94a3a90544b00c8f2ad45aeb89d81a0c6ccbc5e19"
|
|
||||||
],
|
|
||||||
"Parent": "sha256:493aa330a5929027dd8ecded9fa8c473a1508d17c0fd7d6a94a7f197f8d22c60",
|
|
||||||
"Comment": "",
|
|
||||||
"Created": "2022-02-16T11:13:40.8956582Z",
|
|
||||||
"Container": "a57c0ca4dd2e081df8758e00549f7abe83803f1a1a7aaaf1cd8e685a5eb5a097",
|
|
||||||
"DockerVersion": "20.10.9",
|
|
||||||
"Author": "",
|
|
||||||
"Architecture": "amd64",
|
|
||||||
"Os": "linux",
|
|
||||||
"Size": 14045949,
|
|
||||||
"VirtualSize": 14045949,
|
|
||||||
"Metadata": {
|
|
||||||
"LastTagTime": "2022-02-16T11:13:40.9433973Z"
|
|
||||||
},
|
|
||||||
"SizeString": "13.40MB",
|
|
||||||
"VirtualSizeString": "13.40MB",
|
|
||||||
"Time": "2022-02-16T11:13:40Z",
|
|
||||||
"URL": "http://hub.docker.com/repositories/tphoney/test/"
|
|
||||||
}
|
|
||||||
138
docs/card.json
138
docs/card.json
@@ -1,138 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "AdaptiveCard",
|
|
||||||
"body": [
|
|
||||||
{
|
|
||||||
"type": "ColumnSet",
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"type": "Column",
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"type": "Image",
|
|
||||||
"url": "https://d36jcksde1wxzq.cloudfront.net/be7833db9bddb4494d2a7c3dd659199a.png",
|
|
||||||
"size": "small"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"width": "auto"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Column",
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"type": "TextBlock",
|
|
||||||
"text": "Plugin: Drone Docker",
|
|
||||||
"wrap": true,
|
|
||||||
"size": "Small",
|
|
||||||
"weight": "Bolder",
|
|
||||||
"isSubtle": false,
|
|
||||||
"spacing": "Small"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "TextBlock",
|
|
||||||
"text": "DIGEST: ${RepoDigests[0]}",
|
|
||||||
"wrap": true,
|
|
||||||
"size": "Small",
|
|
||||||
"weight": "Lighter",
|
|
||||||
"isSubtle": true,
|
|
||||||
"spacing": "Small"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"width": "stretch"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"style": "default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "ColumnSet",
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"type": "Column",
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"type": "TextBlock",
|
|
||||||
"weight": "Lighter",
|
|
||||||
"text": "TAGS",
|
|
||||||
"wrap": true,
|
|
||||||
"size": "Small",
|
|
||||||
"isSubtle": true,
|
|
||||||
"spacing": "Medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FactSet",
|
|
||||||
"facts": [
|
|
||||||
{
|
|
||||||
"title": "${Tag}",
|
|
||||||
"value": ""
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"spacing": "Small",
|
|
||||||
"$data": "${ParsedRepoTags}",
|
|
||||||
"wrap": true,
|
|
||||||
"size": "Small",
|
|
||||||
"weight": "Bolder"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"separator": true,
|
|
||||||
"width": "auto"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Column",
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"type": "TextBlock",
|
|
||||||
"weight": "Lighter",
|
|
||||||
"text": "SIZE",
|
|
||||||
"wrap": true,
|
|
||||||
"size": "Small",
|
|
||||||
"isSubtle": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "TextBlock",
|
|
||||||
"spacing": "Small",
|
|
||||||
"text": "${SizeString}",
|
|
||||||
"wrap": true,
|
|
||||||
"weight": "Bolder"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"width": "auto",
|
|
||||||
"separator": true,
|
|
||||||
"spacing": "Medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Column",
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"type": "TextBlock",
|
|
||||||
"weight": "Lighter",
|
|
||||||
"text": "LAST PUSHED",
|
|
||||||
"wrap": true,
|
|
||||||
"size": "Small",
|
|
||||||
"isSubtle": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "TextBlock",
|
|
||||||
"spacing": "Small",
|
|
||||||
"text": "{{DATE(${Time})}} - {{TIME(${Time})}}",
|
|
||||||
"wrap": true,
|
|
||||||
"weight": "Bolder"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"width": "auto",
|
|
||||||
"separator": true,
|
|
||||||
"spacing": "Medium"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"style": "default",
|
|
||||||
"separator": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"actions": [
|
|
||||||
{
|
|
||||||
"type": "Action.OpenUrl",
|
|
||||||
"title": "Go to image",
|
|
||||||
"url": "${url}"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
||||||
"version": "1.5"
|
|
||||||
}
|
|
||||||
19
go.mod
19
go.mod
@@ -2,23 +2,12 @@ module github.com/drone-plugins/drone-docker
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aws/aws-sdk-go v1.26.7
|
github.com/aws/aws-sdk-go v1.26.7
|
||||||
github.com/coreos/go-semver v0.3.0
|
github.com/coreos/go-semver v0.2.0
|
||||||
github.com/drone/drone-go v1.7.1
|
|
||||||
github.com/inhies/go-bytesize v0.0.0-20210819104631-275770b98743
|
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.3.0
|
||||||
github.com/sirupsen/logrus v1.3.0
|
github.com/sirupsen/logrus v1.3.0
|
||||||
github.com/urfave/cli v1.22.2
|
github.com/urfave/cli v1.22.2
|
||||||
|
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e // indirect
|
||||||
|
golang.org/x/text v0.3.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
go 1.13
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
|
|
||||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
|
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
|
|
||||||
github.com/russross/blackfriday/v2 v2.0.1 // indirect
|
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 // indirect
|
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 // indirect
|
|
||||||
gopkg.in/yaml.v2 v2.2.8 // indirect
|
|
||||||
)
|
|
||||||
|
|
||||||
go 1.17
|
|
||||||
|
|||||||
21
go.sum
21
go.sum
@@ -1,19 +1,12 @@
|
|||||||
github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e/go.mod h1:Xa6lInWHNQnuWoF0YPSsx+INFA9qk7/7pTjwb3PInkY=
|
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/aws/aws-sdk-go v1.26.7 h1:ObjEnmzvSdYy8KVd3me7v/UMyCn81inLy2SyoIPoBkg=
|
github.com/aws/aws-sdk-go v1.26.7 h1:ObjEnmzvSdYy8KVd3me7v/UMyCn81inLy2SyoIPoBkg=
|
||||||
github.com/aws/aws-sdk-go v1.26.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
github.com/aws/aws-sdk-go v1.26.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||||
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
|
github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY=
|
||||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
github.com/coreos/go-semver v0.2.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 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.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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/drone/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw=
|
|
||||||
github.com/drone/drone-go v1.7.1/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
|
|
||||||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
|
||||||
github.com/inhies/go-bytesize v0.0.0-20210819104631-275770b98743 h1:X3Xxno5Ji8idrNiUoFc7QyXpqhSYlDRYQmc7mlpMBzU=
|
|
||||||
github.com/inhies/go-bytesize v0.0.0-20210819104631-275770b98743/go.mod h1:KrtyD5PFj++GKkFS/7/RRrfnRhAMGQwy75GLCHWrCNs=
|
|
||||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
|
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
|
||||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||||
@@ -31,13 +24,19 @@ github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
|
|||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
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.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
|
||||||
|
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||||
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
|
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
|
||||||
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
|
||||||
|
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
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/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.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ local test_pipeline_name = 'testing';
|
|||||||
local windows(os) = os == 'windows';
|
local windows(os) = os == 'windows';
|
||||||
|
|
||||||
local golang_image(os, version) =
|
local golang_image(os, version) =
|
||||||
'golang:' + '1.13' + if windows(os) then '-windowsservercore-' + version else '';
|
'golang:' + '1.11' + if windows(os) then '-windowsservercore-' + version else '';
|
||||||
|
|
||||||
{
|
{
|
||||||
test(os='linux', arch='amd64', version='')::
|
test(os='linux', arch='amd64', version='')::
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
# this script is used by the continuous integration server to
|
|
||||||
# build and publish the docker image for a commit to master.
|
|
||||||
$ErrorActionPreference = "Stop"
|
|
||||||
|
|
||||||
$env:GOOS="windows"
|
|
||||||
$env:GOARCH="amd64"
|
|
||||||
$env:CGO_ENABLED="0"
|
|
||||||
|
|
||||||
if (-not (Test-Path env:VERSION)) {
|
|
||||||
$env:VERSION="1809"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-Path env:REGISTRY)) {
|
|
||||||
$env:REGISTRY="docker"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo $env:GOOS
|
|
||||||
echo $env:GOARCH
|
|
||||||
echo $env:VERSION
|
|
||||||
echo $env:REGISTRY
|
|
||||||
|
|
||||||
# build the binary
|
|
||||||
Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}";
|
|
||||||
go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}
|
|
||||||
|
|
||||||
# build and publish the docker image
|
|
||||||
docker login -u ${env:USERNAME} -p ${env:PASSWORD}
|
|
||||||
Write-Host "+ docker build -f docker/${env:REGISTRY}/Dockerfile.windows.amd64.${env:VERSION} -t plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64 .";
|
|
||||||
docker build -f docker/${env:REGISTRY}/Dockerfile.windows.amd64.${env:VERSION} -t plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64 .
|
|
||||||
Write-Host "+ docker push plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64"
|
|
||||||
docker push plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64
|
|
||||||
|
|
||||||
# remove images from local cache
|
|
||||||
Write-Host "+ docker rmi plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64"
|
|
||||||
docker rmi plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
# this script is used by the continuous integration server to
|
|
||||||
# build and publish the docker image for a tagged revsision.
|
|
||||||
$ErrorActionPreference = "Stop"
|
|
||||||
|
|
||||||
$env:GOOS="windows"
|
|
||||||
$env:GOARCH="amd64"
|
|
||||||
$env:CGO_ENABLED="0"
|
|
||||||
|
|
||||||
if (-not (Test-Path env:VERSION)) {
|
|
||||||
$env:VERSION="1809"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-Path env:DRONE_SEMVER_SHORT)) {
|
|
||||||
echo "missing semver"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-Path env:REGISTRY)) {
|
|
||||||
$env:REGISTRY="docker"
|
|
||||||
}
|
|
||||||
|
|
||||||
# define the image tags
|
|
||||||
$env:IMAGE_PATCH="plugins/${env:REGISTRY}:${env:DRONE_SEMVER_SHORT}-windows-${env:VERSION}-amd64"
|
|
||||||
$env:IMAGE_MAJOR="plugins/${env:REGISTRY}:${env:DRONE_SEMVER_MAJOR}-windows-${env:VERSION}-amd64"
|
|
||||||
$env:IMAGE_MINOR="plugins/${env:REGISTRY}:${env:DRONE_SEMVER_MAJOR}.${env:DRONE_SEMVER_MINOR}-windows-${env:VERSION}-amd64"
|
|
||||||
|
|
||||||
echo "build environment:"
|
|
||||||
echo $env:GOOS
|
|
||||||
echo $env:GOARCH
|
|
||||||
echo $env:VERSION
|
|
||||||
|
|
||||||
# build the binary
|
|
||||||
Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}"
|
|
||||||
go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}
|
|
||||||
|
|
||||||
# authenticate with the docker registry
|
|
||||||
docker login -u ${env:USERNAME} -p ${env:PASSWORD}
|
|
||||||
|
|
||||||
echo "building images:"
|
|
||||||
echo ${env:IMAGE_PATCH}
|
|
||||||
echo ${env:IMAGE_MINOR}
|
|
||||||
echo ${env:IMAGE_MAJOR}
|
|
||||||
|
|
||||||
# build and tag the docker images
|
|
||||||
Write-Host "+ docker build -f docker/${env:REGISTRY}/Dockerfile.windows.amd64.${env:VERSION} -t ${env:IMAGE_PATCH} ."
|
|
||||||
docker build -f docker/${env:REGISTRY}/Dockerfile.windows.amd64.${env:VERSION} -t ${env:IMAGE_PATCH} .
|
|
||||||
Write-Host "+ docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MAJOR}"
|
|
||||||
docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MAJOR}
|
|
||||||
Write-Host "+ docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MINOR}"
|
|
||||||
docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MINOR}
|
|
||||||
|
|
||||||
# publish the docker images
|
|
||||||
Write-Host "+ docker push ${env:IMAGE_MAJOR}"
|
|
||||||
docker push ${env:IMAGE_MAJOR}
|
|
||||||
Write-Host "+ docker push ${env:IMAGE_MINOR}"
|
|
||||||
docker push ${env:IMAGE_MINOR}
|
|
||||||
Write-Host "+ docker push ${env:IMAGE_PATCH}"
|
|
||||||
docker push ${env:IMAGE_PATCH}
|
|
||||||
|
|
||||||
# remove images after from local cache
|
|
||||||
Write-Host "+ docker rmi ${env:IMAGE_MAJOR}"
|
|
||||||
docker rmi ${env:IMAGE_MAJOR}
|
|
||||||
Write-Host "+ docker rmi ${env:IMAGE_MINOR}"
|
|
||||||
docker rmi ${env:IMAGE_MINOR}
|
|
||||||
Write-Host "+ docker rmi ${env:IMAGE_PATCH}"
|
|
||||||
docker rmi ${env:IMAGE_PATCH}
|
|
||||||
Reference in New Issue
Block a user