Compare commits
17 commits
master
...
lukehoban/
Author | SHA1 | Date | |
---|---|---|---|
|
ae2f5db7e7 | ||
|
f90ece4462 | ||
|
57ad7a9bae | ||
|
c4f4062b0f | ||
|
19865df412 | ||
|
61cce63199 | ||
|
c66233049b | ||
|
108f0bc467 | ||
|
efc6d8801d | ||
|
d3f8a02f4c | ||
|
5da85b1b2c | ||
|
20f79f2232 | ||
|
a91aefc1c3 | ||
|
6ab9dc20bd | ||
|
04057c1558 | ||
|
0315c18756 | ||
|
811beae23c |
|
@ -2,4 +2,9 @@
|
|||
|
||||
### Improvements
|
||||
|
||||
- [cli] - Added support for passing custom paths that need
|
||||
to be watched by the `pulumi watch` command.
|
||||
[#7115](https://github.com/pulumi/pulumi/pull/7247)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
|
|
@ -164,7 +164,7 @@ type Backend interface {
|
|||
// Destroy destroys all of this stack's resources.
|
||||
Destroy(ctx context.Context, stack Stack, op UpdateOperation) (engine.ResourceChanges, result.Result)
|
||||
// Watch watches the project's working directory for changes and automatically updates the active stack.
|
||||
Watch(ctx context.Context, stack Stack, op UpdateOperation) result.Result
|
||||
Watch(ctx context.Context, stack Stack, op UpdateOperation, paths []string) result.Result
|
||||
|
||||
// Query against the resource outputs in a stack's state checkpoint.
|
||||
Query(ctx context.Context, op QueryOperation) result.Result
|
||||
|
|
|
@ -534,8 +534,8 @@ func (b *localBackend) Query(ctx context.Context, op backend.QueryOperation) res
|
|||
}
|
||||
|
||||
func (b *localBackend) Watch(ctx context.Context, stack backend.Stack,
|
||||
op backend.UpdateOperation) result.Result {
|
||||
return backend.Watch(ctx, b, stack, op, b.apply)
|
||||
op backend.UpdateOperation, paths []string) result.Result {
|
||||
return backend.Watch(ctx, b, stack, op, b.apply, paths)
|
||||
}
|
||||
|
||||
// apply actually performs the provided type of update on a locally hosted stack.
|
||||
|
|
|
@ -85,8 +85,8 @@ func (s *localStack) Destroy(ctx context.Context, op backend.UpdateOperation) (e
|
|||
return backend.DestroyStack(ctx, s, op)
|
||||
}
|
||||
|
||||
func (s *localStack) Watch(ctx context.Context, op backend.UpdateOperation) result.Result {
|
||||
return backend.WatchStack(ctx, s, op)
|
||||
func (s *localStack) Watch(ctx context.Context, op backend.UpdateOperation, paths []string) result.Result {
|
||||
return backend.WatchStack(ctx, s, op, paths)
|
||||
}
|
||||
|
||||
func (s *localStack) GetLogs(ctx context.Context, cfg backend.StackConfiguration,
|
||||
|
|
|
@ -853,8 +853,8 @@ func (b *cloudBackend) Destroy(ctx context.Context, stack backend.Stack,
|
|||
}
|
||||
|
||||
func (b *cloudBackend) Watch(ctx context.Context, stack backend.Stack,
|
||||
op backend.UpdateOperation) result.Result {
|
||||
return backend.Watch(ctx, b, stack, op, b.apply)
|
||||
op backend.UpdateOperation, paths []string) result.Result {
|
||||
return backend.Watch(ctx, b, stack, op, b.apply, paths)
|
||||
}
|
||||
|
||||
func (b *cloudBackend) Query(ctx context.Context, op backend.QueryOperation) result.Result {
|
||||
|
|
|
@ -161,8 +161,8 @@ func (s *cloudStack) Destroy(ctx context.Context, op backend.UpdateOperation) (e
|
|||
return backend.DestroyStack(ctx, s, op)
|
||||
}
|
||||
|
||||
func (s *cloudStack) Watch(ctx context.Context, op backend.UpdateOperation) result.Result {
|
||||
return backend.WatchStack(ctx, s, op)
|
||||
func (s *cloudStack) Watch(ctx context.Context, op backend.UpdateOperation, paths []string) result.Result {
|
||||
return backend.WatchStack(ctx, s, op, paths)
|
||||
}
|
||||
|
||||
func (s *cloudStack) GetLogs(ctx context.Context, cfg backend.StackConfiguration,
|
||||
|
|
|
@ -66,7 +66,7 @@ type MockBackend struct {
|
|||
DestroyF func(context.Context, Stack,
|
||||
UpdateOperation) (engine.ResourceChanges, result.Result)
|
||||
WatchF func(context.Context, Stack,
|
||||
UpdateOperation) result.Result
|
||||
UpdateOperation, []string) result.Result
|
||||
GetLogsF func(context.Context, Stack, StackConfiguration,
|
||||
operations.LogQuery) ([]operations.LogEntry, error)
|
||||
}
|
||||
|
@ -221,10 +221,10 @@ func (be *MockBackend) Destroy(ctx context.Context, stack Stack,
|
|||
}
|
||||
|
||||
func (be *MockBackend) Watch(ctx context.Context, stack Stack,
|
||||
op UpdateOperation) result.Result {
|
||||
op UpdateOperation, paths []string) result.Result {
|
||||
|
||||
if be.WatchF != nil {
|
||||
return be.WatchF(ctx, stack, op)
|
||||
return be.WatchF(ctx, stack, op, paths)
|
||||
}
|
||||
panic("not implemented")
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ type MockStack struct {
|
|||
imports []deploy.Import) (engine.ResourceChanges, result.Result)
|
||||
RefreshF func(ctx context.Context, op UpdateOperation) (engine.ResourceChanges, result.Result)
|
||||
DestroyF func(ctx context.Context, op UpdateOperation) (engine.ResourceChanges, result.Result)
|
||||
WatchF func(ctx context.Context, op UpdateOperation) result.Result
|
||||
WatchF func(ctx context.Context, op UpdateOperation, paths []string) result.Result
|
||||
QueryF func(ctx context.Context, op UpdateOperation) result.Result
|
||||
RemoveF func(ctx context.Context, force bool) (bool, error)
|
||||
RenameF func(ctx context.Context, newName tokens.QName) (StackReference, error)
|
||||
|
@ -413,9 +413,9 @@ func (ms *MockStack) Destroy(ctx context.Context, op UpdateOperation) (engine.Re
|
|||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms *MockStack) Watch(ctx context.Context, op UpdateOperation) result.Result {
|
||||
func (ms *MockStack) Watch(ctx context.Context, op UpdateOperation, paths []string) result.Result {
|
||||
if ms.WatchF != nil {
|
||||
return ms.WatchF(ctx, op)
|
||||
return ms.WatchF(ctx, op, paths)
|
||||
}
|
||||
panic("not implemented")
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ type Stack interface {
|
|||
// Destroy this stack's resources.
|
||||
Destroy(ctx context.Context, op UpdateOperation) (engine.ResourceChanges, result.Result)
|
||||
// Watch this stack.
|
||||
Watch(ctx context.Context, op UpdateOperation) result.Result
|
||||
Watch(ctx context.Context, op UpdateOperation, paths []string) result.Result
|
||||
|
||||
// remove this stack.
|
||||
Remove(ctx context.Context, force bool) (bool, error)
|
||||
|
@ -103,8 +103,8 @@ func DestroyStack(ctx context.Context, s Stack, op UpdateOperation) (engine.Reso
|
|||
|
||||
// WatchStack watches the projects working directory for changes and automatically updates the
|
||||
// active stack.
|
||||
func WatchStack(ctx context.Context, s Stack, op UpdateOperation) result.Result {
|
||||
return s.Backend().Watch(ctx, s, op)
|
||||
func WatchStack(ctx context.Context, s Stack, op UpdateOperation, paths []string) result.Result {
|
||||
return s.Backend().Watch(ctx, s, op, paths)
|
||||
}
|
||||
|
||||
// GetLatestConfiguration returns the configuration for the most recent deployment of the stack.
|
||||
|
|
|
@ -35,7 +35,8 @@ import (
|
|||
|
||||
// Watch watches the project's working directory for changes and automatically updates the active
|
||||
// stack.
|
||||
func Watch(ctx context.Context, b Backend, stack Stack, op UpdateOperation, apply Applier) result.Result {
|
||||
func Watch(ctx context.Context, b Backend, stack Stack, op UpdateOperation,
|
||||
apply Applier, paths []string) result.Result {
|
||||
|
||||
opts := ApplierOptions{
|
||||
DryRun: false,
|
||||
|
@ -69,9 +70,21 @@ func Watch(ctx context.Context, b Backend, stack Stack, op UpdateOperation, appl
|
|||
}()
|
||||
|
||||
events := make(chan notify.EventInfo, 1)
|
||||
if err := notify.Watch(path.Join(op.Root, "..."), events, notify.All); err != nil {
|
||||
return result.FromError(err)
|
||||
|
||||
for _, p := range paths {
|
||||
// Provided paths can be both relative and absolute.
|
||||
watchPath := ""
|
||||
if path.IsAbs(p) {
|
||||
watchPath = path.Join(p, "...")
|
||||
} else {
|
||||
watchPath = path.Join(op.Root, p, "...")
|
||||
}
|
||||
|
||||
if err := notify.Watch(watchPath, events, notify.All); err != nil {
|
||||
return result.FromError(err)
|
||||
}
|
||||
}
|
||||
|
||||
defer notify.Stop(events)
|
||||
|
||||
fmt.Printf(op.Opts.Display.Color.Colorize(
|
||||
|
|
|
@ -35,6 +35,7 @@ func newWatchCmd() *cobra.Command {
|
|||
var execKind string
|
||||
var stack string
|
||||
var configArray []string
|
||||
var pathArray []string
|
||||
var configPath bool
|
||||
|
||||
// Flags for engine.UpdateOptions.
|
||||
|
@ -53,9 +54,9 @@ func newWatchCmd() *cobra.Command {
|
|||
Short: "[PREVIEW] Continuously update the resources in a stack",
|
||||
Long: "Continuously update the resources in a stack.\n" +
|
||||
"\n" +
|
||||
"This command watches the working directory for the current project and updates the active stack whenever\n" +
|
||||
"the project changes. In parallel, logs are collected for all resources in the stack and displayed along\n" +
|
||||
"with update progress.\n" +
|
||||
"This command watches the working directory or specified paths for the current project and updates\n" +
|
||||
"the active stack whenever the project changes. In parallel, logs are collected for all resources\n" +
|
||||
"in the stack and displayed along with update progress.\n" +
|
||||
"\n" +
|
||||
"The program to watch is loaded from the project in the current directory by default. Use the `-C` or\n" +
|
||||
"`--cwd` flag to use a different directory.",
|
||||
|
@ -131,7 +132,8 @@ func newWatchCmd() *cobra.Command {
|
|||
StackConfiguration: cfg,
|
||||
SecretsManager: sm,
|
||||
Scopes: cancellationScopes,
|
||||
})
|
||||
}, pathArray)
|
||||
|
||||
switch {
|
||||
case res != nil && res.Error() == context.Canceled:
|
||||
return result.FromError(errors.New("update cancelled"))
|
||||
|
@ -143,6 +145,10 @@ func newWatchCmd() *cobra.Command {
|
|||
}),
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().StringArrayVarP(
|
||||
&pathArray, "path", "", []string{""},
|
||||
"Specify one or more relative or absolute paths that need to be watched. "+
|
||||
"A path can point to a folder or a file. Defaults to working directory")
|
||||
cmd.PersistentFlags().BoolVarP(
|
||||
&debug, "debug", "d", false,
|
||||
"Print detailed debugging output during resource operations")
|
||||
|
|
Loading…
Reference in a new issue