From ab6cca963b00d6e918e3e5f50546dc88ad14e263 Mon Sep 17 00:00:00 2001 From: Piotr <17101802+thampiotr@users.noreply.github.com> Date: Tue, 25 Jun 2024 16:59:35 +0100 Subject: [PATCH] Fix incorrect path used in watch command (#458) --- cmd/grr/workflow.go | 4 ++-- pkg/grizzly/workflow.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/grr/workflow.go b/cmd/grr/workflow.go index 77f75cf4..f4cb32ff 100644 --- a/cmd/grr/workflow.go +++ b/cmd/grr/workflow.go @@ -296,7 +296,7 @@ func watchCmd(registry grizzly.Registry) *cli.Command { } targets := currentContext.GetTargets(opts.Targets) - watchDir := args[0] + watchDir, resourcePath := args[0], args[1] trailRecorder := grizzly.NewWriterRecorder(os.Stdout, grizzly.EventToPlainText) @@ -305,7 +305,7 @@ func watchCmd(registry grizzly.Registry) *cli.Command { DefaultResourceKind: resourceKind, DefaultFolderUID: folderUID, } - return grizzly.Watch(registry, watchDir, parser, parserOpts, trailRecorder) + return grizzly.Watch(registry, watchDir, resourcePath, parser, parserOpts, trailRecorder) } cmd = initialiseOnlySpec(cmd, &opts) return initialiseCmd(cmd, &opts) diff --git a/pkg/grizzly/workflow.go b/pkg/grizzly/workflow.go index da9f1009..9b49aa4b 100644 --- a/pkg/grizzly/workflow.go +++ b/pkg/grizzly/workflow.go @@ -488,16 +488,16 @@ func Snapshot(registry Registry, resources Resources, expiresSeconds int) error // Watch watches a directory for changes then pushes Jsonnet resource to endpoints // when changes are noticed. -func Watch(registry Registry, watchDir string, parser Parser, parserOpts ParserOptions, trailRecorder eventsRecorder) error { +func Watch(registry Registry, watchDir string, resourcePath string, parser Parser, parserOpts ParserOptions, trailRecorder eventsRecorder) error { updateWatchedResource := func(path string) error { - log.Info("Changes detected. Applying ", path) - resources, err := parser.Parse(path, parserOpts) + log.Infof("Changes detected in %q. Applying %q", path, resourcePath) + resources, err := parser.Parse(resourcePath, parserOpts) if err != nil { - log.Error("Error: ", err) + log.Error("Error parsing resource file: ", err) } err = Apply(registry, resources, false, trailRecorder) // TODO? if err != nil { - log.Error("Error: ", err) + log.Error("Error applying resources: ", err) } return nil }