mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-26 16:03:13 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1481814281 | |||
| f2aa7810ec |
@@ -75,6 +75,11 @@ func main() {
|
|||||||
EnvVar: "PLUGIN_TAGS",
|
EnvVar: "PLUGIN_TAGS",
|
||||||
FilePath: ".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{
|
cli.BoolFlag{
|
||||||
Name: "expand-tag",
|
Name: "expand-tag",
|
||||||
Usage: "enable for semver tagging",
|
Usage: "enable for semver tagging",
|
||||||
@@ -206,13 +211,13 @@ func run(c *cli.Context) error {
|
|||||||
ExpandTag: c.Bool("expand-tag"),
|
ExpandTag: c.Bool("expand-tag"),
|
||||||
Args: c.StringSlice("args"),
|
Args: c.StringSlice("args"),
|
||||||
Target: c.String("target"),
|
Target: c.String("target"),
|
||||||
Repo: buildRepo(c.String("registry"), c.String("repo")),
|
Repo: buildRepo(c.String("registry"), c.String("repo"), c.Bool("expand-repo")),
|
||||||
Mirrors: c.StringSlice("registry-mirrors"),
|
Mirrors: c.StringSlice("registry-mirrors"),
|
||||||
Labels: c.StringSlice("custom-labels"),
|
Labels: c.StringSlice("custom-labels"),
|
||||||
SkipTlsVerify: c.Bool("skip-tls-verify"),
|
SkipTlsVerify: c.Bool("skip-tls-verify"),
|
||||||
SnapshotMode: c.String("snapshot-mode"),
|
SnapshotMode: c.String("snapshot-mode"),
|
||||||
EnableCache: c.Bool("enable-cache"),
|
EnableCache: c.Bool("enable-cache"),
|
||||||
CacheRepo: buildRepo(c.String("registry"), c.String("cache-repo")),
|
CacheRepo: buildRepo(c.String("registry"), c.String("cache-repo"), c.Bool("expand-repo")),
|
||||||
CacheTTL: c.Int("cache-ttl"),
|
CacheTTL: c.Int("cache-ttl"),
|
||||||
DigestFile: defaultDigestFile,
|
DigestFile: defaultDigestFile,
|
||||||
NoPush: noPush,
|
NoPush: noPush,
|
||||||
@@ -221,7 +226,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: buildRepo(c.String("registry"), c.String("repo"), c.Bool("expand-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,
|
||||||
@@ -263,8 +268,8 @@ func createDockerCfgFile(username, password, registry string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildRepo(registry, repo string) string {
|
func buildRepo(registry, repo string, expandRepo bool) string {
|
||||||
if registry == "" || registry == v1RegistryURL {
|
if !expandRepo || registry == "" || registry == v1RegistryURL {
|
||||||
// No custom registry, just return the repo name
|
// No custom registry, just return the repo name
|
||||||
return repo
|
return repo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func Test_buildRepo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
if got := buildRepo(tt.registry, tt.repo); got != tt.want {
|
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)
|
t.Errorf("buildRepo(%q, %q) = %v, want %v", tt.registry, tt.repo, got, tt.want)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user