fix: use image name for run command (#238)

The run command shouldn't consume the digest (as it is being created once the image is being pushed to the external registry), because if we do deploy , then build and then run, the run will use image produced by deploy not the subsequent build.

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
This commit is contained in:
Zbynek Roubalik 2020-12-08 16:19:45 +01:00 committed by GitHub
parent 7e47377ce4
commit 985906b0e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -30,15 +30,15 @@ func (n *Runner) Run(f faas.Function) error {
return errors.New("please install 'docker'")
}
if f.Image == "" || f.ImageWithDigest() == "" {
return errors.New("Function has no associated Image and Digest. Has it been built?")
if f.Image == "" {
return errors.New("Function has no associated Image. Has it been built?")
}
// Extra arguments to docker
args := []string{"run", "--rm", "-t", "-p=8080:8080"}
for name, value := range f.EnvVars {
if !strings.HasSuffix(name,"-") {
if !strings.HasSuffix(name, "-") {
args = append(args, fmt.Sprintf("-e%s=%s", name, value))
}
}
@ -47,7 +47,7 @@ func (n *Runner) Run(f faas.Function) error {
if n.Verbose {
args = append(args, "-e VERBOSE=true")
}
args = append(args, f.ImageWithDigest())
args = append(args, f.Image)
// Set up the command with extra arguments and to run rooted at path
cmd := exec.Command("docker", args...)