mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-16 14:49:02 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| af93afae8c |
@@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -191,7 +190,7 @@ func run(c *cli.Context) error {
|
|||||||
},
|
},
|
||||||
Artifact: kaniko.Artifact{
|
Artifact: kaniko.Artifact{
|
||||||
Tags: c.StringSlice("tags"),
|
Tags: c.StringSlice("tags"),
|
||||||
Repo: buildRepo(c.String("registry"), c.String("repo")),
|
Repo: c.String("repo"),
|
||||||
Registry: c.String("registry"),
|
Registry: c.String("registry"),
|
||||||
ArtifactFile: c.String("artifact-file"),
|
ArtifactFile: c.String("artifact-file"),
|
||||||
RegistryType: artifact.Docker,
|
RegistryType: artifact.Docker,
|
||||||
@@ -232,17 +231,3 @@ func createDockerCfgFile(username, password, registry string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildRepo(registry, repo string) string {
|
|
||||||
if registry == "" {
|
|
||||||
// No custom registry, just return the repo name
|
|
||||||
return repo
|
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
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); got != tt.want {
|
|
||||||
t.Errorf("buildRepo(%q, %q) = %v, want %v", tt.registry, tt.repo, got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.7.0
|
FROM gcr.io/kaniko-project/executor:v1.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,4 +1,4 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.7.0
|
FROM gcr.io/kaniko-project/executor:arm64-v1.6.0
|
||||||
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER root
|
ENV USER root
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.7.0
|
FROM gcr.io/kaniko-project/executor:v1.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,4 +1,4 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.7.0
|
FROM gcr.io/kaniko-project/executor:arm64-v1.6.0
|
||||||
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER root
|
ENV USER root
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.7.0
|
FROM gcr.io/kaniko-project/executor:v1.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,4 +1,4 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.7.0
|
FROM gcr.io/kaniko-project/executor:arm64-v1.6.0
|
||||||
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER root
|
ENV USER root
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if p.Build.CacheTTL != 0 {
|
if p.Build.CacheTTL != 0 {
|
||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--cache-ttl=%dh", p.Build.CacheTTL))
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--cache-ttl=%d", p.Build.CacheTTL))
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Build.DigestFile != "" {
|
if p.Build.DigestFile != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user