diff --git a/cmd/kaniko-docker/main.go b/cmd/kaniko-docker/main.go index 4d69ad3..c43ae59 100644 --- a/cmd/kaniko-docker/main.go +++ b/cmd/kaniko-docker/main.go @@ -176,13 +176,14 @@ func run(c *cli.Context) error { // Create the docker config file for authentication func createDockerCfgFile(username, password, registry string) error { if username == "" { - return fmt.Errorf("Username must be specified") + fmt.Println("no username provided, using empty string") } if password == "" { - return fmt.Errorf("Password must be specified") + fmt.Println("no password provided, using empty string") } if registry == "" { - return fmt.Errorf("Registry must be specified") + fmt.Println("no registry string provided, using the default value") + registry = v1Registry } if registry == v2Registry { diff --git a/kaniko.go b/kaniko.go index 2f55d18..ed9424f 100644 --- a/kaniko.go +++ b/kaniko.go @@ -46,10 +46,6 @@ type ( // Exec executes the plugin step func (p Plugin) Exec() error { - if p.Build.Repo == "" { - return fmt.Errorf("repository name to publish image must be specified") - } - if _, err := os.Stat(p.Build.Dockerfile); os.IsNotExist(err) { return fmt.Errorf("dockerfile does not exist at path: %s", p.Build.Dockerfile) } @@ -59,10 +55,16 @@ func (p Plugin) Exec() error { fmt.Sprintf("--context=dir://%s", p.Build.Context), } - // Set the destination repository - for _, tag := range p.Build.Tags { - cmdArgs = append(cmdArgs, fmt.Sprintf("--destination=%s:%s", p.Build.Repo, tag)) + if p.Build.Repo == "" { + fmt.Println("repository name to publish image not specified, adding '--no-push' flag") + cmdArgs = append(cmdArgs, fmt.Sprintf("--no-push")) + } else { + // Set the destination repository + for _, tag := range p.Build.Tags { + cmdArgs = append(cmdArgs, fmt.Sprintf("--destination=%s:%s", p.Build.Repo, tag)) + } } + // Set the build arguments for _, arg := range p.Build.Args { cmdArgs = append(cmdArgs, fmt.Sprintf("--build-arg=%s", arg))