watch

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Example (Watch_help)
package main

import (
	"os"

	"github.com/aws-cloudformation/rain/internal/cmd/watch"
)

func main() {
	os.Args = []string{
		os.Args[0],
		"--help",
	}

	watch.Cmd.Execute()
}
Output:

Repeatedly displays the status of a CloudFormation stack. Useful for watching the progress of a deployment started from outside of Rain.

Usage:
  watch <stack>

Flags:
  -h, --help   help for watch
  -w, --wait   Wait for changes to begin rather than refusing to watch an unchanging stack

Index

Examples

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:                   "watch <stack>",
	Short:                 "Display an updating view of a CloudFormation stack",
	Long:                  "Repeatedly displays the status of a CloudFormation stack. Useful for watching the progress of a deployment started from outside of Rain.",
	Args:                  cobra.ExactArgs(1),
	Annotations:           cmd.StackAnnotation,
	DisableFlagsInUseLine: true,
	Run: func(cmd *cobra.Command, args []string) {
		stackName := args[0]

		first := true
		for {
			if first {
				spinner.Push("Fetching stack status")
			}

			stack, err := cfn.GetStack(stackName)
			if err != nil {
				panic(ui.Errorf(err, "error watching stack '%s'", stackName))
			}

			if !ui.StackHasSettled(stack) {

				break
			}

			if !waitThenWatch {

				status, _ := ui.GetStackOutput(stack)
				fmt.Println(status)
				panic(errors.New("not watching unchanging stack"))
			}

			if first {
				spinner.Pop()
				spinner.Push("Waiting for stack to begin changing")
				first = false
			}

			time.Sleep(time.Second * 2)
		}

		spinner.Pop()

		status, messages := ui.WaitForStackToSettle(stackName)

		fmt.Println("Final stack status:", ui.ColouriseStatus(status))

		if len(messages) > 0 {
			fmt.Println(console.Yellow("Messages:"))
			for _, message := range messages {
				fmt.Printf("  - %s\n", message)
			}
		}
	},
}

Cmd is the watch command's entrypoint

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL