Skip to content
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

Fix incorrect path used in watch command #458

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/grr/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions pkg/grizzly/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading