Skip to content

Commit

Permalink
warn and continue when ONBUILD image could not be retrieved
Browse files Browse the repository at this point in the history
  • Loading branch information
tejal29 committed Oct 21, 2020
1 parent 12d64a2 commit 9e963ba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/skaffold/docker/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package docker

import (
"context"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -61,6 +62,7 @@ type fromTo struct {
var (
// RetrieveImage is overridden for unit testing
RetrieveImage = retrieveImage
onBuildRetrieveErr = errors.New("error retrieving ONBUILD image")
)

func readCopyCmdsFromDockerfile(onlyLastImage bool, absDockerfilePath, workspace string, buildArgs map[string]*string, cfg Config) ([]fromTo, error) {
Expand Down Expand Up @@ -318,6 +320,11 @@ func expandOnbuildInstructions(nodes []*parser.Node, cfg Config) ([]*parser.Node
} else if ons, err := parseOnbuild(from.image, cfg); err == nil {
onbuildNodes = ons
} else {
if errors.Is(err, onBuildRetrieveErr) {
// TODO: [4895] collect warning codes for warnings seen during a dev iteration.
logrus.Warnf("could not retrieve ONBUILD image %s. Will ignore files dependencies for all ONBUILD triggers", from.image)
return []*parser.Node{}, nil
}
return nil, fmt.Errorf("parsing ONBUILD instructions: %w", err)
}

Expand All @@ -339,7 +346,7 @@ func parseOnbuild(image string, cfg Config) ([]*parser.Node, error) {
// Image names are case SENSITIVE
img, err := RetrieveImage(image, cfg)
if err != nil {
return nil, fmt.Errorf("retrieving image %q: %w", image, err)
return nil, onBuildRetrieveErr
}

if len(img.Config.OnBuild) == 0 {
Expand Down

0 comments on commit 9e963ba

Please sign in to comment.