From d273fda0b63c3ed7c961fe9eb52d521480ff5024 Mon Sep 17 00:00:00 2001 From: Nick Kubala Date: Wed, 10 Oct 2018 17:41:50 -0700 Subject: [PATCH 1/2] Minor logging improvements --- pkg/skaffold/bazel/bazel.go | 3 +++ pkg/skaffold/docker/parse.go | 2 +- pkg/skaffold/jib/jib_gradle.go | 2 ++ pkg/skaffold/jib/jib_maven.go | 2 ++ pkg/skaffold/watch/changes.go | 18 +++++++++++++++--- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/pkg/skaffold/bazel/bazel.go b/pkg/skaffold/bazel/bazel.go index 93e9d56d141..7eda2fcb37c 100644 --- a/pkg/skaffold/bazel/bazel.go +++ b/pkg/skaffold/bazel/bazel.go @@ -27,6 +27,7 @@ import ( "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest" "github.com/GoogleContainerTools/skaffold/pkg/skaffold/util" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) const sourceQuery = "kind('source file', deps('%[1]s')) union buildfiles('%[1]s')" @@ -65,6 +66,8 @@ func GetDependencies(ctx context.Context, workspace string, a *latest.BazelArtif deps = append(deps, "WORKSPACE") } + logrus.Debugf("Found dependencies for bazel artifact: %s", deps) + return deps, nil } diff --git a/pkg/skaffold/docker/parse.go b/pkg/skaffold/docker/parse.go index f37d4d9ea59..3aa125223a8 100644 --- a/pkg/skaffold/docker/parse.go +++ b/pkg/skaffold/docker/parse.go @@ -249,7 +249,7 @@ func expandPaths(workspace string, copied [][]string) ([]string, error) { for dep := range expandedPaths { deps = append(deps, dep) } - logrus.Infof("Found dependencies for dockerfile %s", deps) + logrus.Debugf("Found dependencies for dockerfile: %s", deps) return deps, nil } diff --git a/pkg/skaffold/jib/jib_gradle.go b/pkg/skaffold/jib/jib_gradle.go index a949dd2d552..1067b6e0fe2 100644 --- a/pkg/skaffold/jib/jib_gradle.go +++ b/pkg/skaffold/jib/jib_gradle.go @@ -24,6 +24,7 @@ import ( "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest" "github.com/GoogleContainerTools/skaffold/pkg/skaffold/util" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) var GradleCommand = util.CommandWrapper{Executable: "gradle", Wrapper: "gradlew"} @@ -36,6 +37,7 @@ func GetDependenciesGradle(ctx context.Context, workspace string, a *latest.JibG if err != nil { return nil, errors.Wrapf(err, "getting jibGradle dependencies") } + logrus.Debugf("Found dependencies for jibGradle artifact: %s", deps) return deps, nil } diff --git a/pkg/skaffold/jib/jib_maven.go b/pkg/skaffold/jib/jib_maven.go index d5b4648c633..15af6833959 100644 --- a/pkg/skaffold/jib/jib_maven.go +++ b/pkg/skaffold/jib/jib_maven.go @@ -23,6 +23,7 @@ import ( "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest" "github.com/GoogleContainerTools/skaffold/pkg/skaffold/util" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) var MavenCommand = util.CommandWrapper{Executable: "mvn", Wrapper: "mvnw"} @@ -38,6 +39,7 @@ func GetDependenciesMaven(ctx context.Context, workspace string, a *latest.JibMa if err != nil { return nil, errors.Wrapf(err, "getting jibMaven dependencies") } + logrus.Debugf("Found dependencies for jibMaven artifact: %s", deps) return deps, nil } diff --git a/pkg/skaffold/watch/changes.go b/pkg/skaffold/watch/changes.go index 3ca8eec7aeb..8d61ce9b589 100644 --- a/pkg/skaffold/watch/changes.go +++ b/pkg/skaffold/watch/changes.go @@ -105,13 +105,25 @@ func events(prev, curr FileMap) Events { } } - sortEvt(e) - logrus.Debug(e.String()) + sortEvents(e) + logEvents(e) return e } -func sortEvt(e Events) { +func sortEvents(e Events) { sort.Strings(e.Added) sort.Strings(e.Modified) sort.Strings(e.Deleted) } + +func logEvents(e Events) { + if e.Added != nil && len(e.Added) > 0 { + logrus.Infof("files added: %v", e.Added) + } + if e.Modified != nil && len(e.Modified) > 0 { + logrus.Infof("files modified: %v", e.Modified) + } + if e.Deleted != nil && len(e.Deleted) > 0 { + logrus.Infof("files deleted: %v", e.Deleted) + } +} From 306348d408ea5cac4d6566e2b53925a0719920f0 Mon Sep 17 00:00:00 2001 From: Nick Kubala Date: Thu, 11 Oct 2018 09:34:13 -0700 Subject: [PATCH 2/2] use %v instead of %s to string format a slice --- pkg/skaffold/bazel/bazel.go | 2 +- pkg/skaffold/docker/parse.go | 2 +- pkg/skaffold/jib/jib_gradle.go | 2 +- pkg/skaffold/jib/jib_maven.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/skaffold/bazel/bazel.go b/pkg/skaffold/bazel/bazel.go index 7eda2fcb37c..7f209b819e9 100644 --- a/pkg/skaffold/bazel/bazel.go +++ b/pkg/skaffold/bazel/bazel.go @@ -66,7 +66,7 @@ func GetDependencies(ctx context.Context, workspace string, a *latest.BazelArtif deps = append(deps, "WORKSPACE") } - logrus.Debugf("Found dependencies for bazel artifact: %s", deps) + logrus.Debugf("Found dependencies for bazel artifact: %v", deps) return deps, nil } diff --git a/pkg/skaffold/docker/parse.go b/pkg/skaffold/docker/parse.go index 3aa125223a8..21e5e899513 100644 --- a/pkg/skaffold/docker/parse.go +++ b/pkg/skaffold/docker/parse.go @@ -249,7 +249,7 @@ func expandPaths(workspace string, copied [][]string) ([]string, error) { for dep := range expandedPaths { deps = append(deps, dep) } - logrus.Debugf("Found dependencies for dockerfile: %s", deps) + logrus.Debugf("Found dependencies for dockerfile: %v", deps) return deps, nil } diff --git a/pkg/skaffold/jib/jib_gradle.go b/pkg/skaffold/jib/jib_gradle.go index 1067b6e0fe2..b3839eafdfe 100644 --- a/pkg/skaffold/jib/jib_gradle.go +++ b/pkg/skaffold/jib/jib_gradle.go @@ -37,7 +37,7 @@ func GetDependenciesGradle(ctx context.Context, workspace string, a *latest.JibG if err != nil { return nil, errors.Wrapf(err, "getting jibGradle dependencies") } - logrus.Debugf("Found dependencies for jibGradle artifact: %s", deps) + logrus.Debugf("Found dependencies for jibGradle artifact: %v", deps) return deps, nil } diff --git a/pkg/skaffold/jib/jib_maven.go b/pkg/skaffold/jib/jib_maven.go index 15af6833959..25ab8c28533 100644 --- a/pkg/skaffold/jib/jib_maven.go +++ b/pkg/skaffold/jib/jib_maven.go @@ -39,7 +39,7 @@ func GetDependenciesMaven(ctx context.Context, workspace string, a *latest.JibMa if err != nil { return nil, errors.Wrapf(err, "getting jibMaven dependencies") } - logrus.Debugf("Found dependencies for jibMaven artifact: %s", deps) + logrus.Debugf("Found dependencies for jibMaven artifact: %v", deps) return deps, nil }