mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-04 18:23:49 +08:00
Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 841eb81e95 | |||
| 5df1d55e7f | |||
| 3181dc066f | |||
| a26a84a1fe | |||
| cd3745b3ca | |||
| 13a217a4af | |||
| 481ee9f624 | |||
| 0dee97e338 | |||
| ed6f3c5bf4 | |||
| 4893b5b945 | |||
| 447ee28867 | |||
| 9c90e58a2d | |||
| d998c00a4b | |||
| 2f55e25020 | |||
| f3544ce6ee | |||
| e4cd992d8d | |||
| d457df687d | |||
| 4820b6af00 | |||
| 3717723366 | |||
| be3bf8ad1e | |||
| 15255d3520 | |||
| 6ba0eb58c3 | |||
| 17e907c7cf | |||
| 190fbefe91 | |||
| 48f6e72954 | |||
| 1bee1629c2 | |||
| 2d0315e6bb | |||
| 34cfbdfbd5 | |||
| d11c254840 | |||
| 7d751135b1 | |||
| 54f2fe097a | |||
| 9c899979ff | |||
| 6ac1efad25 | |||
| 128a2d77c0 | |||
| 69e789b294 | |||
| 000711c7f1 | |||
| 864a7e5319 | |||
| 1c34458f6c | |||
| 725950ee02 | |||
| 97a3f33180 | |||
| 33e44ca23a | |||
| 1409e80406 | |||
| 97ecf9b992 | |||
| 0ae1cbc382 | |||
| fe57a616ed | |||
| 4da1f904b0 | |||
| eaeab5fddb | |||
| 546dc21a7e | |||
| d0df077e6e | |||
| d96c3d05e8 | |||
| 23b0ed0baa | |||
| 34f3316a65 | |||
| 56b0e6a779 | |||
| f1cb9b2c41 | |||
| c7770b6668 | |||
| adee644baf | |||
| f5669f55eb | |||
| 984d34fe9f | |||
| 89b4f6b0c9 | |||
| c39a1155b5 | |||
| ea64d40995 | |||
| 0cd3e162fa | |||
| f492271f45 | |||
| 7c6c33d174 | |||
| a11da49965 | |||
| fae9271dc7 | |||
| 8bd45524d4 | |||
| 427f9abb99 | |||
| dbdf13277d | |||
| c38eb07dea | |||
| de43f3afb6 | |||
| bebe65a6c2 | |||
| 0a4b18dbcb | |||
| d381ac6700 | |||
| 39f3398dfe | |||
| 59e09c14de | |||
| 5e7bcabe6a | |||
| 0a35538489 | |||
| 2172c5b7cb | |||
| 9388a47a4c |
+378
-4
@@ -1,10 +1,18 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: vm
|
||||
name: default
|
||||
|
||||
pool:
|
||||
use: ubuntu
|
||||
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang
|
||||
image: golang:1.21
|
||||
commands:
|
||||
- go test ./...
|
||||
- sh scripts/build.sh
|
||||
@@ -43,6 +51,23 @@ steps:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: gar
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-gar
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
daemon_off: false
|
||||
dockerfile: docker/gar/Dockerfile.linux.amd64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: ecr
|
||||
image: plugins/docker
|
||||
settings:
|
||||
@@ -60,11 +85,265 @@ steps:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: acr
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-acr
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
daemon_off: false
|
||||
dockerfile: docker/acr/Dockerfile.linux.amd64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: docker-kaniko-v1-9
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64-kaniko1.9.1
|
||||
daemon_off: false
|
||||
dockerfile: docker/docker/Dockerfile.linux.amd64.kaniko1.9.1
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: gcr-kaniko-v1-9
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-gcr
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64-kaniko1.9.1
|
||||
daemon_off: false
|
||||
dockerfile: docker/gcr/Dockerfile.linux.amd64.kaniko1.9.1
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: gar-kaniko-v1-9
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-gar
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64-kaniko1.9.1
|
||||
daemon_off: false
|
||||
dockerfile: docker/gar/Dockerfile.linux.amd64.kaniko1.9.1
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: ecr-kaniko-v1-9
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-ecr
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64-kaniko1.9.1
|
||||
daemon_off: false
|
||||
dockerfile: docker/ecr/Dockerfile.linux.amd64.kaniko1.9.1
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: vm
|
||||
name: arm
|
||||
|
||||
pool:
|
||||
use: ubuntu_arm64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.21
|
||||
commands:
|
||||
- go test ./...
|
||||
- sh scripts/build.sh
|
||||
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
daemon_off: false
|
||||
dockerfile: docker/docker/Dockerfile.linux.arm64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: gcr
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-gcr
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
daemon_off: false
|
||||
dockerfile: docker/gcr/Dockerfile.linux.arm64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: gar
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-gar
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
daemon_off: false
|
||||
dockerfile: docker/gar/Dockerfile.linux.arm64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: ecr
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-ecr
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
daemon_off: false
|
||||
dockerfile: docker/ecr/Dockerfile.linux.arm64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: acr
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-acr
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
daemon_off: false
|
||||
dockerfile: docker/acr/Dockerfile.linux.arm64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: docker-kaniko-v1-9
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64-kaniko1.9.1
|
||||
daemon_off: false
|
||||
dockerfile: docker/docker/Dockerfile.linux.arm64.kaniko1.9.1
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: gcr-kaniko-v1-9
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-gcr
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64-kaniko1.9.1
|
||||
daemon_off: false
|
||||
dockerfile: docker/gcr/Dockerfile.linux.arm64.kaniko1.9.1
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: gar-kaniko-v1-9
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-gar
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64-kaniko1.9.1
|
||||
daemon_off: false
|
||||
dockerfile: docker/gar/Dockerfile.linux.arm64.kaniko1.9.1
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
- name: ecr-kaniko-v1-9
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-ecr
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64-kaniko1.9.1
|
||||
daemon_off: false
|
||||
dockerfile: docker/ecr/Dockerfile.linux.arm64.kaniko1.9.1
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
---
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: notifications-docker
|
||||
|
||||
pool:
|
||||
use: ubuntu
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
@@ -94,6 +373,30 @@ steps:
|
||||
username:
|
||||
from_secret: docker_username
|
||||
|
||||
- name: manifest-gar
|
||||
pull: always
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
auto_tag: true
|
||||
ignore_missing: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
spec: docker/gar/manifest.tmpl
|
||||
username:
|
||||
from_secret: docker_username
|
||||
|
||||
- name: manifest-acr
|
||||
pull: always
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
auto_tag: true
|
||||
ignore_missing: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
spec: docker/acr/manifest.tmpl
|
||||
username:
|
||||
from_secret: docker_username
|
||||
|
||||
- name: manifest-ecr
|
||||
pull: always
|
||||
image: plugins/manifest
|
||||
@@ -112,4 +415,75 @@ trigger:
|
||||
- "refs/tags/**"
|
||||
|
||||
depends_on:
|
||||
- default
|
||||
- default
|
||||
- arm
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: notifications-docker-kaniko1-8
|
||||
|
||||
pool:
|
||||
use: ubuntu
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: manifest-docker
|
||||
pull: always
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
auto_tag: false
|
||||
ignore_missing: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
spec: docker/docker/manifest-kaniko1.9.1.tmpl
|
||||
username:
|
||||
from_secret: docker_username
|
||||
|
||||
- name: manifest-gcr
|
||||
pull: always
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
auto_tag: false
|
||||
ignore_missing: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
spec: docker/gcr/manifest-kaniko1.9.1.tmpl
|
||||
username:
|
||||
from_secret: docker_username
|
||||
|
||||
- name: manifest-gar
|
||||
pull: always
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
auto_tag: false
|
||||
ignore_missing: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
spec: docker/gar/manifest-kaniko1.9.1.tmpl
|
||||
username:
|
||||
from_secret: docker_username
|
||||
|
||||
- name: manifest-ecr
|
||||
pull: always
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
auto_tag: false
|
||||
ignore_missing: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
spec: docker/ecr/manifest-kaniko1.9.1.tmpl
|
||||
username:
|
||||
from_secret: docker_username
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/main
|
||||
- "refs/tags/**"
|
||||
|
||||
depends_on:
|
||||
- default
|
||||
- arm
|
||||
|
||||
@@ -2,3 +2,4 @@ release
|
||||
coverage.out
|
||||
vendor
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
Drone kaniko plugin uses [kaniko](https://github.com/GoogleContainerTools/kaniko) to build and publish Docker images to a container registry.
|
||||
|
||||
Plugin images are published with 1.6.0 as well as 1.9.1 kaniko version from 1.5.1 release tag. `plugins/kaniko:<release-tag>` uses 1.6.0 version while `plugins/kaniko:<release-tag>-kaniko1.9.1` uses 1.9.1 version. Similar convention is used for plugins/kaniko-ecr & plugins/kaniko-gcr images as well.
|
||||
|
||||
## Build
|
||||
|
||||
Build the binaries with the following commands:
|
||||
@@ -15,6 +17,7 @@ export GO111MODULE=on
|
||||
go build -v -a -tags netgo -o release/linux/amd64/kaniko-docker ./cmd/kaniko-docker
|
||||
go build -v -a -tags netgo -o release/linux/amd64/kaniko-gcr ./cmd/kaniko-gcr
|
||||
go build -v -a -tags netgo -o release/linux/amd64/kaniko-ecr ./cmd/kaniko-ecr
|
||||
go build -v -a -tags netgo -o release/linux/amd64/kaniko-acr ./cmd/kaniko-acr
|
||||
```
|
||||
|
||||
## Docker
|
||||
@@ -26,6 +29,11 @@ docker build \
|
||||
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
|
||||
--file docker/docker/Dockerfile.linux.amd64 --tag plugins/kaniko .
|
||||
|
||||
docker build \
|
||||
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
|
||||
--file docker/acr/Dockerfile.linux.amd64 --tag plugins/kaniko-acr .
|
||||
|
||||
docker build \
|
||||
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
@@ -36,9 +44,15 @@ docker build \
|
||||
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
|
||||
--file docker/ecr/Dockerfile.linux.amd64 --tag plugins/kaniko-ecr .
|
||||
|
||||
docker build \
|
||||
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
|
||||
--file docker/gar/Dockerfile.linux.amd64 --tag plugins/kaniko-gar .
|
||||
```
|
||||
|
||||
## Usage
|
||||
### Manual Tagging
|
||||
|
||||
```console
|
||||
docker run --rm \
|
||||
@@ -51,3 +65,79 @@ docker run --rm \
|
||||
-w /drone \
|
||||
plugins/kaniko:linux-amd64
|
||||
```
|
||||
|
||||
With expanded tagging enabled, semantic versions can be passed to PLUGIN_TAGS directly for expansion.
|
||||
|
||||
**Note**: this feature only works for build labels. Artifact labels are not supported.
|
||||
|
||||
```console
|
||||
docker run --rm \
|
||||
-e PLUGIN_TAGS=v1.2.3,latest \
|
||||
-e PLUGIN_EXPAND_TAG=true \
|
||||
-v $(pwd):/drone \
|
||||
-w /drone \
|
||||
plugins/kaniko:linux-amd64
|
||||
```
|
||||
would both be equivalent to
|
||||
|
||||
```
|
||||
PLUGIN_TAGS=1,1.2,1.2.3,latest
|
||||
```
|
||||
|
||||
This allows for passing `$DRONE_TAG` directly as a tag for repos that use [semver](https://semver.org) tags.
|
||||
|
||||
To avoid confusion between repo tags and image tags, `PLUGIN_EXPAND_TAG` also recognizes a semantic version
|
||||
without the `v` prefix. As such, the following is also equivalent to the above:
|
||||
|
||||
```console
|
||||
docker run --rm \
|
||||
-e PLUGIN_TAGS=1.2.3,latest \
|
||||
-e PLUGIN_EXPAND_TAG=true \
|
||||
-v $(pwd):/drone \
|
||||
-w /drone \
|
||||
plugins/kaniko:linux-amd64
|
||||
```
|
||||
|
||||
### Auto Tagging
|
||||
The [auto tag feature](https://plugins.drone.io/drone-plugins/drone-docker) of docker plugin is also supported.
|
||||
|
||||
When auto tagging is enabled, if any of the case is matched below, a docker build will be pushed with auto generated tags. Otherwise the docker build will be skipped.
|
||||
|
||||
**Note**: this feature only works for build labels. Artifact labels are not supported.
|
||||
|
||||
#### Git Tag Push:
|
||||
|
||||
```console
|
||||
docker run --rm \
|
||||
-e DRONE_COMMIT_REF=refs/tags/v1.2.3 \
|
||||
-e PLUGIN_REPO=foo/bar \
|
||||
-e PLUGIN_USERNAME=foo \
|
||||
-e PLUGIN_PASSWORD=bar \
|
||||
-e PLUGIN_AUTO_TAG=true \
|
||||
-v $(pwd):/drone \
|
||||
-w /drone \
|
||||
plugins/kaniko:linux-amd64
|
||||
```
|
||||
|
||||
Tags to push:
|
||||
- 1.2.3
|
||||
- 1.2
|
||||
- 1
|
||||
|
||||
#### Git Commit Push in default branch:
|
||||
|
||||
```console
|
||||
docker run --rm \
|
||||
-e DRONE_COMMIT_REF=refs/heads/master \
|
||||
-e DRONE_REPO_BRANCH=main \
|
||||
-e PLUGIN_REPO=foo/bar \
|
||||
-e PLUGIN_USERNAME=foo \
|
||||
-e PLUGIN_PASSWORD=bar \
|
||||
-e PLUGIN_AUTO_TAG=true \
|
||||
-v $(pwd):/drone \
|
||||
-w /drone \
|
||||
plugins/kaniko:linux-amd64
|
||||
```
|
||||
|
||||
Tags to push:
|
||||
- latest
|
||||
|
||||
@@ -0,0 +1,446 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
|
||||
kaniko "github.com/drone/drone-kaniko"
|
||||
"github.com/drone/drone-kaniko/pkg/artifact"
|
||||
"github.com/drone/drone-kaniko/pkg/docker"
|
||||
)
|
||||
|
||||
const (
|
||||
dockerPath string = "/kaniko/.docker"
|
||||
clientIdEnv string = "AZURE_CLIENT_ID"
|
||||
clientSecretKeyEnv string = "AZURE_CLIENT_SECRET"
|
||||
tenantKeyEnv string = "AZURE_TENANT_ID"
|
||||
certPathEnv string = "AZURE_CLIENT_CERTIFICATE_PATH"
|
||||
dockerConfigPath string = "/kaniko/.docker"
|
||||
defaultDigestFile string = "/kaniko/digest-file"
|
||||
finalUrl string = "https://portal.azure.com/#view/Microsoft_Azure_ContainerRegistries/TagMetadataBlade/registryId/"
|
||||
)
|
||||
|
||||
var (
|
||||
ACRCertPath = "/kaniko/acr-cert.pem"
|
||||
pluginVersion = "unknown"
|
||||
username = "00000000-0000-0000-0000-000000000000"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// TODO Add the env file functionality
|
||||
app := cli.NewApp()
|
||||
app.Name = "kaniko docker plugin"
|
||||
app.Usage = "kaniko docker plugin"
|
||||
app.Action = run
|
||||
app.Version = pluginVersion
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "dockerfile",
|
||||
Usage: "build dockerfile",
|
||||
Value: "Dockerfile",
|
||||
EnvVar: "PLUGIN_DOCKERFILE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "context",
|
||||
Usage: "build context",
|
||||
Value: ".",
|
||||
EnvVar: "PLUGIN_CONTEXT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "drone-commit-ref",
|
||||
Usage: "git commit ref passed by Drone",
|
||||
EnvVar: "DRONE_COMMIT_REF",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "drone-repo-branch",
|
||||
Usage: "git repository default branch passed by Drone",
|
||||
EnvVar: "DRONE_REPO_BRANCH",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "tags",
|
||||
Usage: "build tags",
|
||||
Value: &cli.StringSlice{"latest"},
|
||||
EnvVar: "PLUGIN_TAGS",
|
||||
FilePath: ".tags",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "expand-tag",
|
||||
Usage: "enable for semver tagging",
|
||||
EnvVar: "PLUGIN_EXPAND_TAG",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "auto-tag",
|
||||
Usage: "enable auto generation of build tags",
|
||||
EnvVar: "PLUGIN_AUTO_TAG",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "auto-tag-suffix",
|
||||
Usage: "the suffix of auto build tags",
|
||||
EnvVar: "PLUGIN_AUTO_TAG_SUFFIX",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "args",
|
||||
Usage: "build args",
|
||||
EnvVar: "PLUGIN_BUILD_ARGS",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "target",
|
||||
Usage: "build target",
|
||||
EnvVar: "PLUGIN_TARGET",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "repo",
|
||||
Usage: "docker repository",
|
||||
EnvVar: "PLUGIN_REPO",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "create-repository",
|
||||
Usage: "create ACR repository",
|
||||
EnvVar: "PLUGIN_CREATE_REPOSITORY",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "custom-labels",
|
||||
Usage: "additional k=v labels",
|
||||
EnvVar: "PLUGIN_CUSTOM_LABELS",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "registry",
|
||||
Usage: "ACR registry",
|
||||
EnvVar: "PLUGIN_REGISTRY",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "registry-mirrors",
|
||||
Usage: "docker registry mirrors",
|
||||
EnvVar: "PLUGIN_REGISTRY_MIRRORS",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "client-secret",
|
||||
Usage: "Azure client secret",
|
||||
EnvVar: "CLIENT_SECRET",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "client-cert",
|
||||
Usage: "Azure client certificate encoded in base64 format",
|
||||
EnvVar: "CLIENT_CERTIFICATE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "tenant-id",
|
||||
Usage: "Azure Tenant Id",
|
||||
EnvVar: "TENANT_ID",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "subscription-id",
|
||||
Usage: "Azure Subscription Id",
|
||||
EnvVar: "SUBSCRIPTION_ID",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "client-id",
|
||||
Usage: "Azure Client Id",
|
||||
EnvVar: "CLIENT_ID",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "snapshot-mode",
|
||||
Usage: "Specify one of full, redo or time as snapshot mode",
|
||||
EnvVar: "PLUGIN_SNAPSHOT_MODE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "lifecycle-policy",
|
||||
Usage: "Path to lifecycle policy file",
|
||||
EnvVar: "PLUGIN_LIFECYCLE_POLICY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "repository-policy",
|
||||
Usage: "Path to repository policy file",
|
||||
EnvVar: "PLUGIN_REPOSITORY_POLICY",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "enable-cache",
|
||||
Usage: "Set this flag to opt into caching with kaniko",
|
||||
EnvVar: "PLUGIN_ENABLE_CACHE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "cache-repo",
|
||||
Usage: "Remote repository that will be used to store cached layers. Cache repo should be present in specified registry. enable-cache needs to be set to use this flag",
|
||||
EnvVar: "PLUGIN_CACHE_REPO",
|
||||
},
|
||||
cli.IntFlag{
|
||||
Name: "cache-ttl",
|
||||
Usage: "Cache timeout in hours. Defaults to two weeks.",
|
||||
EnvVar: "PLUGIN_CACHE_TTL",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "artifact-file",
|
||||
Usage: "Artifact file location that will be generated by the plugin. This file will include information of docker images that are uploaded by the plugin.",
|
||||
EnvVar: "PLUGIN_ARTIFACT_FILE",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "no-push",
|
||||
Usage: "Set this flag if you only want to build the image, without pushing to a registry",
|
||||
EnvVar: "PLUGIN_NO_PUSH",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "verbosity",
|
||||
Usage: "Set this flag with value as oneof <panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
|
||||
EnvVar: "PLUGIN_VERBOSITY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "platform",
|
||||
Usage: "Allows to build with another default platform than the host, similarly to docker build --platform",
|
||||
EnvVar: "PLUGIN_PLATFORM",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "skip-unused-stages",
|
||||
Usage: "build only used stages",
|
||||
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func run(c *cli.Context) error {
|
||||
registry := c.String("registry")
|
||||
noPush := c.Bool("no-push")
|
||||
|
||||
publicUrl, err := setupAuth(
|
||||
c.String("tenant-id"),
|
||||
c.String("client-id"),
|
||||
c.String("client-cert"),
|
||||
c.String("client-secret"),
|
||||
c.String("subscription-id"),
|
||||
registry,
|
||||
noPush,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
plugin := kaniko.Plugin{
|
||||
Build: kaniko.Build{
|
||||
DroneCommitRef: c.String("drone-commit-ref"),
|
||||
DroneRepoBranch: c.String("drone-repo-branch"),
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
AutoTag: c.Bool("auto-tag"),
|
||||
AutoTagSuffix: c.String("auto-tag-suffix"),
|
||||
ExpandTag: c.Bool("expand-tag"),
|
||||
Args: c.StringSlice("args"),
|
||||
Target: c.String("target"),
|
||||
Repo: c.String("repo"),
|
||||
Mirrors: c.StringSlice("registry-mirrors"),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
SnapshotMode: c.String("snapshot-mode"),
|
||||
EnableCache: c.Bool("enable-cache"),
|
||||
CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")),
|
||||
CacheTTL: c.Int("cache-ttl"),
|
||||
DigestFile: defaultDigestFile,
|
||||
NoPush: noPush,
|
||||
Verbosity: c.String("verbosity"),
|
||||
Platform: c.String("platform"),
|
||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||
},
|
||||
Artifact: kaniko.Artifact{
|
||||
Tags: c.StringSlice("tags"),
|
||||
Repo: c.String("repo"),
|
||||
Registry: publicUrl, // this is public url on which the artifact can be seen
|
||||
ArtifactFile: c.String("artifact-file"),
|
||||
RegistryType: artifact.Docker,
|
||||
},
|
||||
}
|
||||
return plugin.Exec()
|
||||
}
|
||||
|
||||
func setupAuth(tenantId, clientId, cert,
|
||||
clientSecret, subscriptionId, registry string, noPush bool) (string, error) {
|
||||
if registry == "" {
|
||||
return "", fmt.Errorf("registry must be specified")
|
||||
}
|
||||
|
||||
if noPush {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// case of client secret or cert based auth
|
||||
if clientId != "" {
|
||||
// only setup auth when pushing or credentials are defined
|
||||
|
||||
token, publicUrl, err := getACRToken(subscriptionId, tenantId, clientId, clientSecret, cert, registry)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "failed to fetch ACR Token")
|
||||
}
|
||||
err = docker.CreateDockerCfgFile(username, token, registry, dockerConfigPath)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "failed to create docker config")
|
||||
}
|
||||
return publicUrl, nil
|
||||
} else {
|
||||
return "", fmt.Errorf("managed authentication is not supported")
|
||||
}
|
||||
}
|
||||
|
||||
func getACRToken(subscriptionId, tenantId, clientId, clientSecret, cert, registry string) (string, string, error) {
|
||||
if tenantId == "" {
|
||||
return "", "", fmt.Errorf("tenantId can't be empty for AAD authentication")
|
||||
}
|
||||
|
||||
if clientId == "" {
|
||||
return "", "", fmt.Errorf("clientId can't be empty for AAD authentication")
|
||||
}
|
||||
|
||||
if clientSecret == "" && cert == "" {
|
||||
return "", "", fmt.Errorf("one of client secret or cert should be defined")
|
||||
}
|
||||
|
||||
// in case of authentication via cert
|
||||
if cert != "" {
|
||||
err := setupACRCert(cert)
|
||||
if err != nil {
|
||||
errors.Wrap(err, "failed to push setup cert file")
|
||||
}
|
||||
}
|
||||
|
||||
if err := os.Setenv(clientIdEnv, clientId); err != nil {
|
||||
return "", "", errors.Wrap(err, "failed to set env variable client Id")
|
||||
}
|
||||
if err := os.Setenv(clientSecretKeyEnv, clientSecret); err != nil {
|
||||
return "", "", errors.Wrap(err, "failed to set env variable client secret")
|
||||
}
|
||||
if err := os.Setenv(tenantKeyEnv, tenantId); err != nil {
|
||||
return "", "", errors.Wrap(err, "failed to set env variable tenant Id")
|
||||
}
|
||||
if err := os.Setenv(certPathEnv, ACRCertPath); err != nil {
|
||||
return "", "", errors.Wrap(err, "failed to set env variable cert path")
|
||||
}
|
||||
env, err := azidentity.NewEnvironmentCredential(nil)
|
||||
if err != nil {
|
||||
return "", "", errors.Wrap(err, "failed to get env credentials from azure")
|
||||
}
|
||||
|
||||
policy := policy.TokenRequestOptions{
|
||||
Scopes: []string{"https://management.azure.com/.default"},
|
||||
}
|
||||
os.Unsetenv(clientIdEnv)
|
||||
os.Unsetenv(clientSecretKeyEnv)
|
||||
os.Unsetenv(tenantKeyEnv)
|
||||
os.Unsetenv(certPathEnv)
|
||||
|
||||
azToken, err := env.GetToken(context.Background(), policy)
|
||||
if err != nil {
|
||||
return "", "", errors.Wrap(err, "failed to fetch access token")
|
||||
}
|
||||
|
||||
publicUrl, err := getPublicUrl(azToken.Token, registry, subscriptionId)
|
||||
if err != nil {
|
||||
// execution should not fail because of this error.
|
||||
fmt.Fprintf(os.Stderr, "failed to get public url with error: %s\n", err)
|
||||
}
|
||||
|
||||
ACRToken, err := fetchACRToken(tenantId, azToken.Token, registry)
|
||||
if err != nil {
|
||||
return "", "", errors.Wrap(err, "failed to fetch ACR token")
|
||||
}
|
||||
return ACRToken, publicUrl, nil
|
||||
}
|
||||
|
||||
func fetchACRToken(tenantId, token, registry string) (string, error) {
|
||||
formData := url.Values{
|
||||
"grant_type": {"access_token"},
|
||||
"service": {registry},
|
||||
"tenant": {tenantId},
|
||||
"access_token": {token},
|
||||
}
|
||||
jsonResponse, err := http.PostForm(fmt.Sprintf("https://%s/oauth2/exchange", registry), formData)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "failed to fetch ACR token")
|
||||
}
|
||||
var response map[string]interface{}
|
||||
err = json.NewDecoder(jsonResponse.Body).Decode(&response)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "failed to decode oauth exchange response")
|
||||
}
|
||||
|
||||
if x, found := response["refresh_token"]; found {
|
||||
s, ok := x.(string)
|
||||
if !ok {
|
||||
errors.New("failed to cast refresh token from acr")
|
||||
} else {
|
||||
return s, nil
|
||||
}
|
||||
} else {
|
||||
return "", errors.Wrap(err, "refresh token not found in response of oauth exchange call")
|
||||
}
|
||||
return "", errors.New("failed to get refresh token from acr")
|
||||
}
|
||||
|
||||
func setupACRCert(cert string) error {
|
||||
decoded, err := base64.StdEncoding.DecodeString(cert)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to base64 decode ACR certificate")
|
||||
}
|
||||
err = ioutil.WriteFile(ACRCertPath, []byte(decoded), 0644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to write ACR certificate")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getPublicUrl(token, registryUrl, subscriptionId string) (string, error) {
|
||||
// for backward compatibilty, if the subscription id is not defined, do not fail step.
|
||||
if len(subscriptionId) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
registry := strings.Split(registryUrl, ".")[0]
|
||||
burl := "https://management.azure.com/subscriptions/" +
|
||||
subscriptionId + "/resources?$filter=resourceType%20eq%20'Microsoft.ContainerRegistry/registries'%20and%20name%20eq%20'" +
|
||||
registry + "'&api-version=2021-04-01&$select=id"
|
||||
|
||||
method := "GET"
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest(method, burl, nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return "", errors.Wrap(err, "failed to create request for getting container registry setting")
|
||||
}
|
||||
|
||||
req.Header.Add("Authorization", "Bearer "+token)
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return "", errors.Wrap(err, "failed to send request for getting container registry setting")
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
var response strct
|
||||
err = json.NewDecoder(res.Body).Decode(&response)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "failed to send request for getting container registry setting")
|
||||
}
|
||||
return finalUrl + encodeParam(response.Value[0].ID), nil
|
||||
}
|
||||
|
||||
func encodeParam(s string) string {
|
||||
return url.QueryEscape(s)
|
||||
}
|
||||
|
||||
type strct struct {
|
||||
Value []struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"value"`
|
||||
}
|
||||
+134
-30
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/pkg/errors"
|
||||
@@ -12,7 +13,7 @@ import (
|
||||
"github.com/urfave/cli"
|
||||
|
||||
kaniko "github.com/drone/drone-kaniko"
|
||||
"github.com/drone/drone-kaniko/cmd/artifact"
|
||||
"github.com/drone/drone-kaniko/pkg/artifact"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -20,8 +21,9 @@ const (
|
||||
dockerPath string = "/kaniko/.docker"
|
||||
dockerConfigPath string = "/kaniko/.docker/config.json"
|
||||
|
||||
v1Registry string = "https://index.docker.io/v1/" // Default registry
|
||||
v2Registry string = "https://index.docker.io/v2/" // v2 registry is not supported
|
||||
v1RegistryURL string = "https://index.docker.io/v1/" // Default registry
|
||||
v2RegistryURL string = "https://index.docker.io/v2/" // v2 registry is not supported
|
||||
v2HubRegistryURL string = "https://registry.hub.docker.com/v2/"
|
||||
|
||||
defaultDigestFile string = "/kaniko/digest-file"
|
||||
)
|
||||
@@ -56,6 +58,16 @@ func main() {
|
||||
Value: ".",
|
||||
EnvVar: "PLUGIN_CONTEXT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "drone-commit-ref",
|
||||
Usage: "git commit ref passed by Drone",
|
||||
EnvVar: "DRONE_COMMIT_REF",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "drone-repo-branch",
|
||||
Usage: "git repository default branch passed by Drone",
|
||||
EnvVar: "DRONE_REPO_BRANCH",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "tags",
|
||||
Usage: "build tags",
|
||||
@@ -63,6 +75,31 @@ func main() {
|
||||
EnvVar: "PLUGIN_TAGS",
|
||||
FilePath: ".tags",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "expand-repo",
|
||||
Usage: "Prepends the registry url to the repo if registry url is not specified in repo name",
|
||||
EnvVar: "PLUGIN_EXPAND_REPO",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "expand-tag",
|
||||
Usage: "enable for semver tagging",
|
||||
EnvVar: "PLUGIN_EXPAND_TAG",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "auto-tag",
|
||||
Usage: "enable auto generation of build tags",
|
||||
EnvVar: "PLUGIN_AUTO_TAG",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "dockerconfig",
|
||||
Usage: "docker json dockerconfig",
|
||||
EnvVar: "PLUGIN_CONFIG",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "auto-tag-suffix",
|
||||
Usage: "the suffix of auto build tags",
|
||||
EnvVar: "PLUGIN_AUTO_TAG_SUFFIX",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "args",
|
||||
Usage: "build args",
|
||||
@@ -86,9 +123,14 @@ func main() {
|
||||
cli.StringFlag{
|
||||
Name: "registry",
|
||||
Usage: "docker registry",
|
||||
Value: v1Registry,
|
||||
Value: v1RegistryURL,
|
||||
EnvVar: "PLUGIN_REGISTRY",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "registry-mirrors",
|
||||
Usage: "docker registry mirrors",
|
||||
EnvVar: "PLUGIN_REGISTRY_MIRRORS",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "username",
|
||||
Usage: "docker username",
|
||||
@@ -134,11 +176,31 @@ func main() {
|
||||
Usage: "Set this flag if you only want to build the image, without pushing to a registry",
|
||||
EnvVar: "PLUGIN_NO_PUSH",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "tar-path",
|
||||
Usage: "Set this flag to save the image as a tarball at path",
|
||||
EnvVar: "PLUGIN_TAR_PATH",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "verbosity",
|
||||
Usage: "Set this flag with value as oneof <panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
|
||||
EnvVar: "PLUGIN_VERBOSITY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "platform",
|
||||
Usage: "Allows to build with another default platform than the host, similarly to docker build --platform",
|
||||
EnvVar: "PLUGIN_PLATFORM",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "skip-unused-stages",
|
||||
Usage: "build only used stages",
|
||||
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "output-file",
|
||||
Usage: "Output file location that will be generated by the plugin. This file will include information of the output that are exported by the plugin.",
|
||||
EnvVar: "DRONE_OUTPUT",
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
@@ -149,9 +211,15 @@ func main() {
|
||||
func run(c *cli.Context) error {
|
||||
username := c.String("username")
|
||||
noPush := c.Bool("no-push")
|
||||
configOverride := c.String("dockerconfig")
|
||||
|
||||
// only setup auth when pushing or credentials are defined
|
||||
if !noPush || username != "" {
|
||||
// if configOverride is provided, use this for docker auth
|
||||
if len(configOverride) > 0 {
|
||||
if err := writeDockerCfgFile([]byte(configOverride)); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if !noPush || username != "" {
|
||||
// setup auth when pushing or credentials are defined and docker config override is false
|
||||
if err := createDockerCfgFile(username, c.String("password"), c.String("registry")); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -159,29 +227,41 @@ func run(c *cli.Context) error {
|
||||
|
||||
plugin := kaniko.Plugin{
|
||||
Build: kaniko.Build{
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
Args: c.StringSlice("args"),
|
||||
Target: c.String("target"),
|
||||
Repo: c.String("repo"),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
SkipTlsVerify: c.Bool("skip-tls-verify"),
|
||||
SnapshotMode: c.String("snapshot-mode"),
|
||||
EnableCache: c.Bool("enable-cache"),
|
||||
CacheRepo: c.String("cache-repo"),
|
||||
CacheTTL: c.Int("cache-ttl"),
|
||||
DigestFile: defaultDigestFile,
|
||||
NoPush: noPush,
|
||||
Verbosity: c.String("verbosity"),
|
||||
DroneCommitRef: c.String("drone-commit-ref"),
|
||||
DroneRepoBranch: c.String("drone-repo-branch"),
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
AutoTag: c.Bool("auto-tag"),
|
||||
AutoTagSuffix: c.String("auto-tag-suffix"),
|
||||
ExpandTag: c.Bool("expand-tag"),
|
||||
Args: c.StringSlice("args"),
|
||||
Target: c.String("target"),
|
||||
Repo: buildRepo(c.String("registry"), c.String("repo"), c.Bool("expand-repo")),
|
||||
Mirrors: c.StringSlice("registry-mirrors"),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
SkipTlsVerify: c.Bool("skip-tls-verify"),
|
||||
SnapshotMode: c.String("snapshot-mode"),
|
||||
EnableCache: c.Bool("enable-cache"),
|
||||
CacheRepo: buildRepo(c.String("registry"), c.String("cache-repo"), c.Bool("expand-repo")),
|
||||
CacheTTL: c.Int("cache-ttl"),
|
||||
DigestFile: defaultDigestFile,
|
||||
NoPush: noPush,
|
||||
TarPath: c.String("tar-path"),
|
||||
Verbosity: c.String("verbosity"),
|
||||
Platform: c.String("platform"),
|
||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||
},
|
||||
Artifact: kaniko.Artifact{
|
||||
Tags: c.StringSlice("tags"),
|
||||
Repo: c.String("repo"),
|
||||
Repo: buildRepo(c.String("registry"), c.String("repo"), c.Bool("expand-repo")),
|
||||
Registry: c.String("registry"),
|
||||
ArtifactFile: c.String("artifact-file"),
|
||||
RegistryType: artifact.Docker,
|
||||
},
|
||||
Output: kaniko.Output{
|
||||
OutputFile: c.String("output-file"),
|
||||
},
|
||||
}
|
||||
return plugin.Exec()
|
||||
}
|
||||
@@ -198,23 +278,47 @@ func createDockerCfgFile(username, password, registry string) error {
|
||||
return fmt.Errorf("Registry must be specified")
|
||||
}
|
||||
|
||||
if registry == v2Registry {
|
||||
if registry == v2RegistryURL || registry == v2HubRegistryURL {
|
||||
fmt.Println("Docker v2 registry is not supported in kaniko. Refer issue: https://github.com/GoogleContainerTools/kaniko/issues/1209")
|
||||
fmt.Printf("Using v1 registry instead: %s\n", v1Registry)
|
||||
registry = v1Registry
|
||||
}
|
||||
|
||||
err := os.MkdirAll(dockerPath, 0600)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to create %s directory", dockerPath))
|
||||
fmt.Printf("Using v1 registry instead: %s\n", v1RegistryURL)
|
||||
registry = v1RegistryURL
|
||||
}
|
||||
|
||||
authBytes := []byte(fmt.Sprintf("%s:%s", username, password))
|
||||
encodedString := base64.StdEncoding.EncodeToString(authBytes)
|
||||
jsonBytes := []byte(fmt.Sprintf(`{"auths": {"%s": {"auth": "%s"}}}`, registry, encodedString))
|
||||
|
||||
if err := writeDockerCfgFile(jsonBytes); err != nil {
|
||||
return errors.Wrap(err, "failed to write docker config file")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Write json bytes in the docker config file
|
||||
func writeDockerCfgFile(jsonBytes []byte) error {
|
||||
err := os.MkdirAll(dockerPath, 0600)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to create %s directory", dockerPath))
|
||||
}
|
||||
err = ioutil.WriteFile(dockerConfigPath, jsonBytes, 0644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create docker config file")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildRepo(registry, repo string, expandRepo bool) string {
|
||||
if !expandRepo || registry == "" || registry == v1RegistryURL {
|
||||
// No custom registry, just return the repo name
|
||||
return repo
|
||||
}
|
||||
// Trim off trailing slash to prevent double slash when combining with repo
|
||||
registry = strings.TrimSuffix(registry, "/")
|
||||
if strings.HasPrefix(repo, registry+"/") {
|
||||
// Repo already includes the registry prefix
|
||||
// For backward compatibility, we won't add the prefix again.
|
||||
return repo
|
||||
}
|
||||
// Prefix the repo with the registry
|
||||
return registry + "/" + repo
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_buildRepo(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
registry string
|
||||
repo string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "dockerhub",
|
||||
repo: "golang",
|
||||
want: "golang",
|
||||
},
|
||||
{
|
||||
name: "internal",
|
||||
registry: "artifactory.example.com",
|
||||
repo: "service",
|
||||
want: "artifactory.example.com/service",
|
||||
},
|
||||
{
|
||||
name: "backward_compatibility",
|
||||
registry: "artifactory.example.com",
|
||||
repo: "artifactory.example.com/service",
|
||||
want: "artifactory.example.com/service",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := buildRepo(tt.registry, tt.repo, true); got != tt.want {
|
||||
t.Errorf("buildRepo(%q, %q) = %v, want %v", tt.registry, tt.repo, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
+283
-73
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
@@ -12,14 +13,21 @@ import (
|
||||
"github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/service/ecr"
|
||||
"github.com/aws/aws-sdk-go-v2/service/ecrpublic"
|
||||
awsv1 "github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
ecrv1 "github.com/aws/aws-sdk-go/service/ecr"
|
||||
ecrpublicv1 "github.com/aws/aws-sdk-go/service/ecrpublic"
|
||||
"github.com/aws/smithy-go"
|
||||
kaniko "github.com/drone/drone-kaniko"
|
||||
"github.com/drone/drone-kaniko/cmd/artifact"
|
||||
"github.com/drone/drone-kaniko/pkg/docker"
|
||||
"github.com/hashicorp/go-version"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
|
||||
kaniko "github.com/drone/drone-kaniko"
|
||||
"github.com/drone/drone-kaniko/pkg/artifact"
|
||||
"github.com/drone/drone-kaniko/pkg/docker"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -27,12 +35,14 @@ const (
|
||||
secretKeyEnv string = "AWS_SECRET_ACCESS_KEY"
|
||||
dockerConfigPath string = "/kaniko/.docker/config.json"
|
||||
ecrPublicDomain string = "public.ecr.aws"
|
||||
kanikoVersionEnv string = "KANIKO_VERSION"
|
||||
|
||||
defaultDigestFile string = "/kaniko/digest-file"
|
||||
oneDotEightVersion string = "1.8.0"
|
||||
defaultDigestFile string = "/kaniko/digest-file"
|
||||
)
|
||||
|
||||
var (
|
||||
version = "unknown"
|
||||
pluginVersion = "unknown"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -47,7 +57,7 @@ func main() {
|
||||
app.Name = "kaniko docker plugin"
|
||||
app.Usage = "kaniko docker plugin"
|
||||
app.Action = run
|
||||
app.Version = version
|
||||
app.Version = pluginVersion
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "dockerfile",
|
||||
@@ -55,6 +65,11 @@ func main() {
|
||||
Value: "Dockerfile",
|
||||
EnvVar: "PLUGIN_DOCKERFILE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "docker-registry",
|
||||
Usage: "docker registry",
|
||||
EnvVar: "PLUGIN_DOCKER_REGISTRY,DOCKER_REGISTRY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "docker-username",
|
||||
Usage: "docker username",
|
||||
@@ -71,6 +86,16 @@ func main() {
|
||||
Value: ".",
|
||||
EnvVar: "PLUGIN_CONTEXT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "drone-commit-ref",
|
||||
Usage: "git commit ref passed by Drone",
|
||||
EnvVar: "DRONE_COMMIT_REF",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "drone-repo-branch",
|
||||
Usage: "git repository default branch passed by Drone",
|
||||
EnvVar: "DRONE_REPO_BRANCH",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "tags",
|
||||
Usage: "build tags",
|
||||
@@ -78,6 +103,21 @@ func main() {
|
||||
EnvVar: "PLUGIN_TAGS",
|
||||
FilePath: ".tags",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "expand-tag",
|
||||
Usage: "enable for semver tagging",
|
||||
EnvVar: "PLUGIN_EXPAND_TAG",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "auto-tag",
|
||||
Usage: "enable auto generation of build tags",
|
||||
EnvVar: "PLUGIN_AUTO_TAG",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "auto-tag-suffix",
|
||||
Usage: "the suffix of auto build tags",
|
||||
EnvVar: "PLUGIN_AUTO_TAG_SUFFIX",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "args",
|
||||
Usage: "build args",
|
||||
@@ -114,6 +154,11 @@ func main() {
|
||||
Usage: "ECR registry",
|
||||
EnvVar: "PLUGIN_REGISTRY",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "registry-mirrors",
|
||||
Usage: "docker registry mirrors",
|
||||
EnvVar: "PLUGIN_REGISTRY_MIRRORS",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "access-key",
|
||||
Usage: "ECR access key",
|
||||
@@ -124,6 +169,16 @@ func main() {
|
||||
Usage: "ECR secret key",
|
||||
EnvVar: "PLUGIN_SECRET_KEY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "assume-role",
|
||||
Usage: "Assume a role",
|
||||
EnvVar: "PLUGIN_ASSUME_ROLE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "external-id",
|
||||
Usage: "Used along with assume role to assume a role",
|
||||
EnvVar: "PLUGIN_EXTERNAL_ID",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "snapshot-mode",
|
||||
Usage: "Specify one of full, redo or time as snapshot mode",
|
||||
@@ -169,6 +224,16 @@ func main() {
|
||||
Usage: "Set this flag with value as oneof <panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
|
||||
EnvVar: "PLUGIN_VERBOSITY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "platform",
|
||||
Usage: "Allows to build with another default platform than the host, similarly to docker build --platform",
|
||||
EnvVar: "PLUGIN_PLATFORM",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "skip-unused-stages",
|
||||
Usage: "build only used stages",
|
||||
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
@@ -181,13 +246,19 @@ func run(c *cli.Context) error {
|
||||
registry := c.String("registry")
|
||||
region := c.String("region")
|
||||
noPush := c.Bool("no-push")
|
||||
assumeRole := c.String("assume-role")
|
||||
externalId := c.String("external-id")
|
||||
|
||||
dockerConfig, err := createDockerConfig(
|
||||
c.String("docker-registry"),
|
||||
c.String("docker-username"),
|
||||
c.String("docker-password"),
|
||||
c.String("access-key"),
|
||||
c.String("secret-key"),
|
||||
registry,
|
||||
assumeRole,
|
||||
externalId,
|
||||
region,
|
||||
noPush,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -205,7 +276,7 @@ func run(c *cli.Context) error {
|
||||
|
||||
// only create repository when pushing and create-repository is true
|
||||
if !noPush && c.Bool("create-repository") {
|
||||
if err := createRepository(region, repo, registry); err != nil {
|
||||
if err := createRepository(region, repo, registry, assumeRole, externalId); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -215,7 +286,7 @@ func run(c *cli.Context) error {
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
if err := uploadLifeCyclePolicy(region, repo, string(contents)); err != nil {
|
||||
if err := uploadLifeCyclePolicy(region, repo, string(contents), assumeRole, externalId); err != nil {
|
||||
logrus.Fatal(fmt.Sprintf("error uploading ECR lifecycle policy: %v", err))
|
||||
}
|
||||
}
|
||||
@@ -225,27 +296,35 @@ func run(c *cli.Context) error {
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
if err := uploadRepositoryPolicy(region, repo, registry, string(contents)); err != nil {
|
||||
if err := uploadRepositoryPolicy(region, repo, registry, string(contents), assumeRole, externalId); err != nil {
|
||||
logrus.Fatal(fmt.Sprintf("error uploading ECR lifecycle policy: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
plugin := kaniko.Plugin{
|
||||
Build: kaniko.Build{
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
Args: c.StringSlice("args"),
|
||||
Target: c.String("target"),
|
||||
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
SnapshotMode: c.String("snapshot-mode"),
|
||||
EnableCache: c.Bool("enable-cache"),
|
||||
CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")),
|
||||
CacheTTL: c.Int("cache-ttl"),
|
||||
DigestFile: defaultDigestFile,
|
||||
NoPush: noPush,
|
||||
Verbosity: c.String("verbosity"),
|
||||
DroneCommitRef: c.String("drone-commit-ref"),
|
||||
DroneRepoBranch: c.String("drone-repo-branch"),
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
AutoTag: c.Bool("auto-tag"),
|
||||
AutoTagSuffix: c.String("auto-tag-suffix"),
|
||||
ExpandTag: c.Bool("expand-tag"),
|
||||
Args: c.StringSlice("args"),
|
||||
Target: c.String("target"),
|
||||
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
|
||||
Mirrors: c.StringSlice("registry-mirrors"),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
SnapshotMode: c.String("snapshot-mode"),
|
||||
EnableCache: c.Bool("enable-cache"),
|
||||
CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")),
|
||||
CacheTTL: c.Int("cache-ttl"),
|
||||
DigestFile: defaultDigestFile,
|
||||
NoPush: noPush,
|
||||
Verbosity: c.String("verbosity"),
|
||||
Platform: c.String("platform"),
|
||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||
},
|
||||
Artifact: kaniko.Artifact{
|
||||
Tags: c.StringSlice("tags"),
|
||||
@@ -258,15 +337,27 @@ func run(c *cli.Context) error {
|
||||
return plugin.Exec()
|
||||
}
|
||||
|
||||
func createDockerConfig(dockerUsername, dockerPassword, accessKey, secretKey, registry string, noPush bool) (*docker.Config, error) {
|
||||
func createDockerConfig(dockerRegistry, dockerUsername, dockerPassword, accessKey, secretKey,
|
||||
registry, assumeRole, externalId, region string, noPush bool) (*docker.Config, error) {
|
||||
dockerConfig := docker.NewConfig()
|
||||
|
||||
if dockerUsername != "" {
|
||||
dockerConfig.SetAuth(docker.RegistryV1, dockerUsername, dockerPassword)
|
||||
// if no docker registry provided, use dockerhub by default
|
||||
if len(dockerRegistry) == 0 {
|
||||
dockerRegistry = docker.RegistryV1
|
||||
}
|
||||
dockerConfig.SetAuth(dockerRegistry, dockerUsername, dockerPassword)
|
||||
}
|
||||
|
||||
// only setup auth when pushing or credentials are defined
|
||||
if !noPush || accessKey != "" {
|
||||
if assumeRole != "" {
|
||||
var err error
|
||||
username, password, registry, err := getAssumeRoleCreds(region, assumeRole, externalId, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dockerConfig.SetAuth(registry, username, password)
|
||||
} else if !noPush || accessKey != "" {
|
||||
// only setup auth when pushing or credentials are defined
|
||||
if registry == "" {
|
||||
return nil, fmt.Errorf("registry must be specified")
|
||||
}
|
||||
@@ -284,14 +375,18 @@ func createDockerConfig(dockerUsername, dockerPassword, accessKey, secretKey, re
|
||||
}
|
||||
}
|
||||
|
||||
dockerConfig.SetCredHelper(ecrPublicDomain, "ecr-login")
|
||||
dockerConfig.SetCredHelper(registry, "ecr-login")
|
||||
// kaniko-executor >=1.8.0 does not require additional cred helper logic for ECR,
|
||||
// as it discovers ECR repositories automatically and acts accordingly.
|
||||
if isKanikoVersionBelowOneDotEight(os.Getenv(kanikoVersionEnv)) {
|
||||
dockerConfig.SetCredHelper(ecrPublicDomain, "ecr-login")
|
||||
dockerConfig.SetCredHelper(registry, "ecr-login")
|
||||
}
|
||||
}
|
||||
|
||||
return dockerConfig, nil
|
||||
}
|
||||
|
||||
func createRepository(region, repo, registry string) error {
|
||||
func createRepository(region, repo, registry, assumeRole, externalId string) error {
|
||||
if registry == "" {
|
||||
return fmt.Errorf("registry must be specified")
|
||||
}
|
||||
@@ -300,22 +395,29 @@ func createRepository(region, repo, registry string) error {
|
||||
return fmt.Errorf("repo must be specified")
|
||||
}
|
||||
|
||||
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to load aws config")
|
||||
}
|
||||
|
||||
var createErr error
|
||||
|
||||
//create public repo
|
||||
//if registry string starts with public domain (ex: public.ecr.aws/example-registry)
|
||||
if isRegistryPublic(registry) {
|
||||
svc := ecrpublic.NewFromConfig(cfg)
|
||||
_, createErr = svc.CreateRepository(context.TODO(), &ecrpublic.CreateRepositoryInput{RepositoryName: &repo})
|
||||
//create private repo
|
||||
if assumeRole != "" {
|
||||
if isRegistryPublic(registry) {
|
||||
_, createErr = getAssumeRoleEcrPublicSvc(region, assumeRole, externalId).CreateRepository(&ecrpublicv1.CreateRepositoryInput{RepositoryName: &repo})
|
||||
} else {
|
||||
_, createErr = getAssumeRoleEcrSvc(region, assumeRole, externalId).CreateRepository(&ecrv1.CreateRepositoryInput{RepositoryName: &repo})
|
||||
}
|
||||
} else {
|
||||
svc := ecr.NewFromConfig(cfg)
|
||||
_, createErr = svc.CreateRepository(context.TODO(), &ecr.CreateRepositoryInput{RepositoryName: &repo})
|
||||
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to load aws config")
|
||||
}
|
||||
//create public repo
|
||||
//if registry string starts with public domain (ex: public.ecr.aws/example-registry)
|
||||
if isRegistryPublic(registry) {
|
||||
svc := ecrpublic.NewFromConfig(cfg)
|
||||
_, createErr = svc.CreateRepository(context.TODO(), &ecrpublic.CreateRepositoryInput{RepositoryName: &repo})
|
||||
//create private repo
|
||||
} else {
|
||||
svc := ecr.NewFromConfig(cfg)
|
||||
_, createErr = svc.CreateRepository(context.TODO(), &ecr.CreateRepositoryInput{RepositoryName: &repo})
|
||||
}
|
||||
}
|
||||
|
||||
var apiError smithy.APIError
|
||||
@@ -326,51 +428,159 @@ func createRepository(region, repo, registry string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func uploadLifeCyclePolicy(region, repo, lifecyclePolicy string) (err error) {
|
||||
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to load aws config")
|
||||
}
|
||||
func uploadLifeCyclePolicy(region, repo, lifecyclePolicy, assumeRole, externalId string) (err error) {
|
||||
if assumeRole != "" {
|
||||
input := &ecrv1.PutLifecyclePolicyInput{
|
||||
LifecyclePolicyText: aws.String(lifecyclePolicy),
|
||||
RepositoryName: aws.String(repo),
|
||||
}
|
||||
_, err = getAssumeRoleEcrSvc(region, assumeRole, externalId).PutLifecyclePolicy(input)
|
||||
} else {
|
||||
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to load aws config")
|
||||
}
|
||||
|
||||
svc := ecr.NewFromConfig(cfg)
|
||||
svc := ecr.NewFromConfig(cfg)
|
||||
|
||||
input := &ecr.PutLifecyclePolicyInput{
|
||||
LifecyclePolicyText: aws.String(lifecyclePolicy),
|
||||
RepositoryName: aws.String(repo),
|
||||
input := &ecr.PutLifecyclePolicyInput{
|
||||
LifecyclePolicyText: aws.String(lifecyclePolicy),
|
||||
RepositoryName: aws.String(repo),
|
||||
}
|
||||
_, err = svc.PutLifecyclePolicy(context.TODO(), input)
|
||||
}
|
||||
_, err = svc.PutLifecyclePolicy(context.TODO(), input)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func uploadRepositoryPolicy(region, repo, registry, repositoryPolicy string) (err error) {
|
||||
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to load aws config")
|
||||
}
|
||||
|
||||
if isRegistryPublic(registry) {
|
||||
svc := ecrpublic.NewFromConfig(cfg)
|
||||
|
||||
input := &ecrpublic.SetRepositoryPolicyInput{
|
||||
PolicyText: aws.String(repositoryPolicy),
|
||||
RepositoryName: aws.String(repo),
|
||||
func uploadRepositoryPolicy(region, repo, registry, repositoryPolicy, assumeRole, externalId string) (err error) {
|
||||
if assumeRole != "" {
|
||||
if isRegistryPublic(registry) {
|
||||
input := &ecrpublicv1.SetRepositoryPolicyInput{
|
||||
PolicyText: aws.String(repositoryPolicy),
|
||||
RepositoryName: aws.String(repo),
|
||||
}
|
||||
_, err = getAssumeRoleEcrPublicSvc(region, assumeRole, externalId).SetRepositoryPolicy(input)
|
||||
} else {
|
||||
input := &ecrv1.SetRepositoryPolicyInput{
|
||||
PolicyText: aws.String(repositoryPolicy),
|
||||
RepositoryName: aws.String(repo),
|
||||
}
|
||||
_, err = getAssumeRoleEcrSvc(region, assumeRole, externalId).SetRepositoryPolicy(input)
|
||||
}
|
||||
_, err = svc.SetRepositoryPolicy(context.TODO(), input)
|
||||
} else {
|
||||
|
||||
svc := ecr.NewFromConfig(cfg)
|
||||
|
||||
input := &ecr.SetRepositoryPolicyInput{
|
||||
PolicyText: aws.String(repositoryPolicy),
|
||||
RepositoryName: aws.String(repo),
|
||||
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to load aws config")
|
||||
}
|
||||
|
||||
if isRegistryPublic(registry) {
|
||||
svc := ecrpublic.NewFromConfig(cfg)
|
||||
input := &ecrpublic.SetRepositoryPolicyInput{
|
||||
PolicyText: aws.String(repositoryPolicy),
|
||||
RepositoryName: aws.String(repo),
|
||||
}
|
||||
_, err = svc.SetRepositoryPolicy(context.TODO(), input)
|
||||
} else {
|
||||
svc := ecr.NewFromConfig(cfg)
|
||||
input := &ecr.SetRepositoryPolicyInput{
|
||||
PolicyText: aws.String(repositoryPolicy),
|
||||
RepositoryName: aws.String(repo),
|
||||
}
|
||||
_, err = svc.SetRepositoryPolicy(context.TODO(), input)
|
||||
}
|
||||
_, err = svc.SetRepositoryPolicy(context.TODO(), input)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func getAssumeRoleCreds(region, roleArn, externalId, roleSessionName string) (string, string, string, error) {
|
||||
sess, err := session.NewSession(&awsv1.Config{Region: ®ion})
|
||||
if err != nil {
|
||||
return "", "", "", errors.Wrap(err, "failed to create aws session")
|
||||
}
|
||||
|
||||
svc := ecrv1.New(sess, &awsv1.Config{
|
||||
Credentials: stscreds.NewCredentials(sess, roleArn, func(p *stscreds.AssumeRoleProvider) {
|
||||
if externalId != "" {
|
||||
p.ExternalID = &externalId
|
||||
}
|
||||
}),
|
||||
})
|
||||
|
||||
username, password, registry, err := getAuthInfo(svc)
|
||||
if err != nil {
|
||||
return "", "", "", errors.Wrap(err, "failed to get ECR auth: no basic auth credentials")
|
||||
}
|
||||
return username, password, registry, nil
|
||||
}
|
||||
|
||||
func getAuthInfo(svc *ecrv1.ECR) (username, password, registry string, err error) {
|
||||
var result *ecrv1.GetAuthorizationTokenOutput
|
||||
var decoded []byte
|
||||
|
||||
result, err = svc.GetAuthorizationToken(&ecrv1.GetAuthorizationTokenInput{})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
auth := result.AuthorizationData[0]
|
||||
token := *auth.AuthorizationToken
|
||||
decoded, err = base64.StdEncoding.DecodeString(token)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
registry = strings.TrimPrefix(*auth.ProxyEndpoint, "https://")
|
||||
creds := strings.Split(string(decoded), ":")
|
||||
username = creds[0]
|
||||
password = creds[1]
|
||||
return
|
||||
}
|
||||
|
||||
func getAssumeRoleEcrSvc(region, assumeRole, externalId string) *ecrv1.ECR {
|
||||
sess, err := session.NewSession(&awsv1.Config{Region: ®ion})
|
||||
if err != nil {
|
||||
logrus.Fatal(err, "failed to create aws session")
|
||||
}
|
||||
|
||||
return ecrv1.New(sess, &awsv1.Config{
|
||||
Credentials: stscreds.NewCredentials(sess, assumeRole, func(p *stscreds.AssumeRoleProvider) {
|
||||
if externalId != "" {
|
||||
p.ExternalID = &externalId
|
||||
}
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
func getAssumeRoleEcrPublicSvc(region, assumeRole, externalId string) *ecrpublicv1.ECRPublic {
|
||||
sess, err := session.NewSession(&awsv1.Config{Region: ®ion})
|
||||
if err != nil {
|
||||
logrus.Fatal(err, "failed to create aws session")
|
||||
}
|
||||
|
||||
return ecrpublicv1.New(sess, &awsv1.Config{
|
||||
Credentials: stscreds.NewCredentials(sess, assumeRole, func(p *stscreds.AssumeRoleProvider) {
|
||||
if externalId != "" {
|
||||
p.ExternalID = &externalId
|
||||
}
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
func isRegistryPublic(registry string) bool {
|
||||
return strings.HasPrefix(registry, ecrPublicDomain)
|
||||
}
|
||||
|
||||
func isKanikoVersionBelowOneDotEight(v string) bool {
|
||||
currVer, err := version.NewVersion(v)
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
oneEightVer, err := version.NewVersion(oneDotEightVersion)
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return currVer.LessThan(oneEightVer)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -9,11 +10,15 @@ import (
|
||||
|
||||
func TestCreateDockerConfig(t *testing.T) {
|
||||
got, err := createDockerConfig(
|
||||
"",
|
||||
"docker-username",
|
||||
"docker-password",
|
||||
"access-key",
|
||||
"secret-key",
|
||||
"ecr-registry",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
false,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -29,3 +34,96 @@ func TestCreateDockerConfig(t *testing.T) {
|
||||
t.Errorf("not equal:\n want: %#v\n got: %#v", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateDockerConfigFromGivenRegistry(t *testing.T) {
|
||||
got, err := createDockerConfig(
|
||||
"docker-registry",
|
||||
"docker-username",
|
||||
"docker-password",
|
||||
"access-key",
|
||||
"secret-key",
|
||||
"ecr-registry",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
false,
|
||||
)
|
||||
if err != nil {
|
||||
t.Error("failed to create docker config")
|
||||
}
|
||||
|
||||
want := docker.NewConfig()
|
||||
want.SetAuth("docker-registry", "docker-username", "docker-password")
|
||||
want.SetCredHelper(docker.RegistryECRPublic, "ecr-login")
|
||||
want.SetCredHelper("ecr-registry", "ecr-login")
|
||||
if !reflect.DeepEqual(want, got) {
|
||||
t.Errorf("not equal:\n want: %#v\n got: %#v", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateDockerConfigKanikoOneDotEight(t *testing.T) {
|
||||
os.Setenv(kanikoVersionEnv, "1.8.1")
|
||||
defer os.Setenv(kanikoVersionEnv, "")
|
||||
got, err := createDockerConfig(
|
||||
"",
|
||||
"docker-username",
|
||||
"docker-password",
|
||||
"access-key",
|
||||
"secret-key",
|
||||
"ecr-registry",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
false,
|
||||
)
|
||||
if err != nil {
|
||||
t.Error("failed to create docker config")
|
||||
}
|
||||
|
||||
want := docker.NewConfig()
|
||||
want.SetAuth(docker.RegistryV1, "docker-username", "docker-password")
|
||||
|
||||
if !reflect.DeepEqual(want, got) {
|
||||
t.Errorf("not equal:\n want: %#v\n got: %#v", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionComparison(t *testing.T) {
|
||||
tests := []struct {
|
||||
title string
|
||||
version string
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
title: "Kaniko 1.6.0 version",
|
||||
version: "1.6.0",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
title: "Kaniko 1.8.0 version",
|
||||
version: "1.8.0",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
title: "Kaniko 1.8.1 version",
|
||||
version: "1.8.1",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
title: "Empty kaniko version",
|
||||
version: "",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
title: "Kaniko version 1.10.0",
|
||||
version: "1.10.0",
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
got := isKanikoVersionBelowOneDotEight(test.version)
|
||||
if got != test.expected {
|
||||
t.Fatalf("test name: %s, expected: %v, got: %v", test.title, test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/drone/drone-kaniko/internal"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
|
||||
kaniko "github.com/drone/drone-kaniko"
|
||||
"github.com/drone/drone-kaniko/pkg/artifact"
|
||||
)
|
||||
|
||||
const (
|
||||
// GAR JSON key file path
|
||||
garKeyPath string = "/kaniko/config.json"
|
||||
garEnvVariable string = "GOOGLE_APPLICATION_CREDENTIALS"
|
||||
|
||||
defaultDigestFile string = "/kaniko/digest-file"
|
||||
)
|
||||
|
||||
var (
|
||||
version = "unknown"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Load env-file if it exists first
|
||||
if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" {
|
||||
if err := godotenv.Load(env); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
app := cli.NewApp()
|
||||
app.Name = "kaniko gar plugin"
|
||||
app.Usage = "kaniko gar plugin"
|
||||
app.Action = run
|
||||
app.Version = version
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "dockerfile",
|
||||
Usage: "build dockerfile",
|
||||
Value: "Dockerfile",
|
||||
EnvVar: "PLUGIN_DOCKERFILE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "context",
|
||||
Usage: "build context",
|
||||
Value: ".",
|
||||
EnvVar: "PLUGIN_CONTEXT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "drone-commit-ref",
|
||||
Usage: "git commit ref passed by Drone",
|
||||
EnvVar: "DRONE_COMMIT_REF",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "drone-repo-branch",
|
||||
Usage: "git repository default branch passed by Drone",
|
||||
EnvVar: "DRONE_REPO_BRANCH",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "tags",
|
||||
Usage: "build tags",
|
||||
Value: &cli.StringSlice{"latest"},
|
||||
EnvVar: "PLUGIN_TAGS",
|
||||
FilePath: ".tags",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "expand-tag",
|
||||
Usage: "enable for semver tagging",
|
||||
EnvVar: "PLUGIN_EXPAND_TAG",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "auto-tag",
|
||||
Usage: "enable auto generation of build tags",
|
||||
EnvVar: "PLUGIN_AUTO_TAG",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "auto-tag-suffix",
|
||||
Usage: "the suffix of auto build tags",
|
||||
EnvVar: "PLUGIN_AUTO_TAG_SUFFIX",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "args",
|
||||
Usage: "build args",
|
||||
EnvVar: "PLUGIN_BUILD_ARGS",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "target",
|
||||
Usage: "build target",
|
||||
EnvVar: "PLUGIN_TARGET",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "repo",
|
||||
Usage: "gar repository",
|
||||
EnvVar: "PLUGIN_REPO",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "custom-labels",
|
||||
Usage: "additional k=v labels",
|
||||
EnvVar: "PLUGIN_CUSTOM_LABELS",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "registry",
|
||||
Usage: "gar registry",
|
||||
EnvVar: "PLUGIN_REGISTRY",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "registry-mirrors",
|
||||
Usage: "docker registry mirrors",
|
||||
EnvVar: "PLUGIN_REGISTRY_MIRRORS",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "json-key",
|
||||
Usage: "docker username",
|
||||
EnvVar: "PLUGIN_JSON_KEY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "snapshot-mode",
|
||||
Usage: "Specify one of full, redo or time as snapshot mode",
|
||||
EnvVar: "PLUGIN_SNAPSHOT_MODE",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "enable-cache",
|
||||
Usage: "Set this flag to opt into caching with kaniko",
|
||||
EnvVar: "PLUGIN_ENABLE_CACHE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "cache-repo",
|
||||
Usage: "Remote repository that will be used to store cached layers. Cache repo should be present in specified registry. enable-cache needs to be set to use this flag",
|
||||
EnvVar: "PLUGIN_CACHE_REPO",
|
||||
},
|
||||
cli.IntFlag{
|
||||
Name: "cache-ttl",
|
||||
Usage: "Cache timeout in hours. Defaults to two weeks.",
|
||||
EnvVar: "PLUGIN_CACHE_TTL",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "artifact-file",
|
||||
Usage: "Artifact file location that will be generated by the plugin. This file will include information of docker images that are uploaded by the plugin.",
|
||||
EnvVar: "PLUGIN_ARTIFACT_FILE",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "no-push",
|
||||
Usage: "Set this flag if you only want to build the image, without pushing to a registry",
|
||||
EnvVar: "PLUGIN_NO_PUSH",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "verbosity",
|
||||
Usage: "Set this flag as --verbosity=<panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
|
||||
EnvVar: "PLUGIN_VERBOSITY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "platform",
|
||||
Usage: "Allows to build with another default platform than the host, similarly to docker build --platform",
|
||||
EnvVar: "PLUGIN_PLATFORM",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "skip-unused-stages",
|
||||
Usage: "build only used stages",
|
||||
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "oidc-token",
|
||||
Usage: "OIDC token to use for authentication",
|
||||
EnvVar: "PLUGIN_OIDC_TOKEN_ID",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "project-number",
|
||||
Usage: "Google project number",
|
||||
EnvVar: "PLUGIN_PROJECT_NUMBER",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "pool-id",
|
||||
Usage: "Google pool id",
|
||||
EnvVar: "PLUGIN_POOL_ID",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "provider-id",
|
||||
Usage: "Google provider id",
|
||||
EnvVar: "PLUGIN_PROVIDER_ID",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "service-account-email",
|
||||
Usage: "Google service account email",
|
||||
EnvVar: "PLUGIN_SERVICE_ACCOUNT_EMAIL",
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func run(c *cli.Context) error {
|
||||
noPush := c.Bool("no-push")
|
||||
jsonKey := c.String("json-key")
|
||||
idToken := c.String("oidc-token")
|
||||
projectNumber := c.String("project-number")
|
||||
poolId := c.String("pool-id")
|
||||
providerId := c.String("provider-id")
|
||||
serviceAccountEmail := c.String("service-account-email")
|
||||
registry := c.String("registry")
|
||||
// JSON key may not be set in the following cases:
|
||||
// 1. Image does not need to be pushed to GAR.
|
||||
// 2. Workload identity is set on GKE in which pod will inherit the credentials via service account.
|
||||
if jsonKey != "" {
|
||||
if err := setupGARAuth(jsonKey); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if idToken != "" {
|
||||
accessToken := setupOIDCAuth(idToken, projectNumber, poolId, providerId, serviceAccountEmail)
|
||||
if accessToken != "" {
|
||||
if err := setupAccessTokenAuth(accessToken, registry); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin := kaniko.Plugin{
|
||||
Build: kaniko.Build{
|
||||
DroneCommitRef: c.String("drone-commit-ref"),
|
||||
DroneRepoBranch: c.String("drone-repo-branch"),
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
AutoTag: c.Bool("auto-tag"),
|
||||
AutoTagSuffix: c.String("auto-tag-suffix"),
|
||||
ExpandTag: c.Bool("expand-tag"),
|
||||
Args: c.StringSlice("args"),
|
||||
Target: c.String("target"),
|
||||
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
|
||||
Mirrors: c.StringSlice("registry-mirrors"),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
SnapshotMode: c.String("snapshot-mode"),
|
||||
EnableCache: c.Bool("enable-cache"),
|
||||
CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")),
|
||||
CacheTTL: c.Int("cache-ttl"),
|
||||
DigestFile: defaultDigestFile,
|
||||
NoPush: noPush,
|
||||
Verbosity: c.String("verbosity"),
|
||||
Platform: c.String("platform"),
|
||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||
},
|
||||
Artifact: kaniko.Artifact{
|
||||
Tags: c.StringSlice("tags"),
|
||||
Repo: c.String("repo"),
|
||||
Registry: registry,
|
||||
ArtifactFile: c.String("artifact-file"),
|
||||
RegistryType: artifact.GAR,
|
||||
},
|
||||
}
|
||||
return plugin.Exec()
|
||||
}
|
||||
|
||||
func setupGARAuth(jsonKey string) error {
|
||||
err := ioutil.WriteFile(garKeyPath, []byte(jsonKey), 0644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to write GAR JSON key")
|
||||
}
|
||||
|
||||
err = os.Setenv(garEnvVariable, garKeyPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to set %s environment variable", garEnvVariable))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setupAccessTokenAuth(accessToken, registryURL string) error {
|
||||
dockerConfig := map[string]interface{}{
|
||||
"auths": map[string]interface{}{
|
||||
registryURL: map[string]string{
|
||||
"auth": encodeAccessToken(accessToken),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
dockerConfigJson, err := json.Marshal(dockerConfig)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal docker config: %w", err)
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile("/root/.docker/config.json", dockerConfigJson, 0600); err != nil {
|
||||
return fmt.Errorf("failed to write docker config file: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeAccessToken(token string) string {
|
||||
auth := base64.StdEncoding.EncodeToString([]byte("_json_key:" + token))
|
||||
return auth
|
||||
}
|
||||
|
||||
func setupOIDCAuth(idToken, projectId, poolId, providerId, serviceAccountEmail string) string {
|
||||
federalToken, err := internal.GetFederalToken(idToken, projectId, poolId, providerId)
|
||||
if err != nil {
|
||||
logrus.Fatalf("Error (getFederalToken): %s", err)
|
||||
}
|
||||
accessToken, err := internal.GetGoogleCloudAccessToken(federalToken, serviceAccountEmail)
|
||||
if err != nil {
|
||||
logrus.Fatalf("Error (getGoogleCloudAccessToken): %s", err)
|
||||
}
|
||||
return accessToken
|
||||
}
|
||||
+67
-21
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/urfave/cli"
|
||||
|
||||
kaniko "github.com/drone/drone-kaniko"
|
||||
"github.com/drone/drone-kaniko/cmd/artifact"
|
||||
"github.com/drone/drone-kaniko/pkg/artifact"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -52,6 +52,16 @@ func main() {
|
||||
Value: ".",
|
||||
EnvVar: "PLUGIN_CONTEXT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "drone-commit-ref",
|
||||
Usage: "git commit ref passed by Drone",
|
||||
EnvVar: "DRONE_COMMIT_REF",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "drone-repo-branch",
|
||||
Usage: "git repository default branch passed by Drone",
|
||||
EnvVar: "DRONE_REPO_BRANCH",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "tags",
|
||||
Usage: "build tags",
|
||||
@@ -59,6 +69,21 @@ func main() {
|
||||
EnvVar: "PLUGIN_TAGS",
|
||||
FilePath: ".tags",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "expand-tag",
|
||||
Usage: "enable for semver tagging",
|
||||
EnvVar: "PLUGIN_EXPAND_TAG",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "auto-tag",
|
||||
Usage: "enable auto generation of build tags",
|
||||
EnvVar: "PLUGIN_AUTO_TAG",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "auto-tag-suffix",
|
||||
Usage: "the suffix of auto build tags",
|
||||
EnvVar: "PLUGIN_AUTO_TAG_SUFFIX",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "args",
|
||||
Usage: "build args",
|
||||
@@ -85,6 +110,11 @@ func main() {
|
||||
Value: "gcr.io",
|
||||
EnvVar: "PLUGIN_REGISTRY",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "registry-mirrors",
|
||||
Usage: "docker registry mirrors",
|
||||
EnvVar: "PLUGIN_REGISTRY_MIRRORS",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "json-key",
|
||||
Usage: "docker username",
|
||||
@@ -125,6 +155,16 @@ func main() {
|
||||
Usage: "Set this flag as --verbosity=<panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
|
||||
EnvVar: "PLUGIN_VERBOSITY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "platform",
|
||||
Usage: "Allows to build with another default platform than the host, similarly to docker build --platform",
|
||||
EnvVar: "PLUGIN_PLATFORM",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "skip-unused-stages",
|
||||
Usage: "build only used stages",
|
||||
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
@@ -136,8 +176,10 @@ func run(c *cli.Context) error {
|
||||
noPush := c.Bool("no-push")
|
||||
jsonKey := c.String("json-key")
|
||||
|
||||
// only setup auth when pushing or credentials are defined
|
||||
if !noPush || jsonKey != "" {
|
||||
// JSON key may not be set in the following cases:
|
||||
// 1. Image does not need to be pushed to GCR.
|
||||
// 2. Workload identity is set on GKE in which pod will inherit the credentials via service account.
|
||||
if jsonKey != "" {
|
||||
if err := setupGCRAuth(jsonKey); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -145,20 +187,28 @@ func run(c *cli.Context) error {
|
||||
|
||||
plugin := kaniko.Plugin{
|
||||
Build: kaniko.Build{
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
Args: c.StringSlice("args"),
|
||||
Target: c.String("target"),
|
||||
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
SnapshotMode: c.String("snapshot-mode"),
|
||||
EnableCache: c.Bool("enable-cache"),
|
||||
CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")),
|
||||
CacheTTL: c.Int("cache-ttl"),
|
||||
DigestFile: defaultDigestFile,
|
||||
NoPush: noPush,
|
||||
Verbosity: c.String("verbosity"),
|
||||
DroneCommitRef: c.String("drone-commit-ref"),
|
||||
DroneRepoBranch: c.String("drone-repo-branch"),
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
AutoTag: c.Bool("auto-tag"),
|
||||
AutoTagSuffix: c.String("auto-tag-suffix"),
|
||||
ExpandTag: c.Bool("expand-tag"),
|
||||
Args: c.StringSlice("args"),
|
||||
Target: c.String("target"),
|
||||
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
|
||||
Mirrors: c.StringSlice("registry-mirrors"),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
SnapshotMode: c.String("snapshot-mode"),
|
||||
EnableCache: c.Bool("enable-cache"),
|
||||
CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")),
|
||||
CacheTTL: c.Int("cache-ttl"),
|
||||
DigestFile: defaultDigestFile,
|
||||
NoPush: noPush,
|
||||
Verbosity: c.String("verbosity"),
|
||||
Platform: c.String("platform"),
|
||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||
},
|
||||
Artifact: kaniko.Artifact{
|
||||
Tags: c.StringSlice("tags"),
|
||||
@@ -172,10 +222,6 @@ func run(c *cli.Context) error {
|
||||
}
|
||||
|
||||
func setupGCRAuth(jsonKey string) error {
|
||||
if jsonKey == "" {
|
||||
return fmt.Errorf("GCR JSON key must be specified")
|
||||
}
|
||||
|
||||
err := ioutil.WriteFile(gcrKeyPath, []byte(jsonKey), 0644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to write GCR JSON key")
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/amd64/kaniko-acr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-acr"]
|
||||
@@ -0,0 +1,8 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV HOME /root
|
||||
ENV USER root
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/arm64/kaniko-acr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-acr"]
|
||||
@@ -0,0 +1,18 @@
|
||||
image: plugins/kaniko-acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: plugins/kaniko-acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/kaniko-acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
@@ -1,4 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.5.2
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/amd64/kaniko-docker /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/amd64/kaniko-docker /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
||||
@@ -1,7 +1,8 @@
|
||||
FROM gcr.io/kaniko-project/executor:arm64-v1.5.2
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV HOME /root
|
||||
ENV USER root
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/arm64/kaniko-docker /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/arm64/kaniko-docker /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
||||
@@ -0,0 +1,18 @@
|
||||
image: plugins/kaniko:{{#if build.tag}}{{trimPrefix "v" build.tag}}-kaniko1.9.1{{else}}latest-kaniko1.9.1{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: plugins/kaniko:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-kaniko1.9.1
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/kaniko:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-kaniko1.9.1
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
@@ -11,3 +11,8 @@ manifests:
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/kaniko:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.5.2
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/amd64/kaniko-ecr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/amd64/kaniko-ecr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
||||
@@ -1,7 +1,8 @@
|
||||
FROM gcr.io/kaniko-project/executor:arm64-v1.5.2
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV HOME /root
|
||||
ENV USER root
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
|
||||
ADD release/linux/arm64/kaniko-ecr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/arm64/kaniko-ecr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
||||
@@ -0,0 +1,18 @@
|
||||
image: plugins/kaniko-ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-kaniko1.9.1{{else}}latest-kaniko1.9.1{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: plugins/kaniko-ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-kaniko1.9.1
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/kaniko-ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-kaniko1.9.1
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
@@ -10,4 +10,9 @@ manifests:
|
||||
image: plugins/kaniko-ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/kaniko-ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/amd64/kaniko-gar /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-gar"]
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/amd64/kaniko-gar /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-gar"]
|
||||
@@ -0,0 +1,8 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV HOME /root
|
||||
ENV USER root
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
|
||||
ADD release/linux/arm64/kaniko-gar /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-gar"]
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/arm64/kaniko-gar /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-gar"]
|
||||
@@ -0,0 +1,18 @@
|
||||
image: plugins/kaniko-gar:{{#if build.tag}}{{trimPrefix "v" build.tag}}-kaniko1.9.1{{else}}latest-kaniko1.9.1{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: plugins/kaniko-gar:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-kaniko1.9.1
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/kaniko-gar:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-kaniko1.9.1
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
@@ -0,0 +1,18 @@
|
||||
image: plugins/kaniko-gar:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: plugins/kaniko-gar:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/kaniko-gar:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
@@ -1,4 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.5.2
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/amd64/kaniko-gcr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/amd64/kaniko-gcr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
||||
@@ -1,7 +1,8 @@
|
||||
FROM gcr.io/kaniko-project/executor:arm64-v1.5.2
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV HOME /root
|
||||
ENV USER root
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
|
||||
ADD release/linux/arm64/kaniko-gcr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||
|
||||
ENV KANIKO_VERSION=1.9.1
|
||||
ADD release/linux/arm64/kaniko-gcr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
||||
@@ -0,0 +1,18 @@
|
||||
image: plugins/kaniko-gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-kaniko1.9.1{{else}}latest-kaniko1.9.1{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: plugins/kaniko-gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-kaniko1.9.1
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/kaniko-gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-kaniko1.9.1
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
@@ -11,3 +11,8 @@ manifests:
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/kaniko-gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
|
||||
@@ -1,15 +1,60 @@
|
||||
module github.com/drone/drone-kaniko
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go-v2 v1.8.1
|
||||
github.com/aws/aws-sdk-go-v2/config v1.6.1
|
||||
github.com/aws/aws-sdk-go-v2/service/ecr v1.4.3
|
||||
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.4.3
|
||||
github.com/aws/smithy-go v1.7.0
|
||||
github.com/joho/godotenv v1.3.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0
|
||||
github.com/aws/aws-sdk-go v1.44.52
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.7
|
||||
github.com/aws/aws-sdk-go-v2/config v1.15.14
|
||||
github.com/aws/aws-sdk-go-v2/service/ecr v1.17.8
|
||||
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.13.8
|
||||
github.com/aws/smithy-go v1.12.0
|
||||
github.com/coreos/go-semver v0.3.0
|
||||
github.com/google/go-cmp v0.6.0
|
||||
github.com/hashicorp/go-version v1.6.0
|
||||
github.com/joho/godotenv v1.4.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/sirupsen/logrus v1.3.0
|
||||
github.com/urfave/cli v1.22.2
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/urfave/cli v1.22.9
|
||||
golang.org/x/mod v0.8.0
|
||||
)
|
||||
|
||||
go 1.13
|
||||
require (
|
||||
cloud.google.com/go/compute v1.23.1 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.9 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.8 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.15 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.8 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.12 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.9 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/s2a-go v0.1.7 // indirect
|
||||
github.com/google/uuid v1.4.0 // indirect
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/kylelemons/godebug v1.1.0 // indirect
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
golang.org/x/crypto v0.14.0 // indirect
|
||||
golang.org/x/net v0.17.0 // indirect
|
||||
golang.org/x/oauth2 v0.13.0 // indirect
|
||||
golang.org/x/sys v0.13.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
google.golang.org/api v0.151.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
|
||||
google.golang.org/grpc v1.59.0 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
)
|
||||
|
||||
go 1.21
|
||||
|
||||
@@ -1,66 +1,244 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go/compute v1.23.1 h1:V97tBoDaZHb6leicZ1G6DLK2BAaZLJ/7+9BB/En3hR0=
|
||||
cloud.google.com/go/compute v1.23.1/go.mod h1:CqB3xpmPKKt3OJpW2ndFIXnA9A4xAy/F3Xp1ixncW78=
|
||||
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
|
||||
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1 h1:tz19qLF65vuu2ibfTqGVJxG/zZAI27NEIIbvAOQwYbw=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.3 h1:TsFCaaF5tR4XN8b4zLVl/J4qMb0nf80Q4CXcpXDNJDY=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.3/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/aws/aws-sdk-go-v2 v1.8.1 h1:GcFgQl7MsBygmeeqXyV1ivrTEmsVz/rdFJaTcltG9ag=
|
||||
github.com/aws/aws-sdk-go-v2 v1.8.1/go.mod h1:xEFuWz+3TYdlPRuo+CqATbeDWIWyaT5uAPwPaWtgse0=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.6.1 h1:qrZINaORyr78syO1zfD4l7r4tZjy0Z1l0sy4jiysyOM=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.6.1/go.mod h1:t/y3UPu0XEDy0cEw6mvygaBQaPzWiYAxfP2SzgtvclA=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.3.3 h1:A13QPatmUl41SqUfnuT3V0E3XiNGL6qNTOINbE8cZL4=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.3.3/go.mod h1:oVieKMT3m9BSfqhOfuQ+E0j/yN84ZAJ7Qv8Sfume/ak=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.4.1 h1:rc+fRGvlKbeSd9IFhFS1KWBs0XjTkq0CfK5xqyLgIp0=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.4.1/go.mod h1:+GTydg3uHmVlQdkRoetz6VHKbOMEYof70m19IpMLifc=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.2.1 h1:IkqRRUZTKaS16P2vpX+FNc2jq3JWa3c478gykQp4ow4=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.2.1/go.mod h1:Pv3WenDjI0v2Jl7UaMFIIbPOBbhn33RmmAmGgkXDoqY=
|
||||
github.com/aws/aws-sdk-go-v2/service/ecr v1.4.3 h1:d356GPVp5MzJ4n/xCBc26wLmRti0DoWO4WzNfxSesrY=
|
||||
github.com/aws/aws-sdk-go-v2/service/ecr v1.4.3/go.mod h1:HlFOVFXSvCfI2oUmd/Vv1IZKJhEVFQru38BBupEYWxs=
|
||||
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.4.3 h1:EU9GrpMtGLCklSMLjuU6AZGG5wu6aiowxIgbfWwxrgs=
|
||||
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.4.3/go.mod h1:AAI7iB1GPqxjyKHbzLpBJdmH9/dPr34pxeLFdkKsONA=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.2.3 h1:VxFCgxsqWe7OThOwJ5IpFX3xrObtuIH9Hg/NW7oot1Y=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.2.3/go.mod h1:7gcsONBmFoCcKrAqrm95trrMd2+C/ReYKP7Vfu8yHHA=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.3.3 h1:K2gCnGvAASpz+jqP9iyr+F/KNjmTYf8aWOtTQzhmZ5w=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.3.3/go.mod h1:Jgw5O+SK7MZ2Yi9Yvzb4PggAPYaFSliiQuWR0hNjexk=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.6.2 h1:l504GWCoQi1Pk68vSUFGLmDIEMzRfVGNgLakDK+Uj58=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.6.2/go.mod h1:RBhoMJB8yFToaCnbe0jNq5Dcdy0jp6LhHqg55rjClkM=
|
||||
github.com/aws/smithy-go v1.7.0 h1:+cLHMRrDZvQ4wk+KuQ9yH6eEg6KZEJ9RI2IkDqnygCg=
|
||||
github.com/aws/smithy-go v1.7.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||
github.com/aws/aws-sdk-go v1.44.52 h1:kHLbYJj59C7VrsLM4gm7pxsvaNIvhXCCIDYEFFoQ+VE=
|
||||
github.com/aws/aws-sdk-go v1.44.52/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.7 h1:zfBwXus3u14OszRxGcqCDS4MfMCv10e8SMJ2r8Xm0Ns=
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.7/go.mod h1:6CpKuLXg2w7If3ABZCl/qZ6rEgwtjZTn4eAf4RcEyuw=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.15.14 h1:+BqpqlydTq4c2et9Daury7gE+o67P4lbk7eybiCBNc4=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.15.14/go.mod h1:CQBv+VVv8rR5z2xE+Chdh5m+rFfsqeY4k0veEZeq6QM=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.9 h1:DloAJr0/jbvm0iVRFDFh8GlWxrOd9XKyX82U+dfVeZs=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.9/go.mod h1:2Vavxl1qqQXJ8MUcQZTsIEW8cwenFCWYXtLRPba3L/o=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.8 h1:VfBdn2AxwMbFyJN/lF/xuT3SakomJ86PZu3rCxb5K0s=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.8/go.mod h1:oL1Q3KuCq1D4NykQnIvtRiBGLUXhcpY5pl6QZB2XEPU=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14 h1:2C0pYHcUBmdzPj+EKNC4qj97oK6yjrUhc1KoSodglvk=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14/go.mod h1:kdjrMwHwrC3+FsKhNcCMJ7tUVj/8uSD5CZXeQ4wV6fM=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8 h1:2J+jdlBJWEmTyAwC82Ym68xCykIvnSnIN18b8xHGlcc=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8/go.mod h1:ZIV8GYoC6WLBW5KGs+o4rsc65/ozd+eQ0L31XF5VDwk=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.15 h1:QquxR7NH3ULBsKC+NoTpilzbKKS+5AELfNREInbhvas=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.15/go.mod h1:Tkrthp/0sNBShQQsamR7j/zY4p19tVTAs+nnqhH6R3c=
|
||||
github.com/aws/aws-sdk-go-v2/service/ecr v1.17.8 h1:wgZo/yeY0f+2RWy2q1rTtZSPMmq37Zy3pY4QypHeurg=
|
||||
github.com/aws/aws-sdk-go-v2/service/ecr v1.17.8/go.mod h1:ItZADKTnGxqcqXABHyNpoBljQ8ORt4h+D39RToM/3Ds=
|
||||
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.13.8 h1:uByYzUJNBrI4LN0H+HMA7yrDWQxe2f9cF7ZkiXltXRo=
|
||||
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.13.8/go.mod h1:nPSH6Ebmb3OkKl7+CLSjx+SMBaoFKbOe9mZhTAd352k=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.8 h1:oKnAXxSF2FUvfgw8uzU/v9OTYorJJZ8eBmWhr9TWVVQ=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.8/go.mod h1:rDVhIMAX9N2r8nWxDUlbubvvaFMnfsm+3jAV7q+rpM4=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.12 h1:760bUnTX/+d693FT6T6Oa7PZHfEQT9XMFZeM5IQIB0A=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.12/go.mod h1:MO4qguFjs3wPGcCSpQ7kOFTwRvb+eu+fn+1vKleGHUk=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.9 h1:yOfILxyjmtr2ubRkRJldlHDFBhf5vw4CzhbwWIBmimQ=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.9/go.mod h1:O1IvkYxr+39hRf960Us6j0x1P8pDqhTX+oXM5kQNl/Y=
|
||||
github.com/aws/smithy-go v1.12.0 h1:gXpeZel/jPoWQ7OEmLIgCUnhkFftqNfwWUwAHSlp1v0=
|
||||
github.com/aws/smithy-go v1.12.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c=
|
||||
github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU=
|
||||
github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o=
|
||||
github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
|
||||
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs=
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=
|
||||
github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas=
|
||||
github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU=
|
||||
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
|
||||
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
|
||||
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
||||
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME=
|
||||
github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/stretchr/objx v0.1.0/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/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
|
||||
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/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
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/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/urfave/cli v1.22.9 h1:cv3/KhXGBGjEXLC4bH0sLuJ9BewaAbpk5oyMOveu4pw=
|
||||
github.com/urfave/cli v1.22.9/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
||||
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
|
||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
|
||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220725212005-46097bf591d3 h1:2yWTtPWWRcISTw3/o+s/Y4UOMnQL71DWyToOANFusCg=
|
||||
golang.org/x/net v0.0.0-20220725212005-46097bf591d3/go.mod h1:AaygXjzTFtRAg2ttMY5RMuhpJ3cNnI0XpyFJD1iQRSM=
|
||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY=
|
||||
golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
google.golang.org/api v0.151.0 h1:FhfXLO/NFdJIzQtCqjpysWwqKk8AzGWBUhMIx67cVDU=
|
||||
google.golang.org/api v0.151.0/go.mod h1:ccy+MJ6nrYFgE3WgRx/AMXOxOmU8Q4hSa+jjibzhxcg=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b h1:+YaDE2r2OG8t/z5qmsh7Y+XXwCbvadxxZ0YY6mTdrVA=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 h1:AB/lmRny7e2pLhFEYIbl5qkDAUt2h0ZRO4wGPhZf+ik=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405/go.mod h1:67X1fPuzjcrkymZzZV1vvkFeTn2Rvc6lYF9MYFGCcwE=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
|
||||
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
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=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
"google.golang.org/api/iamcredentials/v1"
|
||||
"google.golang.org/api/option"
|
||||
"google.golang.org/api/sts/v1"
|
||||
)
|
||||
|
||||
type staticTokenSource struct {
|
||||
token *oauth2.Token
|
||||
}
|
||||
|
||||
func (s *staticTokenSource) Token() (*oauth2.Token, error) {
|
||||
return s.token, nil
|
||||
}
|
||||
|
||||
func GetFederalToken(idToken, projectNumber, poolId, providerId string) (string, error) {
|
||||
ctx := context.Background()
|
||||
stsService, err := sts.NewService(ctx, option.WithoutAuthentication())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
audience := fmt.Sprintf("//iam.googleapis.com/projects/%s/locations/global/workloadIdentityPools/%s/providers/%s", projectNumber, poolId, providerId)
|
||||
tokenRequest := &sts.GoogleIdentityStsV1ExchangeTokenRequest{
|
||||
GrantType: "urn:ietf:params:oauth:grant-type:token-exchange",
|
||||
SubjectToken: idToken,
|
||||
Audience: audience,
|
||||
Scope: "https://www.googleapis.com/auth/cloud-platform",
|
||||
RequestedTokenType: "urn:ietf:params:oauth:token-type:access_token",
|
||||
SubjectTokenType: "urn:ietf:params:oauth:token-type:id_token",
|
||||
}
|
||||
tokenResponse, err := stsService.V1.Token(tokenRequest).Do()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return tokenResponse.AccessToken, nil
|
||||
}
|
||||
|
||||
func GetGoogleCloudAccessToken(federatedToken string, serviceAccountEmail string) (string, error) {
|
||||
ctx := context.Background()
|
||||
tokenSource := &staticTokenSource{
|
||||
token: &oauth2.Token{AccessToken: federatedToken},
|
||||
}
|
||||
service, err := iamcredentials.NewService(ctx, option.WithTokenSource(tokenSource))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
name := "projects/-/serviceAccounts/" + serviceAccountEmail
|
||||
rb := &iamcredentials.GenerateAccessTokenRequest{
|
||||
Scope: []string{"https://www.googleapis.com/auth/cloud-platform"},
|
||||
}
|
||||
|
||||
resp, err := service.Projects.ServiceAccounts.GenerateAccessToken(name, rb).Do()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp.AccessToken, nil
|
||||
}
|
||||
@@ -7,28 +7,41 @@ import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/drone/drone-kaniko/cmd/artifact"
|
||||
"github.com/drone/drone-kaniko/pkg/artifact"
|
||||
"github.com/drone/drone-kaniko/pkg/output"
|
||||
"github.com/drone/drone-kaniko/pkg/tagger"
|
||||
"golang.org/x/mod/semver"
|
||||
)
|
||||
|
||||
type (
|
||||
// Build defines Docker build parameters.
|
||||
Build struct {
|
||||
Dockerfile string // Docker build Dockerfile
|
||||
Context string // Docker build context
|
||||
Tags []string // Docker build tags
|
||||
Args []string // Docker build args
|
||||
Target string // Docker build target
|
||||
Repo string // Docker build repository
|
||||
Labels []string // Label map
|
||||
SkipTlsVerify bool // Docker skip tls certificate verify for registry
|
||||
SnapshotMode string // Kaniko snapshot mode
|
||||
EnableCache bool // Whether to enable kaniko cache
|
||||
CacheRepo string // Remote repository that will be used to store cached layers
|
||||
CacheTTL int // Cache timeout in hours
|
||||
DigestFile string // Digest file location
|
||||
NoPush bool // Set this flag if you only want to build the image, without pushing to a registry
|
||||
Verbosity string // Log level
|
||||
DroneCommitRef string // Drone git commit reference
|
||||
DroneRepoBranch string // Drone repo branch
|
||||
Dockerfile string // Docker build Dockerfile
|
||||
Context string // Docker build context
|
||||
Tags []string // Docker build tags
|
||||
AutoTag bool // Set this to auto detect tags from git commits and semver-tagged labels
|
||||
AutoTagSuffix string // Suffix to append to the auto detect tags
|
||||
ExpandTag bool // Set this to expand the `Tags` into semver-tagged labels
|
||||
Args []string // Docker build args
|
||||
Target string // Docker build target
|
||||
Repo string // Docker build repository
|
||||
Mirrors []string // Docker repository mirrors
|
||||
Labels []string // Label map
|
||||
SkipTlsVerify bool // Docker skip tls certificate verify for registry
|
||||
SnapshotMode string // Kaniko snapshot mode
|
||||
EnableCache bool // Whether to enable kaniko cache
|
||||
CacheRepo string // Remote repository that will be used to store cached layers
|
||||
CacheTTL int // Cache timeout in hours
|
||||
DigestFile string // Digest file location
|
||||
NoPush bool // Set this flag if you only want to build the image, without pushing to a registry
|
||||
Verbosity string // Log level
|
||||
Platform string // Allows to build with another default platform than the host, similarly to docker build --platform
|
||||
SkipUnusedStages bool // Build only used stages
|
||||
TarPath string // Set this flag to save the image as a tarball at path
|
||||
}
|
||||
|
||||
// Artifact defines content of artifact file
|
||||
Artifact struct {
|
||||
Tags []string // Docker artifact tags
|
||||
@@ -36,15 +49,87 @@ type (
|
||||
Registry string // Docker artifact registry
|
||||
RegistryType artifact.RegistryTypeEnum // Rocker artifact registry type
|
||||
ArtifactFile string // Artifact file location
|
||||
AccessToken string // Access token for registry
|
||||
}
|
||||
|
||||
// Output defines content of output file
|
||||
Output struct {
|
||||
OutputFile string // File where plugin output are saved
|
||||
}
|
||||
|
||||
// Plugin defines the Docker plugin parameters.
|
||||
Plugin struct {
|
||||
Build Build // Docker build configuration
|
||||
Artifact Artifact // Artifact file content
|
||||
Output Output // Output file content
|
||||
}
|
||||
)
|
||||
|
||||
// labelsForTag returns the labels to use for the given tag, subject to the value of ExpandTag.
|
||||
//
|
||||
// Build information (e.g. +linux_amd64) is carried through to all labels.
|
||||
// Pre-release information (e.g. -rc1) suppresses major and major+minor auto-labels.
|
||||
func (b Build) labelsForTag(tag string) (labels []string) {
|
||||
// We strip "v" off of the beginning of semantic versions, as they are not used in docker tags
|
||||
const VersionPrefix = "v"
|
||||
|
||||
// Semantic Versions don't allow underscores, so replace them with dashes.
|
||||
// https://semver.org/
|
||||
semverTag := strings.ReplaceAll(tag, "_", "-")
|
||||
|
||||
// Allow tags of the form "1.2.3" as well as "v1.2.3" to avoid confusion.
|
||||
if withV := VersionPrefix + semverTag; !semver.IsValid(semverTag) && semver.IsValid(withV) {
|
||||
semverTag = withV
|
||||
}
|
||||
|
||||
// Pass through tags if expand-tag is not set, or if the tag is not a semantic version
|
||||
if !b.ExpandTag || !semver.IsValid(semverTag) {
|
||||
return []string{tag}
|
||||
}
|
||||
tag = semverTag
|
||||
|
||||
// If the version is pre-release, only the full release should be tagged, not the major/minor versions.
|
||||
if semver.Prerelease(tag) != "" {
|
||||
return []string{
|
||||
strings.TrimPrefix(tag, VersionPrefix),
|
||||
}
|
||||
}
|
||||
|
||||
// tagFor carries any build information from the semantic version through to major and minor tags.
|
||||
labelFor := func(base string) string {
|
||||
return strings.TrimPrefix(base, VersionPrefix) + semver.Build(tag)
|
||||
}
|
||||
return []string{
|
||||
labelFor(semver.Major(tag)),
|
||||
labelFor(semver.MajorMinor(tag)),
|
||||
labelFor(semver.Canonical(tag)),
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the auto detected tags. See the AutoTag section of
|
||||
// https://plugins.drone.io/drone-plugins/drone-docker/ for more info.
|
||||
func (b Build) AutoTags() (tags []string, err error) {
|
||||
if len(b.Tags) > 1 || len(b.Tags) == 1 && b.Tags[0] != "latest" {
|
||||
err = fmt.Errorf("The auto-tag flag does not work with user provided tags %s", b.Tags)
|
||||
return
|
||||
}
|
||||
// We have tried the best to prevent enabling auto-tag and passing in
|
||||
// user specified at the same time. Starts to auto detect tags.
|
||||
// Note: passing in a "latest" tag with auto-tag enabled won't trigger the
|
||||
// early returns above, because we cannot tell if the tag is provided by
|
||||
// the default value or by the users.
|
||||
commitRef := b.DroneCommitRef
|
||||
if !tagger.UseAutoTag(commitRef, b.DroneRepoBranch) {
|
||||
err = fmt.Errorf("Could not auto detect the tag. Skipping automated docker build for commit %s", commitRef)
|
||||
return
|
||||
}
|
||||
tags, err = tagger.AutoTagsSuffix(commitRef, b.AutoTagSuffix)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Invalid semantic version when auto detecting the tag. Skipping automated docker build for %s.", commitRef)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Exec executes the plugin step
|
||||
func (p Plugin) Exec() error {
|
||||
if !p.Build.NoPush && p.Build.Repo == "" {
|
||||
@@ -55,17 +140,32 @@ func (p Plugin) Exec() error {
|
||||
return fmt.Errorf("dockerfile does not exist at path: %s", p.Build.Dockerfile)
|
||||
}
|
||||
|
||||
var tags = p.Build.Tags
|
||||
if p.Build.AutoTag && p.Build.ExpandTag {
|
||||
return fmt.Errorf("The auto-tag flag conflicts with the expand-tag flag")
|
||||
}
|
||||
if p.Build.AutoTag {
|
||||
var err error
|
||||
tags, err = p.Build.AutoTags()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
cmdArgs := []string{
|
||||
fmt.Sprintf("--dockerfile=%s", p.Build.Dockerfile),
|
||||
fmt.Sprintf("--context=dir://%s", p.Build.Context),
|
||||
}
|
||||
|
||||
// Set the destination repository
|
||||
if !p.Build.NoPush {
|
||||
for _, tag := range p.Build.Tags {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--destination=%s:%s", p.Build.Repo, tag))
|
||||
// Set the destination repository only when we push or save to tarball
|
||||
if !p.Build.NoPush || p.Build.TarPath != "" {
|
||||
for _, tag := range tags {
|
||||
for _, label := range p.Build.labelsForTag(tag) {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--destination=%s:%s", p.Build.Repo, label))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the build arguments
|
||||
for _, arg := range p.Build.Args {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--build-arg=%s", arg))
|
||||
@@ -74,7 +174,10 @@ func (p Plugin) Exec() error {
|
||||
for _, label := range p.Build.Labels {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--label=%s", label))
|
||||
}
|
||||
|
||||
// Set repository mirrors
|
||||
for _, mirror := range p.Build.Mirrors {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--registry-mirror=%s", mirror))
|
||||
}
|
||||
if p.Build.Target != "" {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--target=%s", p.Build.Target))
|
||||
}
|
||||
@@ -96,7 +199,7 @@ func (p Plugin) Exec() error {
|
||||
}
|
||||
|
||||
if p.Build.CacheTTL != 0 {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--cache-ttl=%d", p.Build.CacheTTL))
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--cache-ttl=%dh", p.Build.CacheTTL))
|
||||
}
|
||||
|
||||
if p.Build.DigestFile != "" {
|
||||
@@ -111,6 +214,18 @@ func (p Plugin) Exec() error {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--verbosity=%s", p.Build.Verbosity))
|
||||
}
|
||||
|
||||
if p.Build.Platform != "" {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--customPlatform=%s", p.Build.Platform))
|
||||
}
|
||||
|
||||
if p.Build.SkipUnusedStages {
|
||||
cmdArgs = append(cmdArgs, "--skip-unused-stages")
|
||||
}
|
||||
|
||||
if p.Build.TarPath != "" {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--tar-path=%s", p.Build.TarPath))
|
||||
}
|
||||
|
||||
cmd := exec.Command("/kaniko/executor", cmdArgs...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
@@ -122,19 +237,29 @@ func (p Plugin) Exec() error {
|
||||
}
|
||||
|
||||
if p.Build.DigestFile != "" && p.Artifact.ArtifactFile != "" {
|
||||
content, err := ioutil.ReadFile(p.Build.DigestFile)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to read digest file contents at path: %s with error: %s\n", p.Build.DigestFile, err)
|
||||
}
|
||||
err = artifact.WritePluginArtifactFile(p.Artifact.RegistryType, p.Artifact.ArtifactFile, p.Artifact.Registry, p.Artifact.Repo, string(content), p.Artifact.Tags)
|
||||
err = artifact.WritePluginArtifactFile(p.Artifact.RegistryType, p.Artifact.ArtifactFile, p.Artifact.Registry, p.Artifact.Repo, getDigest(p.Build.DigestFile), p.Artifact.Tags)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to write plugin artifact file at path: %s with error: %s\n", p.Artifact.ArtifactFile, err)
|
||||
}
|
||||
}
|
||||
|
||||
if p.Output.OutputFile != "" {
|
||||
if err = output.WritePluginOutputFile(p.Output.OutputFile, getDigest(p.Build.DigestFile)); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to write plugin output file at path: %s with error: %s\n", p.Output.OutputFile, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getDigest(digestFile string) string {
|
||||
content, err := ioutil.ReadFile(digestFile)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to read digest file contents at path: %s with error: %s\n", digestFile, err)
|
||||
}
|
||||
return string(content)
|
||||
}
|
||||
|
||||
// trace writes each command to stdout with the command wrapped in an xml
|
||||
// tag so that it can be extracted and displayed in the logs.
|
||||
func trace(cmd *exec.Cmd) {
|
||||
|
||||
+149
@@ -1 +1,150 @@
|
||||
package kaniko
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func TestBuild_labelsForTag(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
tag string
|
||||
expandTags []string
|
||||
}{
|
||||
{
|
||||
name: "semver",
|
||||
tag: "v1.2.3",
|
||||
expandTags: []string{"1", "1.2", "1.2.3"},
|
||||
},
|
||||
{
|
||||
name: "no_patch",
|
||||
tag: "v1.2",
|
||||
expandTags: []string{"1", "1.2", "1.2.0"},
|
||||
},
|
||||
{
|
||||
name: "only_major",
|
||||
tag: "v1",
|
||||
expandTags: []string{"1", "1.0", "1.0.0"},
|
||||
},
|
||||
{
|
||||
name: "full_with_build",
|
||||
tag: "v1.2.3+build-info",
|
||||
expandTags: []string{"1+build-info", "1.2+build-info", "1.2.3+build-info"},
|
||||
},
|
||||
{
|
||||
name: "build_with_underscores",
|
||||
tag: "v1.2.3+linux_amd64",
|
||||
expandTags: []string{"1+linux-amd64", "1.2+linux-amd64", "1.2.3+linux-amd64"},
|
||||
},
|
||||
{
|
||||
name: "prerelease",
|
||||
tag: "v1.2.3-rc1",
|
||||
expandTags: []string{"1.2.3-rc1"},
|
||||
},
|
||||
{
|
||||
name: "prerelease_with_build",
|
||||
tag: "v1.2.3-rc1+bld",
|
||||
expandTags: []string{"1.2.3-rc1+bld"},
|
||||
},
|
||||
{
|
||||
name: "invalid_build",
|
||||
tag: "v1+bld", // can only include build detail with all three elements
|
||||
expandTags: []string{"v1+bld"},
|
||||
},
|
||||
{
|
||||
name: "accidental_non_semver",
|
||||
tag: "1.2.3",
|
||||
expandTags: []string{"1", "1.2", "1.2.3"},
|
||||
},
|
||||
{
|
||||
name: "non_semver",
|
||||
tag: "latest",
|
||||
expandTags: []string{"latest"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tags := Build{ExpandTag: true}.labelsForTag(tt.tag)
|
||||
if got, want := tags, tt.expandTags; !cmp.Equal(got, want) {
|
||||
t.Errorf("tagsFor(%q) = %q, want %q", tt.tag, got, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuild_AutoTags(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
repoBranch string
|
||||
commitRef string
|
||||
autoTagSuffix string
|
||||
expectedTags []string
|
||||
}{
|
||||
{
|
||||
name: "commit push",
|
||||
repoBranch: "master",
|
||||
commitRef: "refs/heads/master",
|
||||
autoTagSuffix: "",
|
||||
expectedTags: []string{"latest"},
|
||||
},
|
||||
{
|
||||
name: "tag push",
|
||||
repoBranch: "master",
|
||||
commitRef: "refs/tags/v1.0.0",
|
||||
autoTagSuffix: "",
|
||||
expectedTags: []string{
|
||||
"1",
|
||||
"1.0",
|
||||
"1.0.0",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "beta tag push",
|
||||
repoBranch: "master",
|
||||
commitRef: "refs/tags/v1.0.0-beta.1",
|
||||
autoTagSuffix: "",
|
||||
expectedTags: []string{
|
||||
"1.0.0-beta.1",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "tag push with suffix",
|
||||
repoBranch: "master",
|
||||
commitRef: "refs/tags/v1.0.0",
|
||||
autoTagSuffix: "linux-amd64",
|
||||
expectedTags: []string{
|
||||
"1-linux-amd64",
|
||||
"1.0-linux-amd64",
|
||||
"1.0.0-linux-amd64",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
b := Build{DroneCommitRef: tt.commitRef, DroneRepoBranch: tt.repoBranch, AutoTag: true}
|
||||
if tt.autoTagSuffix != "" {
|
||||
b.AutoTagSuffix = tt.autoTagSuffix
|
||||
}
|
||||
tags, err := b.AutoTags()
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected err %q", err)
|
||||
}
|
||||
if got, want := tags, tt.expectedTags; !cmp.Equal(got, want) {
|
||||
t.Errorf("auto detected tags = %q, wanted = %q", got, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
t.Run("auto-tag cannot be enabled with user provided tags", func(t *testing.T) {
|
||||
b := Build{
|
||||
DroneCommitRef: "refs/tags/v1.0.0",
|
||||
DroneRepoBranch: "master",
|
||||
AutoTag: true,
|
||||
Tags: []string{"v1"},
|
||||
}
|
||||
_, err := b.AutoTags()
|
||||
if err == nil {
|
||||
t.Errorf("Expect error for invalid flags")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ const (
|
||||
Docker RegistryTypeEnum = "Docker"
|
||||
ECR RegistryTypeEnum = "ECR"
|
||||
GCR RegistryTypeEnum = "GCR"
|
||||
GAR RegistryTypeEnum = "GAR"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -0,0 +1,35 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Create the docker config file for authentication
|
||||
func CreateDockerCfgFile(username, password, registry, path string) error {
|
||||
if username == "" {
|
||||
return fmt.Errorf("Username must be specified")
|
||||
}
|
||||
if password == "" {
|
||||
return fmt.Errorf("Password must be specified")
|
||||
}
|
||||
|
||||
err := os.MkdirAll(path, 0600)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to create %s directory", path))
|
||||
}
|
||||
|
||||
authBytes := []byte(fmt.Sprintf("%s:%s", username, password))
|
||||
encodedString := base64.StdEncoding.EncodeToString(authBytes)
|
||||
jsonBytes := []byte(fmt.Sprintf(`{"auths": {"%s": {"auth": "%s"}}}`, "https://"+registry, encodedString))
|
||||
filePath := path + "/config.json"
|
||||
err = ioutil.WriteFile(filePath, jsonBytes, 0644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create docker config file")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package output
|
||||
|
||||
import (
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func WritePluginOutputFile(outputFilePath, digest string) error {
|
||||
output := map[string]string{
|
||||
"digest": digest,
|
||||
}
|
||||
return godotenv.Write(output, outputFilePath)
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
// A fork of https://github.com/drone-plugins/drone-docker/blob/master/tags.go
|
||||
|
||||
package tagger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/coreos/go-semver/semver"
|
||||
)
|
||||
|
||||
// AutoTagsSuffix returns a set of default suggested tags
|
||||
// based on the commit ref with an attached suffix.
|
||||
func AutoTagsSuffix(ref, suffix string) ([]string, error) {
|
||||
tags, err := AutoTags(ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(suffix) == 0 {
|
||||
return tags, nil
|
||||
}
|
||||
for i, tag := range tags {
|
||||
if tag == "latest" {
|
||||
tags[i] = suffix
|
||||
} else {
|
||||
tags[i] = fmt.Sprintf("%s-%s", tag, suffix)
|
||||
}
|
||||
}
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
func splitOff(input string, delim string) string {
|
||||
parts := strings.SplitN(input, delim, 2)
|
||||
|
||||
if len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
|
||||
return input
|
||||
}
|
||||
|
||||
// AutoTags returns a set of default suggested tags based on
|
||||
// the commit ref.
|
||||
func AutoTags(ref string) ([]string, error) {
|
||||
if !strings.HasPrefix(ref, "refs/tags/") {
|
||||
return []string{"latest"}, nil
|
||||
}
|
||||
v := stripTagPrefix(ref)
|
||||
version, err := semver.NewVersion(v)
|
||||
if err != nil {
|
||||
return []string{"latest"}, err
|
||||
}
|
||||
if version.PreRelease != "" || version.Metadata != "" {
|
||||
return []string{
|
||||
version.String(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
v = stripTagPrefix(ref)
|
||||
v = splitOff(splitOff(v, "+"), "-")
|
||||
dotParts := strings.SplitN(v, ".", 3)
|
||||
|
||||
if version.Major == 0 {
|
||||
return []string{
|
||||
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),
|
||||
}, nil
|
||||
}
|
||||
return []string{
|
||||
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),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UseAutoTag for keep only default branch for latest tag.
|
||||
func UseAutoTag(ref, defaultBranch string) bool {
|
||||
if strings.HasPrefix(ref, "refs/tags/") {
|
||||
return true
|
||||
}
|
||||
if stripHeadPrefix(ref) == defaultBranch {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func stripHeadPrefix(ref string) string {
|
||||
return strings.TrimPrefix(ref, "refs/heads/")
|
||||
}
|
||||
|
||||
func stripTagPrefix(ref string) string {
|
||||
ref = strings.TrimPrefix(ref, "refs/tags/")
|
||||
ref = strings.TrimPrefix(ref, "v")
|
||||
return ref
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
// A fork of https://github.com/drone-plugins/drone-docker/blob/master/tags_test.go
|
||||
|
||||
package tagger
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_stripTagPrefix(t *testing.T) {
|
||||
var tests = []struct {
|
||||
Before string
|
||||
After string
|
||||
}{
|
||||
{"refs/tags/1.0.0", "1.0.0"},
|
||||
{"refs/tags/v1.0.0", "1.0.0"},
|
||||
{"v1.0.0", "1.0.0"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
got, want := stripTagPrefix(test.Before), test.After
|
||||
if got != want {
|
||||
t.Errorf("Got tag %s, want %s", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutoTags(t *testing.T) {
|
||||
var tests = []struct {
|
||||
Before string
|
||||
After []string
|
||||
}{
|
||||
{"", []string{"latest"}},
|
||||
{"refs/heads/master", []string{"latest"}},
|
||||
{"refs/tags/0.9.0", []string{"0.9", "0.9.0"}},
|
||||
{"refs/tags/1.0.0", []string{"1", "1.0", "1.0.0"}},
|
||||
{"refs/tags/v1.0.0", []string{"1", "1.0", "1.0.0"}},
|
||||
{"refs/tags/v1.0.0-alpha.1", []string{"1.0.0-alpha.1"}},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
tags, err := AutoTags(test.Before)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
continue
|
||||
}
|
||||
got, want := tags, test.After
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("Got tag %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutoTagsError(t *testing.T) {
|
||||
var tests = []string{
|
||||
"refs/tags/x1.0.0",
|
||||
"refs/tags/20190203",
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
_, err := AutoTags(test)
|
||||
if err == nil {
|
||||
t.Errorf("Expect tag error for %s", test)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutoTagsSuffix(t *testing.T) {
|
||||
var tests = []struct {
|
||||
Before string
|
||||
Suffix string
|
||||
After []string
|
||||
}{
|
||||
// without suffix
|
||||
{
|
||||
After: []string{"latest"},
|
||||
},
|
||||
{
|
||||
Before: "refs/tags/v1.0.0",
|
||||
After: []string{
|
||||
"1",
|
||||
"1.0",
|
||||
"1.0.0",
|
||||
},
|
||||
},
|
||||
// with suffix
|
||||
{
|
||||
Suffix: "linux-amd64",
|
||||
After: []string{"linux-amd64"},
|
||||
},
|
||||
{
|
||||
Before: "refs/tags/v1.0.0",
|
||||
Suffix: "linux-amd64",
|
||||
After: []string{
|
||||
"1-linux-amd64",
|
||||
"1.0-linux-amd64",
|
||||
"1.0.0-linux-amd64",
|
||||
},
|
||||
},
|
||||
{
|
||||
Suffix: "nanoserver",
|
||||
After: []string{"nanoserver"},
|
||||
},
|
||||
{
|
||||
Before: "refs/tags/v1.9.2",
|
||||
Suffix: "nanoserver",
|
||||
After: []string{
|
||||
"1-nanoserver",
|
||||
"1.9-nanoserver",
|
||||
"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 {
|
||||
tag, err := AutoTagsSuffix(test.Before, test.Suffix)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
continue
|
||||
}
|
||||
got, want := tag, test.After
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("Got tag %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Test_stripHeadPrefix(t *testing.T) {
|
||||
type args struct {
|
||||
ref string
|
||||
}
|
||||
tests := []struct {
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{
|
||||
args: args{
|
||||
ref: "refs/heads/master",
|
||||
},
|
||||
want: "master",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := stripHeadPrefix(tt.args.ref); got != tt.want {
|
||||
t.Errorf("stripHeadPrefix() = %v, want %v", got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUseAutoTag(t *testing.T) {
|
||||
type args struct {
|
||||
ref string
|
||||
defaultBranch string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "latest tag for default branch",
|
||||
args: args{
|
||||
ref: "refs/heads/master",
|
||||
defaultBranch: "master",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "build from tags",
|
||||
args: args{
|
||||
ref: "refs/tags/v1.0.0",
|
||||
defaultBranch: "master",
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "skip build for not default branch",
|
||||
args: args{
|
||||
ref: "refs/heads/develop",
|
||||
defaultBranch: "master",
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := UseAutoTag(tt.args.ref, tt.args.defaultBranch); got != tt.want {
|
||||
t.Errorf("%q. UseAutoTag() = %v, want %v", tt.name, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,19 @@ set -x
|
||||
|
||||
# linux
|
||||
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/kaniko-gcr ./cmd/kaniko-gcr
|
||||
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/kaniko-acr ./cmd/kaniko-acr
|
||||
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/kaniko-ecr ./cmd/kaniko-ecr
|
||||
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/kaniko-docker ./cmd/kaniko-docker
|
||||
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/kaniko-gar ./cmd/kaniko-gar
|
||||
|
||||
GOOS=linux GOARCH=arm64 go build -o release/linux/arm64/kaniko-gcr ./cmd/kaniko-gcr
|
||||
GOOS=linux GOARCH=arm64 go build -o release/linux/arm64/kaniko-acr ./cmd/kaniko-acr
|
||||
GOOS=linux GOARCH=arm64 go build -o release/linux/arm64/kaniko-ecr ./cmd/kaniko-ecr
|
||||
GOOS=linux GOARCH=arm64 go build -o release/linux/arm64/kaniko-docker ./cmd/kaniko-docker
|
||||
GOOS=linux GOARCH=arm64 go build -o release/linux/arm64/kaniko-gar ./cmd/kaniko-gar
|
||||
|
||||
GOOS=linux GOARCH=arm go build -o release/linux/arm/kaniko-gcr ./cmd/kaniko-gcr
|
||||
GOOS=linux GOARCH=arm go build -o release/linux/arm/kaniko-acr ./cmd/kaniko-acr
|
||||
GOOS=linux GOARCH=arm go build -o release/linux/arm/kaniko-ecr ./cmd/kaniko-ecr
|
||||
GOOS=linux GOARCH=arm go build -o release/linux/arm/kaniko-docker ./cmd/kaniko-docker
|
||||
GOOS=linux GOARCH=arm go build -o release/linux/arm/kaniko-gar ./cmd/kaniko-gar
|
||||
|
||||
@@ -15,10 +15,12 @@ set -x
|
||||
|
||||
# build the binary
|
||||
go build -o release/linux/amd64/kaniko-gcr ./cmd/kaniko-gcr
|
||||
go build -o release/linux/amd64/kaniko-gar ./cmd/kaniko-gar
|
||||
go build -o release/linux/amd64/kaniko-ecr ./cmd/kaniko-ecr
|
||||
go build -o release/linux/amd64/kaniko-docker ./cmd/kaniko-docker
|
||||
|
||||
# build the docker image
|
||||
docker build -f docker/gcr/Dockerfile.linux.amd64 -t plugins/kaniko-gcr .
|
||||
docker build -f docker/gar/Dockerfile.linux.amd64 -t plugins/kaniko-gar .
|
||||
docker build -f docker/ecr/Dockerfile.linux.amd64 -t plugins/kaniko-ecr .
|
||||
docker build -f docker/docker/Dockerfile.linux.amd64 -t plugins/kaniko .
|
||||
|
||||
Reference in New Issue
Block a user