Compare commits

..

1 Commits

Author SHA1 Message Date
Shubham Agrawal af93afae8c Add support for custom platform 2021-12-01 17:08:49 +05:30
3 changed files with 2 additions and 54 deletions
+1 -16
View File
@@ -5,7 +5,6 @@ import (
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/joho/godotenv"
"github.com/pkg/errors"
@@ -191,7 +190,7 @@ func run(c *cli.Context) error {
},
Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"),
Repo: buildRepo(c.String("registry"), c.String("repo")),
Repo: c.String("repo"),
Registry: c.String("registry"),
ArtifactFile: c.String("artifact-file"),
RegistryType: artifact.Docker,
@@ -232,17 +231,3 @@ func createDockerCfgFile(username, password, registry string) error {
}
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
}
-37
View File
@@ -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 -1
View File
@@ -143,7 +143,7 @@ func (p Plugin) Exec() error {
}
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 != "" {