Skip to content

Commit

Permalink
Fix incorrect path used in watch command (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
thampiotr authored Jun 25, 2024
1 parent ade26db commit ab6cca9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit ab6cca9

Please sign in to comment.