-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lists files recursively in jib.getDependencies and other fixes. #1097
Changes from 5 commits
a5775f1
a6f4ddc
d566548
16007c3
396fbb2
5374868
1e643fc
d0c069d
30ce7ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,12 @@ import ( | |
"os/exec" | ||
"strings" | ||
|
||
"os" | ||
"path/filepath" | ||
|
||
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util" | ||
"github.com/pkg/errors" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func getDependencies(cmd *exec.Cmd) ([]string, error) { | ||
|
@@ -30,14 +35,34 @@ func getDependencies(cmd *exec.Cmd) ([]string, error) { | |
} | ||
|
||
// Parses stdout for the dependencies, one per line | ||
// TODO(coollog) directories should be expanded recursively | ||
lines := strings.Split(string(stdout), "\n") | ||
var deps []string | ||
for _, l := range lines { | ||
if l == "" { | ||
for _, dep := range lines { | ||
if dep == "" { | ||
continue | ||
} | ||
|
||
// Resolves directories recursively. | ||
info, err := os.Stat(dep) | ||
if err != nil { | ||
if os.IsNotExist(err) { | ||
logrus.Debugf("could not stat dependency: %s", err) | ||
continue // Ignore files that don't exist | ||
} | ||
return nil, errors.Wrapf(err, "unable to stat file %s", dep) | ||
} | ||
if info.IsDir() { | ||
err := filepath.Walk(dep, func(path string, info os.FileInfo, err error) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
deps = append(deps, path) | ||
return nil | ||
}) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "filepath walk") | ||
} | ||
continue | ||
} | ||
deps = append(deps, l) | ||
|
||
deps = append(deps, dep) | ||
} | ||
return deps, nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,7 +428,12 @@ func dependenciesForArtifact(a *latest.Artifact) ([]string, error) { | |
|
||
var p []string | ||
for _, path := range paths { | ||
p = append(p, filepath.Join(a.Workspace, path)) | ||
if !filepath.IsAbs(path) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be fine in regards to the other artifacts right? There should be no case where a dep would be absolute yet need to resolve against workspace? |
||
path = filepath.Join(a.Workspace, path) | ||
} | ||
p = append(p, path) | ||
|
||
logrus.Info("watching: " + filepath.Join(a.Workspace, path)) | ||
} | ||
return p, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is modeled after the logic in
changes.go#stat
. I think ignoring non-existent files should be fine here since the files would be ignored bystat
anyways. The alternative is to just add the file to thedeps
list upon thisos.Stat
error. Thoughts?