From 9c54d0dd133419f7db55b36e95f690634913638e Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 12 Feb 2019 19:49:22 +0800 Subject: [PATCH 1/3] feat(version): support 18.06.0 tag format. Signed-off-by: Bo-Yi Wu --- go.sum | 1 + tags.go | 25 ++++++++++++++++++++----- tags_test.go | 9 +++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/go.sum b/go.sum index 1c09484..258e8ed 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,6 @@ github.com/aws/aws-sdk-go v1.16.15 h1:kQyxfRyjAwIYjf0225sn/pn+WAlncKyI8dmT3+ItMFE= github.com/aws/aws-sdk-go v1.16.15/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/bradrydzewski/cli v0.0.0-20190108225652-0d51abd87c77 h1:bXc5tB7PFVzIHUfTECDt0Orw6mIAzHePWBmemvtnfiU= github.com/bradrydzewski/cli v0.0.0-20190108225652-0d51abd87c77/go.mod h1:4SmsVk3pOgYeJlG54e23Ztd/HucXeH5RmH5bNO+uOpk= github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= diff --git a/tags.go b/tags.go index 99c7a83..8972fcc 100644 --- a/tags.go +++ b/tags.go @@ -24,6 +24,16 @@ func DefaultTagSuffix(ref, suffix string) []string { return tags } +func splitOff(input string, delim string) string { + parts := strings.SplitN(input, delim, 2) + + if len(parts) == 2 { + return parts[0] + } + + return input +} + // DefaultTags returns a set of default suggested tags based on // the commit ref. func DefaultTags(ref string) []string { @@ -40,16 +50,21 @@ func DefaultTags(ref string) []string { version.String(), } } + + v = stripTagPrefix(ref) + v = splitOff(splitOff(v, "+"), "-") + dotParts := strings.SplitN(v, ".", 3) + if version.Major == 0 { return []string{ - fmt.Sprintf("%d.%d", version.Major, version.Minor), - fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch), + fmt.Sprintf("%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor), + fmt.Sprintf("%0*d.%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor, len(dotParts[2]), version.Patch), } } return []string{ - fmt.Sprint(version.Major), - fmt.Sprintf("%d.%d", version.Major, version.Minor), - fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch), + fmt.Sprintf("%0*d", len(dotParts[0]), version.Major), + fmt.Sprintf("%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor), + fmt.Sprintf("%0*d.%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor, len(dotParts[2]), version.Patch), } } diff --git a/tags_test.go b/tags_test.go index a68bfa5..49838d5 100644 --- a/tags_test.go +++ b/tags_test.go @@ -93,6 +93,15 @@ func TestDefaultTagSuffix(t *testing.T) { "1.9.2-nanoserver", }, }, + { + Before: "refs/tags/v18.06.0", + Suffix: "nanoserver", + After: []string{ + "18-nanoserver", + "18.06-nanoserver", + "18.06.0-nanoserver", + }, + }, } for _, test := range tests { From 9e0fbb1c80bbf0c6551d427bfe22a66defee6459 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 12 Feb 2019 19:56:04 +0800 Subject: [PATCH 2/3] fix(docker): update image path --- docker/docker/Dockerfile.linux.amd64 | 2 +- docker/docker/Dockerfile.linux.arm | 2 +- docker/docker/Dockerfile.linux.arm64 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/docker/Dockerfile.linux.amd64 b/docker/docker/Dockerfile.linux.amd64 index 02b6fff..63797f1 100644 --- a/docker/docker/Dockerfile.linux.amd64 +++ b/docker/docker/Dockerfile.linux.amd64 @@ -1,4 +1,4 @@ -FROM docker:18.06-dind +FROM amd64/docker:18.06-dind ADD release/linux/amd64/drone-docker /bin/ ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"] diff --git a/docker/docker/Dockerfile.linux.arm b/docker/docker/Dockerfile.linux.arm index 310f16a..7278d45 100644 --- a/docker/docker/Dockerfile.linux.arm +++ b/docker/docker/Dockerfile.linux.arm @@ -1,4 +1,4 @@ -FROM docker:18.06-dind +FROM arm32v6/docker:18.06-dind ADD release/linux/arm/drone-docker /bin/ ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"] diff --git a/docker/docker/Dockerfile.linux.arm64 b/docker/docker/Dockerfile.linux.arm64 index 5fd6f01..502fb4c 100644 --- a/docker/docker/Dockerfile.linux.arm64 +++ b/docker/docker/Dockerfile.linux.arm64 @@ -1,4 +1,4 @@ -FROM docker:18.06-dind +FROM arm64v8/docker:18.06-dind ADD release/linux/arm64/drone-docker /bin/ ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"] From 2b358b00017af0c1b65e6858dc4c73df194bb3ce Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 12 Feb 2019 21:25:20 +0800 Subject: [PATCH 3/3] revert amd64 base image. Signed-off-by: Bo-Yi Wu --- docker/docker/Dockerfile.linux.amd64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker/Dockerfile.linux.amd64 b/docker/docker/Dockerfile.linux.amd64 index 63797f1..02b6fff 100644 --- a/docker/docker/Dockerfile.linux.amd64 +++ b/docker/docker/Dockerfile.linux.amd64 @@ -1,4 +1,4 @@ -FROM amd64/docker:18.06-dind +FROM docker:18.06-dind ADD release/linux/amd64/drone-docker /bin/ ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]