Skip to content

Instantly share code, notes, and snippets.

@EvanBoyle
Created December 28, 2020 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvanBoyle/f5e7c77f94851238d93efbefba1debfc to your computer and use it in GitHub Desktop.
Save EvanBoyle/f5e7c77f94851238d93efbefba1debfc to your computer and use it in GitHub Desktop.
func reset(ctx context.Context, s auto.Stack){
args.Output.Write([]byte("canceling any active updates...\n"))
// we ignore the error on a cancel as it errors if there is no update running...
_ = s.Cancel(ctx)
args.Output.Write([]byte("removing any pending operations...\n"))
exp, err := s.Workspace().ExportStack(ctx, s.Name())
if err != nil {
return errors.Wrap(err, "failed to reset stack, could not export stack")
}
err = s.Workspace().ImportStack(ctx, s.Name(), exp)
if err != nil {
return errors.Wrap(err, "failed to reset stack, could not import stack")
}
args.Output.Write([]byte("refreshing stack...\n"))
_, err = s.Refresh(ctx, optrefresh.ProgressStreams(args.Output))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment