Compare commits

...

2 Commits

Author SHA1 Message Date
Raghav 4893b5b945 add support for docker complaint registries for base image (#74) 2023-02-23 11:38:53 +05:30
Soumyajit Das 447ee28867 fix: [CI-6505]: Upgrade kanoko version for all (#71) 2023-01-17 13:00:11 +05:30
10 changed files with 56 additions and 18 deletions
+12 -2
View File
@@ -64,6 +64,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",
@@ -242,6 +247,7 @@ func run(c *cli.Context) error {
noPush := c.Bool("no-push")
dockerConfig, err := createDockerConfig(
c.String("docker-registry"),
c.String("docker-username"),
c.String("docker-password"),
c.String("access-key"),
@@ -328,12 +334,16 @@ func run(c *cli.Context) error {
return plugin.Exec()
}
func createDockerConfig(dockerUsername, dockerPassword, accessKey, secretKey,
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)
}
if assumeRole != "" {
+28
View File
@@ -10,6 +10,7 @@ import (
func TestCreateDockerConfig(t *testing.T) {
got, err := createDockerConfig(
"",
"docker-username",
"docker-password",
"access-key",
@@ -34,10 +35,37 @@ 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) {
os.Setenv(kanikoVersionEnv, "1.8.1")
defer os.Setenv(kanikoVersionEnv, "")
got, err := createDockerConfig(
"",
"docker-username",
"docker-password",
"access-key",
+2 -2
View File
@@ -1,5 +1,5 @@
FROM gcr.io/kaniko-project/executor:v1.8.1
FROM gcr.io/kaniko-project/executor:v1.9.1
ENV KANIKO_VERSION=1.8.1
ENV KANIKO_VERSION=1.9.1
ADD release/linux/amd64/kaniko-acr /kaniko/
ENTRYPOINT ["/kaniko/kaniko-acr"]
+2 -2
View File
@@ -1,8 +1,8 @@
FROM gcr.io/kaniko-project/executor:v1.8.1
FROM gcr.io/kaniko-project/executor:v1.9.1
ENV HOME /root
ENV USER root
ENV KANIKO_VERSION=1.8.1
ENV KANIKO_VERSION=1.9.1
ADD release/linux/arm64/kaniko-acr /kaniko/
ENTRYPOINT ["/kaniko/kaniko-acr"]
+2 -2
View File
@@ -1,5 +1,5 @@
FROM gcr.io/kaniko-project/executor:v1.6.0
FROM gcr.io/kaniko-project/executor:v1.9.1
ENV KANIKO_VERSION=1.6.0
ENV KANIKO_VERSION=1.9.1
ADD release/linux/amd64/kaniko-docker /kaniko/
ENTRYPOINT ["/kaniko/kaniko-docker"]
+2 -2
View File
@@ -1,8 +1,8 @@
FROM gcr.io/kaniko-project/executor:v1.6.0
FROM gcr.io/kaniko-project/executor:v1.9.1
ENV HOME /root
ENV USER root
ENV KANIKO_VERSION=1.6.0
ENV KANIKO_VERSION=1.9.1
ADD release/linux/arm64/kaniko-docker /kaniko/
ENTRYPOINT ["/kaniko/kaniko-docker"]
+2 -2
View File
@@ -1,5 +1,5 @@
FROM gcr.io/kaniko-project/executor:v1.6.0
FROM gcr.io/kaniko-project/executor:v1.9.1
ENV KANIKO_VERSION=1.6.0
ENV KANIKO_VERSION=1.9.1
ADD release/linux/amd64/kaniko-ecr /kaniko/
ENTRYPOINT ["/kaniko/kaniko-ecr"]
+2 -2
View File
@@ -1,8 +1,8 @@
FROM gcr.io/kaniko-project/executor:v1.6.0
FROM gcr.io/kaniko-project/executor:v1.9.1
ENV HOME /root
ENV USER root
ENV KANIKO_VERSION=1.6.0
ENV KANIKO_VERSION=1.9.1
ADD release/linux/arm64/kaniko-ecr /kaniko/
ENTRYPOINT ["/kaniko/kaniko-ecr"]
+2 -2
View File
@@ -1,5 +1,5 @@
FROM gcr.io/kaniko-project/executor:v1.6.0
FROM gcr.io/kaniko-project/executor:v1.9.1
ENV KANIKO_VERSION=1.6.0
ENV KANIKO_VERSION=1.9.1
ADD release/linux/amd64/kaniko-gcr /kaniko/
ENTRYPOINT ["/kaniko/kaniko-gcr"]
+2 -2
View File
@@ -1,8 +1,8 @@
FROM gcr.io/kaniko-project/executor:v1.6.0
FROM gcr.io/kaniko-project/executor:v1.9.1
ENV HOME /root
ENV USER root
ENV KANIKO_VERSION=1.6.0
ENV KANIKO_VERSION=1.9.1
ADD release/linux/arm64/kaniko-gcr /kaniko/
ENTRYPOINT ["/kaniko/kaniko-gcr"]