add expectnochanges to stack.refresh

This commit is contained in:
evanboyle 2020-08-28 19:17:46 -07:00
parent 09964d2031
commit 5458e2f685
2 changed files with 12 additions and 0 deletions

View file

@ -24,6 +24,13 @@ func Parallel(n int) Option {
}) })
} }
// ExpectNoChanges will cause the preview to return an error if any changes occur
func ExpectNoChanges() Option {
return optionFunc(func(opts *Options) {
opts.ExpectNoChanges = true
})
}
// Message (optional) to associate with the refresh operation // Message (optional) to associate with the refresh operation
func Message(message string) Option { func Message(message string) Option {
return optionFunc(func(opts *Options) { return optionFunc(func(opts *Options) {
@ -52,6 +59,8 @@ type Options struct {
Parallel int Parallel int
// Message (optional) to associate with the refresh operation // Message (optional) to associate with the refresh operation
Message string Message string
// Return an error if any changes occur during this preview
ExpectNoChanges bool
// Specify an exclusive list of resource URNs to re // Specify an exclusive list of resource URNs to re
Target []string Target []string
} }

View file

@ -320,6 +320,9 @@ func (s *Stack) Refresh(ctx context.Context, opts ...optrefresh.Option) (Refresh
if refreshOpts.Message != "" { if refreshOpts.Message != "" {
args = append(args, fmt.Sprintf("--message=%q", refreshOpts.Message)) args = append(args, fmt.Sprintf("--message=%q", refreshOpts.Message))
} }
if refreshOpts.ExpectNoChanges {
args = append(args, "--expect-no-changes")
}
for _, tURN := range refreshOpts.Target { for _, tURN := range refreshOpts.Target {
args = append(args, "--target %s", tURN) args = append(args, "--target %s", tURN)
} }