Compare commits

..

1 Commits

Author SHA1 Message Date
Ompragash Viswanathan c4ff01c1e7 Updated cmd/drone-acr/main.go and the dependencies 2025-03-24 13:33:27 +05:30
5 changed files with 431 additions and 165 deletions
+112
View File
@@ -13,3 +13,115 @@ inputSet:
type: PR type: PR
spec: spec:
number: <+trigger.prNumber> number: <+trigger.prNumber>
stages:
- parallel:
- stage:
identifier: linamd64
type: CI
spec:
execution:
steps:
- step:
identifier: Build_Push
type: Run
spec:
command: go build -a -tags netgo -o release/linux/amd64/drone-<+matrix.repo> ./cmd/drone-<+matrix.repo>
- step:
identifier: Docker_Build_and_Push
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.amd64
auto_tag_suffix: linux-amd64
- step:
identifier: BuildAndPushDockerRegistry_1
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- linux-amd64
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.amd64
- stage:
identifier: linarm64
type: CI
spec:
execution:
steps:
- step:
identifier: buildpush
type: Run
spec:
command: go build -a -tags netgo -o release/linux/arm64/drone-<+matrix.repo> ./cmd/drone-<+matrix.repo>
- step:
identifier: Docker_Build_and_Push
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.arm64
auto_tag_suffix: linux-arm64
- step:
identifier: BuildAndPushDockerRegistry_1
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- linux-arm64
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.arm64
- stage:
identifier: win1809amd64
type: CI
spec:
execution:
steps:
- step:
identifier: Docker_Build_and_Push1
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.1809
auto_tag_suffix: windows-1809-amd64
- step:
identifier: BuildAndPushDockerRegistry_2
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- windows-1809-amd64
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.1809
- stage:
identifier: winamd64
type: CI
spec:
execution:
steps:
- step:
identifier: Docker_Build_and_Push1
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.ltsc2022
auto_tag_suffix: windows-ltsc2022-amd64
- step:
identifier: BuildAndPushDockerRegistry_2
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- windows-ltsc2022-amd64
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.ltsc2022
- stage:
identifier: Manifest
type: CI
spec:
execution:
steps:
- step:
identifier: Plugin_1
type: Plugin
spec:
settings:
spec: docker/<+matrix.repo>/manifest.tmpl
+112
View File
@@ -13,3 +13,115 @@ inputSet:
type: branch type: branch
spec: spec:
branch: <+trigger.branch> branch: <+trigger.branch>
stages:
- parallel:
- stage:
identifier: linamd64
type: CI
spec:
execution:
steps:
- step:
identifier: Build_Push
type: Run
spec:
command: go build -a -tags netgo -o release/linux/amd64/drone-<+matrix.repo> ./cmd/drone-<+matrix.repo>
- step:
identifier: Docker_Build_and_Push
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.amd64
auto_tag_suffix: linux-amd64
- step:
identifier: BuildAndPushDockerRegistry_1
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- linux-amd64
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.amd64
- stage:
identifier: linarm64
type: CI
spec:
execution:
steps:
- step:
identifier: buildpush
type: Run
spec:
command: go build -a -tags netgo -o release/linux/arm64/drone-<+matrix.repo> ./cmd/drone-<+matrix.repo>
- step:
identifier: Docker_Build_and_Push
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.arm64
auto_tag_suffix: linux-arm64
- step:
identifier: BuildAndPushDockerRegistry_1
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- linux-arm64
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.arm64
- stage:
identifier: win1809amd64
type: CI
spec:
execution:
steps:
- step:
identifier: Docker_Build_and_Push1
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.1809
auto_tag_suffix: windows-1809-amd64
- step:
identifier: BuildAndPushDockerRegistry_2
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- windows-1809-amd64
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.1809
- stage:
identifier: winamd64
type: CI
spec:
execution:
steps:
- step:
identifier: Docker_Build_and_Push1
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.ltsc2022
auto_tag_suffix: windows-ltsc2022-amd64
- step:
identifier: BuildAndPushDockerRegistry_2
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- windows-ltsc2022-amd64
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.ltsc2022
- stage:
identifier: Manifest
type: CI
spec:
execution:
steps:
- step:
identifier: Plugin_1
type: Plugin
spec:
settings:
spec: docker/<+matrix.repo>/manifest.tmpl
+112
View File
@@ -13,3 +13,115 @@ inputSet:
type: tag type: tag
spec: spec:
tag: <+trigger.tag> tag: <+trigger.tag>
stages:
- parallel:
- stage:
identifier: linamd64
type: CI
spec:
execution:
steps:
- step:
identifier: Build_Push
type: Run
spec:
command: go build -a -tags netgo -o release/linux/amd64/drone-<+matrix.repo> ./cmd/drone-<+matrix.repo>
- step:
identifier: Docker_Build_and_Push
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.amd64
auto_tag_suffix: linux-amd64
- step:
identifier: BuildAndPushDockerRegistry_1
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- linux-amd64
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.amd64
- stage:
identifier: linarm64
type: CI
spec:
execution:
steps:
- step:
identifier: buildpush
type: Run
spec:
command: go build -a -tags netgo -o release/linux/arm64/drone-<+matrix.repo> ./cmd/drone-<+matrix.repo>
- step:
identifier: Docker_Build_and_Push
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.arm64
auto_tag_suffix: linux-arm64
- step:
identifier: BuildAndPushDockerRegistry_1
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- linux-arm64
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.arm64
- stage:
identifier: win1809amd64
type: CI
spec:
execution:
steps:
- step:
identifier: Docker_Build_and_Push1
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.1809
auto_tag_suffix: windows-1809-amd64
- step:
identifier: BuildAndPushDockerRegistry_2
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- windows-1809-amd64
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.1809
- stage:
identifier: winamd64
type: CI
spec:
execution:
steps:
- step:
identifier: Docker_Build_and_Push1
type: Plugin
spec:
settings:
repo: plugins/<+matrix.repo>
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.ltsc2022
auto_tag_suffix: windows-ltsc2022-amd64
- step:
identifier: BuildAndPushDockerRegistry_2
type: BuildAndPushDockerRegistry
spec:
repo: plugins/<+matrix.repo>
tags:
- windows-ltsc2022-amd64
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.ltsc2022
- stage:
identifier: Manifest
type: CI
spec:
execution:
steps:
- step:
identifier: Plugin_1
type: Plugin
spec:
settings:
spec: docker/<+matrix.repo>/manifest.tmpl
+94 -159
View File
@@ -32,8 +32,8 @@ pipeline:
name: GO VET name: GO VET
identifier: Run_1 identifier: Run_1
spec: spec:
connectorRef: Plugins_Docker_Hub_Connector connectorRef: account.harnessImage
image: golang:1.23.0 image: golang:1.22.4
shell: Sh shell: Sh
command: go vet ./... command: go vet ./...
- step: - step:
@@ -41,8 +41,8 @@ pipeline:
name: GO TEST name: GO TEST
identifier: Run_2 identifier: Run_2
spec: spec:
connectorRef: Plugins_Docker_Hub_Connector connectorRef: account.harnessImage
image: golang:1.23.0 image: golang:1.22.4
shell: Sh shell: Sh
command: go test -cover ./... command: go test -cover ./...
- parallel: - parallel:
@@ -69,21 +69,12 @@ pipeline:
name: Build Binary name: Build Binary
identifier: Build_Push identifier: Build_Push
spec: spec:
connectorRef: Plugins_Docker_Hub_Connector connectorRef: account.harnessImage
image: golang:1.23.0 image: golang:1.22.4
shell: Sh shell: Sh
command: go build -a -tags netgo -o release/linux/amd64/drone-<+matrix.repo> ./cmd/drone-<+matrix.repo> command: <+input>
envVariables: envVariables:
CGO_ENABLED: "0" CGO_ENABLED: "0"
strategy:
matrix:
repo:
- docker
- gcr
- gar
- ecr
- heroku
- acr
- step: - step:
type: Plugin type: Plugin
name: Build and Push on Tag name: Build and Push on Tag
@@ -94,45 +85,35 @@ pipeline:
settings: settings:
username: drone username: drone
password: <+secrets.getValue("Plugins_Docker_Hub_Pat")> password: <+secrets.getValue("Plugins_Docker_Hub_Pat")>
repo: plugins/<+matrix.repo> repo: <+input>
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.amd64 dockerfile: <+input>
auto_tag: "true" auto_tag: "true"
auto_tag_suffix: linux-amd64 auto_tag_suffix: <+input>
when: when:
stageStatus: Success stageStatus: Success
condition: <+codebase.build.type> == "tag" condition: <+codebase.build.type> == "tag"
strategy:
matrix:
repo:
- docker
- gcr
- gar
- ecr
- heroku
- acr
- step: - step:
type: BuildAndPushDockerRegistry type: BuildAndPushDockerRegistry
name: Build and Push on Branch name: Build and Push on Branch
identifier: BuildAndPushDockerRegistry_1 identifier: BuildAndPushDockerRegistry_1
spec: spec:
connectorRef: Plugins_Docker_Hub_Connector connectorRef: Plugins_Docker_Hub_Connector
repo: plugins/<+matrix.repo> repo: <+input>
tags: tags: <+input>
- linux-amd64
caching: true caching: true
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.amd64 dockerfile: <+input>
when: when:
stageStatus: Success stageStatus: Success
condition: <+codebase.build.type> == "branch" condition: <+codebase.build.type> == "branch"
strategy: strategy:
matrix: matrix:
repo: repo:
- docker - docker
- gcr - gcr
- gar - gar
- ecr - ecr
- heroku - heroku
- acr - acr
- stage: - stage:
name: linux-arm64 name: linux-arm64
identifier: linarm64 identifier: linarm64
@@ -156,21 +137,12 @@ pipeline:
name: Build Binary name: Build Binary
identifier: buildpush identifier: buildpush
spec: spec:
connectorRef: Plugins_Docker_Hub_Connector connectorRef: account.harnessImage
image: golang:1.23.0 image: golang:1.22.4
shell: Sh shell: Sh
command: go build -a -tags netgo -o release/linux/arm64/drone-<+matrix.repo> ./cmd/drone-<+matrix.repo> command: <+input>
envVariables: envVariables:
CGO_ENABLED: "0" CGO_ENABLED: "0"
strategy:
matrix:
repo:
- docker
- gcr
- gar
- ecr
- heroku
- acr
- step: - step:
type: Plugin type: Plugin
name: Build and Push on Tag name: Build and Push on Tag
@@ -181,45 +153,35 @@ pipeline:
settings: settings:
username: drone username: drone
password: <+secrets.getValue("Plugins_Docker_Hub_Pat")> password: <+secrets.getValue("Plugins_Docker_Hub_Pat")>
repo: plugins/<+matrix.repo> repo: <+input>
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.arm64 dockerfile: <+input>
auto_tag: "true" auto_tag: "true"
auto_tag_suffix: linux-arm64 auto_tag_suffix: <+input>
when: when:
stageStatus: Success stageStatus: Success
condition: <+codebase.build.type> == "tag" condition: <+codebase.build.type> == "tag"
strategy:
matrix:
repo:
- docker
- gcr
- gar
- ecr
- heroku
- acr
- step: - step:
type: BuildAndPushDockerRegistry type: BuildAndPushDockerRegistry
name: Build and Push on Branch name: Build and Push on Branch
identifier: BuildAndPushDockerRegistry_1 identifier: BuildAndPushDockerRegistry_1
spec: spec:
connectorRef: Plugins_Docker_Hub_Connector connectorRef: Plugins_Docker_Hub_Connector
repo: plugins/<+matrix.repo> repo: <+input>
tags: tags: <+input>
- linux-arm64
caching: true caching: true
dockerfile: docker/<+matrix.repo>/Dockerfile.linux.arm64 dockerfile: <+input>
when: when:
stageStatus: Success stageStatus: Success
condition: <+codebase.build.type> == "branch" condition: <+codebase.build.type> == "branch"
strategy: strategy:
matrix: matrix:
repo: repo:
- docker - docker
- gcr - gcr
- gar - gar
- ecr - ecr
- heroku - heroku
- acr - acr
- stage: - stage:
name: win-1809-amd64 name: win-1809-amd64
identifier: win1809amd64 identifier: win1809amd64
@@ -243,22 +205,18 @@ pipeline:
name: Build Binary name: Build Binary
identifier: go_build identifier: go_build
spec: spec:
connectorRef: Plugins_Docker_Hub_Connector connectorRef: account.harnessImage
image: golang:1.23.0 image: golang:1.22.4
shell: Sh shell: Sh
command: |- command: |-
# disable cgo # disable cgo
export CGO_ENABLED=0 export CGO_ENABLED=0
go build -o release/windows/amd64/drone-<+matrix.repo>.exe ./cmd/drone-<+matrix.repo> go build -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker
strategy: go build -o release/windows/amd64/drone-ecr.exe ./cmd/drone-ecr
matrix: go build -o release/windows/amd64/drone-gcr.exe ./cmd/drone-gcr
repo: go build -o release/windows/amd64/drone-acr.exe ./cmd/drone-acr
- docker go build -o release/windows/amd64/drone-gar.exe ./cmd/drone-gar
- gcr
- gar
- ecr
- acr
- step: - step:
type: Plugin type: Plugin
name: Build and Push on Tag name: Build and Push on Tag
@@ -269,43 +227,34 @@ pipeline:
settings: settings:
username: drone username: drone
password: <+secrets.getValue("Plugins_Docker_Hub_Pat")> password: <+secrets.getValue("Plugins_Docker_Hub_Pat")>
repo: plugins/<+matrix.repo> repo: <+input>
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.1809 dockerfile: <+input>
auto_tag: "true" auto_tag: "true"
auto_tag_suffix: windows-1809-amd64 auto_tag_suffix: <+input>
when: when:
stageStatus: Success stageStatus: Success
condition: <+codebase.build.type> == "tag" condition: <+codebase.build.type> == "tag"
strategy:
matrix:
repo:
- docker
- gcr
- gar
- ecr
- acr
- step: - step:
type: BuildAndPushDockerRegistry type: BuildAndPushDockerRegistry
name: Build and Push on Branch name: Build and Push on Branch
identifier: BuildAndPushDockerRegistry_2 identifier: BuildAndPushDockerRegistry_2
spec: spec:
connectorRef: Plugins_Docker_Hub_Connector connectorRef: Plugins_Docker_Hub_Connector
repo: plugins/<+matrix.repo> repo: <+input>
tags: tags: <+input>
- windows-1809-amd64 caching: true
caching: false dockerfile: <+input>
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.1809
when: when:
stageStatus: Success stageStatus: Success
condition: <+codebase.build.type> == "branch" condition: <+codebase.build.type> == "branch"
strategy: strategy:
matrix: matrix:
repo: repo:
- docker - docker
- gcr - gcr
- gar - gar
- ecr - ecr
- acr - acr
delegateSelectors: delegateSelectors:
- windows-vm - windows-vm
- stage: - stage:
@@ -331,24 +280,20 @@ pipeline:
name: Build Binary -ltsc2022 name: Build Binary -ltsc2022
identifier: build_amd64ltsc2022 identifier: build_amd64ltsc2022
spec: spec:
connectorRef: Plugins_Docker_Hub_Connector connectorRef: account.harnessImage
image: golang:1.23.0 image: golang:1.22.4
shell: Sh shell: Sh
command: |- command: |-
# disable cgo # disable cgo
export CGO_ENABLED=0 export CGO_ENABLED=0
go build -o release/windows/amd64/drone-<+matrix.repo>.exe ./cmd/drone-<+matrix.repo> go build -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker
go build -o release/windows/amd64/drone-ecr.exe ./cmd/drone-ecr
go build -o release/windows/amd64/drone-gcr.exe ./cmd/drone-gcr
go build -o release/windows/amd64/drone-acr.exe ./cmd/drone-acr
go build -o release/windows/amd64/drone-gar.exe ./cmd/drone-gar
envVariables: envVariables:
CGO_ENABLED: "0" CGO_ENABLED: "0"
strategy:
matrix:
repo:
- docker
- gcr
- gar
- ecr
- acr
- step: - step:
type: Plugin type: Plugin
name: Build and Push on Tag name: Build and Push on Tag
@@ -359,45 +304,36 @@ pipeline:
settings: settings:
username: drone username: drone
password: <+secrets.getValue("Plugins_Docker_Hub_Pat")> password: <+secrets.getValue("Plugins_Docker_Hub_Pat")>
repo: plugins/<+matrix.repo> repo: <+input>
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.ltsc2022 dockerfile: <+input>
auto_tag: "true" auto_tag: "true"
auto_tag_suffix: windows-ltsc2022-amd64 auto_tag_suffix: <+input>
when: when:
stageStatus: Success stageStatus: Success
condition: <+codebase.build.type> == "tag" condition: <+codebase.build.type> == "tag"
strategy:
matrix:
repo:
- docker
- gcr
- gar
- ecr
- acr
- step: - step:
type: BuildAndPushDockerRegistry type: BuildAndPushDockerRegistry
name: Build and Push on Branch name: Build and Push on Branch
identifier: BuildAndPushDockerRegistry_2 identifier: BuildAndPushDockerRegistry_2
spec: spec:
connectorRef: Plugins_Docker_Hub_Connector connectorRef: Plugins_Docker_Hub_Connector
repo: plugins/<+matrix.repo> repo: <+input>
tags: tags: <+input>
- windows-ltsc2022-amd64 caching: true
caching: false dockerfile: <+input>
dockerfile: docker/<+matrix.repo>/Dockerfile.windows.amd64.ltsc2022
when: when:
stageStatus: Success stageStatus: Success
condition: <+codebase.build.type> == "branch" condition: <+codebase.build.type> == "branch"
strategy:
matrix:
repo:
- docker
- gcr
- gar
- ecr
- acr
buildIntelligence: buildIntelligence:
enabled: false enabled: false
strategy:
matrix:
repo:
- docker
- gcr
- gar
- ecr
- acr
- stage: - stage:
name: Manifest and Release name: Manifest and Release
identifier: Manifest identifier: Manifest
@@ -422,26 +358,25 @@ pipeline:
password: <+secrets.getValue("Plugins_Docker_Hub_Pat")> password: <+secrets.getValue("Plugins_Docker_Hub_Pat")>
auto_tag: "true" auto_tag: "true"
ignore_missing: "true" ignore_missing: "true"
spec: docker/<+matrix.repo>/manifest.tmpl spec: <+input>
when: when:
stageStatus: Success stageStatus: Success
condition: <+codebase.build.type> == "tag" || <+codebase.build.type> == "branch" condition: <+codebase.build.type> == "tag" || <+codebase.build.type> == "branch"
strategy:
matrix:
repo:
- docker
- gcr
- gar
- ecr
- heroku
- acr
platform: platform:
os: Linux os: Linux
arch: Amd64 arch: Amd64
runtime: runtime:
type: Cloud type: Cloud
spec: {} spec: {}
strategy:
matrix:
repo:
- docker
- gcr
- gar
- ecr
- heroku
- acr
identifier: dronedockerharness identifier: dronedockerharness
projectIdentifier: Drone_Plugins projectIdentifier: Drone_Plugins
name: drone-docker-harness name: drone-docker-harness
allowStageExecutions: true
+1 -6
View File
@@ -10,7 +10,6 @@ import (
"net/url" "net/url"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"strings" "strings"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
@@ -29,7 +28,7 @@ type subscriptionUrlResponse struct {
} }
const ( const (
acrCertFile = "acr-cert.pem" acrCertPath = "/tmp/acr-cert.pem"
azSubscriptionApiVersion = "2021-04-01" azSubscriptionApiVersion = "2021-04-01"
azSubscriptionBaseUrl = "https://management.azure.com/subscriptions/" azSubscriptionBaseUrl = "https://management.azure.com/subscriptions/"
basePublicUrl = "https://portal.azure.com/#view/Microsoft_Azure_ContainerRegistries/TagMetadataBlade/registryId/" basePublicUrl = "https://portal.azure.com/#view/Microsoft_Azure_ContainerRegistries/TagMetadataBlade/registryId/"
@@ -42,10 +41,6 @@ const (
certPathEnv = "AZURE_CLIENT_CERTIFICATE_PATH" certPathEnv = "AZURE_CLIENT_CERTIFICATE_PATH"
) )
var (
acrCertPath = filepath.Join(os.TempDir(), acrCertFile)
)
func main() { func main() {
// Load env-file if it exists first // Load env-file if it exists first
if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" { if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" {