mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-14 22:11:18 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ed8ef9156e |
+9
-111
@@ -1,17 +1,10 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: vm
|
type: docker
|
||||||
name: default
|
name: default
|
||||||
|
|
||||||
pool:
|
|
||||||
use: ubuntu
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build
|
- name: build
|
||||||
image: golang:1.21
|
image: golang:1.18
|
||||||
commands:
|
commands:
|
||||||
- go test ./...
|
- go test ./...
|
||||||
- sh scripts/build.sh
|
- sh scripts/build.sh
|
||||||
@@ -50,23 +43,6 @@ steps:
|
|||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- 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
|
- name: ecr
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
@@ -135,22 +111,6 @@ steps:
|
|||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- 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
|
- name: ecr-kaniko-v1-9
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
@@ -170,15 +130,16 @@ steps:
|
|||||||
- pull_request
|
- pull_request
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: vm
|
type: docker
|
||||||
name: arm
|
name: arm
|
||||||
|
|
||||||
pool:
|
platform:
|
||||||
use: ubuntu_arm64
|
os: linux
|
||||||
|
arch: arm64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build
|
- name: build
|
||||||
image: golang:1.21
|
image: golang:1.18
|
||||||
commands:
|
commands:
|
||||||
- go test ./...
|
- go test ./...
|
||||||
- sh scripts/build.sh
|
- sh scripts/build.sh
|
||||||
@@ -217,23 +178,6 @@ steps:
|
|||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- 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
|
- name: ecr
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
@@ -302,22 +246,6 @@ steps:
|
|||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- 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
|
- name: ecr-kaniko-v1-9
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
@@ -337,12 +265,9 @@ steps:
|
|||||||
- pull_request
|
- pull_request
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: vm
|
type: docker
|
||||||
name: notifications-docker
|
name: notifications-docker
|
||||||
|
|
||||||
pool:
|
|
||||||
use: ubuntu
|
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: linux
|
||||||
arch: amd64
|
arch: amd64
|
||||||
@@ -372,18 +297,6 @@ steps:
|
|||||||
username:
|
username:
|
||||||
from_secret: docker_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
|
- name: manifest-acr
|
||||||
pull: always
|
pull: always
|
||||||
image: plugins/manifest
|
image: plugins/manifest
|
||||||
@@ -419,12 +332,9 @@ depends_on:
|
|||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: vm
|
type: docker
|
||||||
name: notifications-docker-kaniko1-8
|
name: notifications-docker-kaniko1-8
|
||||||
|
|
||||||
pool:
|
|
||||||
use: ubuntu
|
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: linux
|
||||||
arch: amd64
|
arch: amd64
|
||||||
@@ -454,18 +364,6 @@ steps:
|
|||||||
username:
|
username:
|
||||||
from_secret: docker_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
|
- name: manifest-ecr
|
||||||
pull: always
|
pull: always
|
||||||
image: plugins/manifest
|
image: plugins/manifest
|
||||||
|
|||||||
@@ -432,15 +432,6 @@ func getPublicUrl(token, registryUrl, subscriptionId string) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "failed to send request for getting container registry setting")
|
return "", errors.Wrap(err, "failed to send request for getting container registry setting")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(response.Value) == 0 {
|
|
||||||
return "", errors.New("did not receive any registry information from /subscriptions API")
|
|
||||||
}
|
|
||||||
|
|
||||||
if response.Value[0].ID == "" {
|
|
||||||
return "", errors.New("received empty registry ID from /subscriptions API")
|
|
||||||
}
|
|
||||||
|
|
||||||
return finalUrl + encodeParam(response.Value[0].ID), nil
|
return finalUrl + encodeParam(response.Value[0].ID), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -176,11 +176,6 @@ func main() {
|
|||||||
Usage: "Set this flag if you only want to build the image, without pushing to a registry",
|
Usage: "Set this flag if you only want to build the image, without pushing to a registry",
|
||||||
EnvVar: "PLUGIN_NO_PUSH",
|
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{
|
cli.StringFlag{
|
||||||
Name: "verbosity",
|
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.",
|
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.",
|
||||||
@@ -196,11 +191,6 @@ func main() {
|
|||||||
Usage: "build only used stages",
|
Usage: "build only used stages",
|
||||||
EnvVar: "PLUGIN_SKIP_UNUSED_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 {
|
if err := app.Run(os.Args); err != nil {
|
||||||
@@ -247,7 +237,6 @@ func run(c *cli.Context) error {
|
|||||||
CacheTTL: c.Int("cache-ttl"),
|
CacheTTL: c.Int("cache-ttl"),
|
||||||
DigestFile: defaultDigestFile,
|
DigestFile: defaultDigestFile,
|
||||||
NoPush: noPush,
|
NoPush: noPush,
|
||||||
TarPath: c.String("tar-path"),
|
|
||||||
Verbosity: c.String("verbosity"),
|
Verbosity: c.String("verbosity"),
|
||||||
Platform: c.String("platform"),
|
Platform: c.String("platform"),
|
||||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||||
@@ -259,9 +248,6 @@ func run(c *cli.Context) error {
|
|||||||
ArtifactFile: c.String("artifact-file"),
|
ArtifactFile: c.String("artifact-file"),
|
||||||
RegistryType: artifact.Docker,
|
RegistryType: artifact.Docker,
|
||||||
},
|
},
|
||||||
Output: kaniko.Output{
|
|
||||||
OutputFile: c.String("output-file"),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
}
|
}
|
||||||
|
|||||||
+55
-126
@@ -17,7 +17,6 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
|
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
ecrv1 "github.com/aws/aws-sdk-go/service/ecr"
|
ecrv1 "github.com/aws/aws-sdk-go/service/ecr"
|
||||||
ecrpublicv1 "github.com/aws/aws-sdk-go/service/ecrpublic"
|
|
||||||
"github.com/aws/smithy-go"
|
"github.com/aws/smithy-go"
|
||||||
"github.com/hashicorp/go-version"
|
"github.com/hashicorp/go-version"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
@@ -65,11 +64,6 @@ func main() {
|
|||||||
Value: "Dockerfile",
|
Value: "Dockerfile",
|
||||||
EnvVar: "PLUGIN_DOCKERFILE",
|
EnvVar: "PLUGIN_DOCKERFILE",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
|
||||||
Name: "docker-registry",
|
|
||||||
Usage: "docker registry",
|
|
||||||
EnvVar: "PLUGIN_DOCKER_REGISTRY,DOCKER_REGISTRY",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "docker-username",
|
Name: "docker-username",
|
||||||
Usage: "docker username",
|
Usage: "docker username",
|
||||||
@@ -246,18 +240,15 @@ func run(c *cli.Context) error {
|
|||||||
registry := c.String("registry")
|
registry := c.String("registry")
|
||||||
region := c.String("region")
|
region := c.String("region")
|
||||||
noPush := c.Bool("no-push")
|
noPush := c.Bool("no-push")
|
||||||
assumeRole := c.String("assume-role")
|
|
||||||
externalId := c.String("external-id")
|
|
||||||
|
|
||||||
dockerConfig, err := createDockerConfig(
|
dockerConfig, err := createDockerConfig(
|
||||||
c.String("docker-registry"),
|
|
||||||
c.String("docker-username"),
|
c.String("docker-username"),
|
||||||
c.String("docker-password"),
|
c.String("docker-password"),
|
||||||
c.String("access-key"),
|
c.String("access-key"),
|
||||||
c.String("secret-key"),
|
c.String("secret-key"),
|
||||||
registry,
|
registry,
|
||||||
assumeRole,
|
c.String("assume-role"),
|
||||||
externalId,
|
c.String("external-id"),
|
||||||
region,
|
region,
|
||||||
noPush,
|
noPush,
|
||||||
)
|
)
|
||||||
@@ -276,7 +267,7 @@ func run(c *cli.Context) error {
|
|||||||
|
|
||||||
// only create repository when pushing and create-repository is true
|
// only create repository when pushing and create-repository is true
|
||||||
if !noPush && c.Bool("create-repository") {
|
if !noPush && c.Bool("create-repository") {
|
||||||
if err := createRepository(region, repo, registry, assumeRole, externalId); err != nil {
|
if err := createRepository(region, repo, registry); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -286,7 +277,7 @@ func run(c *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := uploadLifeCyclePolicy(region, repo, string(contents), assumeRole, externalId); err != nil {
|
if err := uploadLifeCyclePolicy(region, repo, string(contents)); err != nil {
|
||||||
logrus.Fatal(fmt.Sprintf("error uploading ECR lifecycle policy: %v", err))
|
logrus.Fatal(fmt.Sprintf("error uploading ECR lifecycle policy: %v", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,7 +287,7 @@ func run(c *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := uploadRepositoryPolicy(region, repo, registry, string(contents), assumeRole, externalId); err != nil {
|
if err := uploadRepositoryPolicy(region, repo, registry, string(contents)); err != nil {
|
||||||
logrus.Fatal(fmt.Sprintf("error uploading ECR lifecycle policy: %v", err))
|
logrus.Fatal(fmt.Sprintf("error uploading ECR lifecycle policy: %v", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -337,16 +328,12 @@ func run(c *cli.Context) error {
|
|||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
func createDockerConfig(dockerRegistry, dockerUsername, dockerPassword, accessKey, secretKey,
|
func createDockerConfig(dockerUsername, dockerPassword, accessKey, secretKey,
|
||||||
registry, assumeRole, externalId, region string, noPush bool) (*docker.Config, error) {
|
registry, assumeRole, externalId, region string, noPush bool) (*docker.Config, error) {
|
||||||
dockerConfig := docker.NewConfig()
|
dockerConfig := docker.NewConfig()
|
||||||
|
|
||||||
if dockerUsername != "" {
|
if dockerUsername != "" {
|
||||||
// if no docker registry provided, use dockerhub by default
|
dockerConfig.SetAuth(docker.RegistryV1, dockerUsername, dockerPassword)
|
||||||
if len(dockerRegistry) == 0 {
|
|
||||||
dockerRegistry = docker.RegistryV1
|
|
||||||
}
|
|
||||||
dockerConfig.SetAuth(dockerRegistry, dockerUsername, dockerPassword)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if assumeRole != "" {
|
if assumeRole != "" {
|
||||||
@@ -386,7 +373,7 @@ func createDockerConfig(dockerRegistry, dockerUsername, dockerPassword, accessKe
|
|||||||
return dockerConfig, nil
|
return dockerConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createRepository(region, repo, registry, assumeRole, externalId string) error {
|
func createRepository(region, repo, registry string) error {
|
||||||
if registry == "" {
|
if registry == "" {
|
||||||
return fmt.Errorf("registry must be specified")
|
return fmt.Errorf("registry must be specified")
|
||||||
}
|
}
|
||||||
@@ -395,29 +382,22 @@ func createRepository(region, repo, registry, assumeRole, externalId string) err
|
|||||||
return fmt.Errorf("repo must be specified")
|
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
|
var createErr error
|
||||||
|
|
||||||
if assumeRole != "" {
|
//create public repo
|
||||||
if isRegistryPublic(registry) {
|
//if registry string starts with public domain (ex: public.ecr.aws/example-registry)
|
||||||
_, createErr = getAssumeRoleEcrPublicSvc(region, assumeRole, externalId).CreateRepository(&ecrpublicv1.CreateRepositoryInput{RepositoryName: &repo})
|
if isRegistryPublic(registry) {
|
||||||
} else {
|
svc := ecrpublic.NewFromConfig(cfg)
|
||||||
_, createErr = getAssumeRoleEcrSvc(region, assumeRole, externalId).CreateRepository(&ecrv1.CreateRepositoryInput{RepositoryName: &repo})
|
_, createErr = svc.CreateRepository(context.TODO(), &ecrpublic.CreateRepositoryInput{RepositoryName: &repo})
|
||||||
}
|
//create private repo
|
||||||
} else {
|
} else {
|
||||||
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
|
svc := ecr.NewFromConfig(cfg)
|
||||||
if err != nil {
|
_, createErr = svc.CreateRepository(context.TODO(), &ecr.CreateRepositoryInput{RepositoryName: &repo})
|
||||||
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
|
var apiError smithy.APIError
|
||||||
@@ -428,67 +408,46 @@ func createRepository(region, repo, registry, assumeRole, externalId string) err
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func uploadLifeCyclePolicy(region, repo, lifecyclePolicy, assumeRole, externalId string) (err error) {
|
func uploadLifeCyclePolicy(region, repo, lifecyclePolicy string) (err error) {
|
||||||
if assumeRole != "" {
|
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
|
||||||
input := &ecrv1.PutLifecyclePolicyInput{
|
if err != nil {
|
||||||
LifecyclePolicyText: aws.String(lifecyclePolicy),
|
return errors.Wrap(err, "failed to load aws config")
|
||||||
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)
|
|
||||||
|
|
||||||
input := &ecr.PutLifecyclePolicyInput{
|
|
||||||
LifecyclePolicyText: aws.String(lifecyclePolicy),
|
|
||||||
RepositoryName: aws.String(repo),
|
|
||||||
}
|
|
||||||
_, err = svc.PutLifecyclePolicy(context.TODO(), input)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
svc := ecr.NewFromConfig(cfg)
|
||||||
|
|
||||||
|
input := &ecr.PutLifecyclePolicyInput{
|
||||||
|
LifecyclePolicyText: aws.String(lifecyclePolicy),
|
||||||
|
RepositoryName: aws.String(repo),
|
||||||
|
}
|
||||||
|
_, err = svc.PutLifecyclePolicy(context.TODO(), input)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func uploadRepositoryPolicy(region, repo, registry, repositoryPolicy, assumeRole, externalId string) (err error) {
|
func uploadRepositoryPolicy(region, repo, registry, repositoryPolicy string) (err error) {
|
||||||
if assumeRole != "" {
|
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
|
||||||
if isRegistryPublic(registry) {
|
if err != nil {
|
||||||
input := &ecrpublicv1.SetRepositoryPolicyInput{
|
return errors.Wrap(err, "failed to load aws config")
|
||||||
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)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrap(err, "failed to load aws config")
|
|
||||||
}
|
|
||||||
|
|
||||||
if isRegistryPublic(registry) {
|
if isRegistryPublic(registry) {
|
||||||
svc := ecrpublic.NewFromConfig(cfg)
|
svc := ecrpublic.NewFromConfig(cfg)
|
||||||
input := &ecrpublic.SetRepositoryPolicyInput{
|
|
||||||
PolicyText: aws.String(repositoryPolicy),
|
input := &ecrpublic.SetRepositoryPolicyInput{
|
||||||
RepositoryName: aws.String(repo),
|
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)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
svc := ecr.NewFromConfig(cfg)
|
||||||
|
|
||||||
|
input := &ecr.SetRepositoryPolicyInput{
|
||||||
|
PolicyText: aws.String(repositoryPolicy),
|
||||||
|
RepositoryName: aws.String(repo),
|
||||||
|
}
|
||||||
|
_, err = svc.SetRepositoryPolicy(context.TODO(), input)
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
@@ -510,7 +469,7 @@ func getAssumeRoleCreds(region, roleArn, externalId, roleSessionName string) (st
|
|||||||
|
|
||||||
username, password, registry, err := getAuthInfo(svc)
|
username, password, registry, err := getAuthInfo(svc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", "", errors.Wrap(err, "failed to get ECR auth: no basic auth credentials")
|
return "", "", "", errors.Wrap(err, "failed to get ECR auth")
|
||||||
}
|
}
|
||||||
return username, password, registry, nil
|
return username, password, registry, nil
|
||||||
}
|
}
|
||||||
@@ -538,36 +497,6 @@ func getAuthInfo(svc *ecrv1.ECR) (username, password, registry string, err error
|
|||||||
return
|
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 {
|
func isRegistryPublic(registry string) bool {
|
||||||
return strings.HasPrefix(registry, ecrPublicDomain)
|
return strings.HasPrefix(registry, ecrPublicDomain)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
func TestCreateDockerConfig(t *testing.T) {
|
func TestCreateDockerConfig(t *testing.T) {
|
||||||
got, err := createDockerConfig(
|
got, err := createDockerConfig(
|
||||||
"",
|
|
||||||
"docker-username",
|
"docker-username",
|
||||||
"docker-password",
|
"docker-password",
|
||||||
"access-key",
|
"access-key",
|
||||||
@@ -35,37 +34,10 @@ func TestCreateDockerConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
func TestCreateDockerConfigKanikoOneDotEight(t *testing.T) {
|
||||||
os.Setenv(kanikoVersionEnv, "1.8.1")
|
os.Setenv(kanikoVersionEnv, "1.8.1")
|
||||||
defer os.Setenv(kanikoVersionEnv, "")
|
defer os.Setenv(kanikoVersionEnv, "")
|
||||||
got, err := createDockerConfig(
|
got, err := createDockerConfig(
|
||||||
"",
|
|
||||||
"docker-username",
|
"docker-username",
|
||||||
"docker-password",
|
"docker-password",
|
||||||
"access-key",
|
"access-key",
|
||||||
|
|||||||
@@ -1,234 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"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",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
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")
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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: c.String("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
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.19.2
|
FROM gcr.io/kaniko-project/executor:v1.8.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.19.2
|
ENV KANIKO_VERSION=1.8.1
|
||||||
ADD release/linux/amd64/kaniko-acr /kaniko/
|
ADD release/linux/amd64/kaniko-acr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-acr"]
|
ENTRYPOINT ["/kaniko/kaniko-acr"]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.19.2
|
FROM gcr.io/kaniko-project/executor:v1.8.1
|
||||||
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER root
|
ENV USER root
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.19.2
|
ENV KANIKO_VERSION=1.8.1
|
||||||
ADD release/linux/arm64/kaniko-acr /kaniko/
|
ADD release/linux/arm64/kaniko-acr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-acr"]
|
ENTRYPOINT ["/kaniko/kaniko-acr"]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.19.2
|
FROM gcr.io/kaniko-project/executor:v1.6.0
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.19.2
|
ENV KANIKO_VERSION=1.6.0
|
||||||
ADD release/linux/amd64/kaniko-docker /kaniko/
|
ADD release/linux/amd64/kaniko-docker /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.19.2
|
FROM gcr.io/kaniko-project/executor:v1.6.0
|
||||||
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER root
|
ENV USER root
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.19.2
|
ENV KANIKO_VERSION=1.6.0
|
||||||
ADD release/linux/arm64/kaniko-docker /kaniko/
|
ADD release/linux/arm64/kaniko-docker /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.19.2
|
FROM gcr.io/kaniko-project/executor:v1.6.0
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.19.2
|
ENV KANIKO_VERSION=1.6.0
|
||||||
ADD release/linux/amd64/kaniko-ecr /kaniko/
|
ADD release/linux/amd64/kaniko-ecr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.19.2
|
FROM gcr.io/kaniko-project/executor:v1.6.0
|
||||||
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER root
|
ENV USER root
|
||||||
ENV KANIKO_VERSION=1.19.2
|
ENV KANIKO_VERSION=1.6.0
|
||||||
|
|
||||||
ADD release/linux/arm64/kaniko-ecr /kaniko/
|
ADD release/linux/arm64/kaniko-ecr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.19.2
|
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.19.2
|
|
||||||
ADD release/linux/amd64/kaniko-gar /kaniko/
|
|
||||||
ENTRYPOINT ["/kaniko/kaniko-gar"]
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
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"]
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.19.2
|
|
||||||
|
|
||||||
ENV HOME /root
|
|
||||||
ENV USER root
|
|
||||||
ENV KANIKO_VERSION=1.19.2
|
|
||||||
|
|
||||||
ADD release/linux/arm64/kaniko-gar /kaniko/
|
|
||||||
ENTRYPOINT ["/kaniko/kaniko-gar"]
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
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"]
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
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,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.19.2
|
FROM gcr.io/kaniko-project/executor:v1.6.0
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.19.2
|
ENV KANIKO_VERSION=1.6.0
|
||||||
ADD release/linux/amd64/kaniko-gcr /kaniko/
|
ADD release/linux/amd64/kaniko-gcr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.19.2
|
FROM gcr.io/kaniko-project/executor:v1.6.0
|
||||||
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER root
|
ENV USER root
|
||||||
ENV KANIKO_VERSION=1.19.2
|
ENV KANIKO_VERSION=1.6.0
|
||||||
|
|
||||||
ADD release/linux/arm64/kaniko-gcr /kaniko/
|
ADD release/linux/arm64/kaniko-gcr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
module github.com/drone/drone-kaniko
|
module github.com/drone/drone-kaniko
|
||||||
|
|
||||||
require (
|
require (
|
||||||
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 v1.44.52
|
||||||
github.com/aws/aws-sdk-go-v2 v1.16.7
|
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/config v1.15.14
|
||||||
@@ -20,6 +18,8 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1 // indirect
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 // indirect
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // 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/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/credentials v1.12.9 // indirect
|
||||||
@@ -43,4 +43,4 @@ require (
|
|||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
go 1.21
|
go 1.18
|
||||||
|
|||||||
@@ -43,13 +43,9 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/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/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
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 h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
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/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
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.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
@@ -80,9 +76,9 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
|
|||||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
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.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/urfave/cli v1.22.9 h1:cv3/KhXGBGjEXLC4bH0sLuJ9BewaAbpk5oyMOveu4pw=
|
github.com/urfave/cli v1.22.9 h1:cv3/KhXGBGjEXLC4bH0sLuJ9BewaAbpk5oyMOveu4pw=
|
||||||
github.com/urfave/cli v1.22.9/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
github.com/urfave/cli v1.22.9/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
|
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
|
||||||
@@ -97,6 +93,8 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
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-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-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e h1:NHvCuwuS43lGnYhten69ZWqi2QOj/CiDNcKbVqwVoew=
|
||||||
|
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e/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 h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
@@ -105,8 +103,5 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
|||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
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-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/drone/drone-kaniko/pkg/artifact"
|
"github.com/drone/drone-kaniko/pkg/artifact"
|
||||||
"github.com/drone/drone-kaniko/pkg/output"
|
|
||||||
"github.com/drone/drone-kaniko/pkg/tagger"
|
"github.com/drone/drone-kaniko/pkg/tagger"
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
)
|
)
|
||||||
@@ -39,7 +38,6 @@ type (
|
|||||||
Verbosity string // Log level
|
Verbosity string // Log level
|
||||||
Platform string // Allows to build with another default platform than the host, similarly to docker build --platform
|
Platform string // Allows to build with another default platform than the host, similarly to docker build --platform
|
||||||
SkipUnusedStages bool // Build only used stages
|
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 defines content of artifact file
|
||||||
@@ -51,16 +49,10 @@ type (
|
|||||||
ArtifactFile string // Artifact file location
|
ArtifactFile string // Artifact file location
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output defines content of output file
|
|
||||||
Output struct {
|
|
||||||
OutputFile string // File where plugin output are saved
|
|
||||||
}
|
|
||||||
|
|
||||||
// Plugin defines the Docker plugin parameters.
|
// Plugin defines the Docker plugin parameters.
|
||||||
Plugin struct {
|
Plugin struct {
|
||||||
Build Build // Docker build configuration
|
Build Build // Docker build configuration
|
||||||
Artifact Artifact // Artifact file content
|
Artifact Artifact // Artifact file content
|
||||||
Output Output // Output file content
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -156,15 +148,14 @@ func (p Plugin) Exec() error {
|
|||||||
fmt.Sprintf("--context=dir://%s", p.Build.Context),
|
fmt.Sprintf("--context=dir://%s", p.Build.Context),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the destination repository only when we push or save to tarball
|
// Set the destination repository
|
||||||
if !p.Build.NoPush || p.Build.TarPath != "" {
|
if !p.Build.NoPush {
|
||||||
for _, tag := range tags {
|
for _, tag := range tags {
|
||||||
for _, label := range p.Build.labelsForTag(tag) {
|
for _, label := range p.Build.labelsForTag(tag) {
|
||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--destination=%s:%s", p.Build.Repo, label))
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--destination=%s:%s", p.Build.Repo, label))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the build arguments
|
// Set the build arguments
|
||||||
for _, arg := range p.Build.Args {
|
for _, arg := range p.Build.Args {
|
||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--build-arg=%s", arg))
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--build-arg=%s", arg))
|
||||||
@@ -221,10 +212,6 @@ func (p Plugin) Exec() error {
|
|||||||
cmdArgs = append(cmdArgs, "--skip-unused-stages")
|
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 := exec.Command("/kaniko/executor", cmdArgs...)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
@@ -236,29 +223,19 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if p.Build.DigestFile != "" && p.Artifact.ArtifactFile != "" {
|
if p.Build.DigestFile != "" && p.Artifact.ArtifactFile != "" {
|
||||||
err = artifact.WritePluginArtifactFile(p.Artifact.RegistryType, p.Artifact.ArtifactFile, p.Artifact.Registry, p.Artifact.Repo, getDigest(p.Build.DigestFile), p.Artifact.Tags)
|
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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed to write plugin artifact file at path: %s with error: %s\n", p.Artifact.ArtifactFile, err)
|
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
|
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
|
// 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.
|
// tag so that it can be extracted and displayed in the logs.
|
||||||
func trace(cmd *exec.Cmd) {
|
func trace(cmd *exec.Cmd) {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ const (
|
|||||||
Docker RegistryTypeEnum = "Docker"
|
Docker RegistryTypeEnum = "Docker"
|
||||||
ECR RegistryTypeEnum = "ECR"
|
ECR RegistryTypeEnum = "ECR"
|
||||||
GCR RegistryTypeEnum = "GCR"
|
GCR RegistryTypeEnum = "GCR"
|
||||||
GAR RegistryTypeEnum = "GAR"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
package output
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/joho/godotenv"
|
|
||||||
)
|
|
||||||
|
|
||||||
func WritePluginOutputFile(outputFilePath, digest string) error {
|
|
||||||
output := map[string]string{
|
|
||||||
"digest": digest,
|
|
||||||
}
|
|
||||||
return godotenv.Write(output, outputFilePath)
|
|
||||||
}
|
|
||||||
@@ -14,16 +14,13 @@ GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/kaniko-gcr ./cmd/kani
|
|||||||
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-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-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-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-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-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-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-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-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-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-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-docker ./cmd/kaniko-docker
|
||||||
GOOS=linux GOARCH=arm go build -o release/linux/arm/kaniko-gar ./cmd/kaniko-gar
|
|
||||||
|
|||||||
@@ -15,12 +15,10 @@ set -x
|
|||||||
|
|
||||||
# build the binary
|
# build the binary
|
||||||
go build -o release/linux/amd64/kaniko-gcr ./cmd/kaniko-gcr
|
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-ecr ./cmd/kaniko-ecr
|
||||||
go build -o release/linux/amd64/kaniko-docker ./cmd/kaniko-docker
|
go build -o release/linux/amd64/kaniko-docker ./cmd/kaniko-docker
|
||||||
|
|
||||||
# build the docker image
|
# build the docker image
|
||||||
docker build -f docker/gcr/Dockerfile.linux.amd64 -t plugins/kaniko-gcr .
|
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/ecr/Dockerfile.linux.amd64 -t plugins/kaniko-ecr .
|
||||||
docker build -f docker/docker/Dockerfile.linux.amd64 -t plugins/kaniko .
|
docker build -f docker/docker/Dockerfile.linux.amd64 -t plugins/kaniko .
|
||||||
|
|||||||
Reference in New Issue
Block a user