예제 #1
0
//Run - required command of a plugin (entry point)
func (plugin AutopilotPlugin) Run(cliConnection plugin.CliConnection, args []string) {

	var err error
	plugin.appRepo = application_repo.NewApplicationRepo(cliConnection)

	if args[0] == "push-zdd" && len(args) == 1 {
		err = plugin.appRepo.PushApplication([]string{"push", "-h"})
		fatalIf(err)
		return
	}

	appName, argList := ParseArgs(args)
	plugin.appName = appName
	plugin.venerableAppName = appName + "-venerable"

	actions := rewind.Actions{
		Actions:              plugin.getActions(argList),
		RewindFailureMessage: "Oh no. Something's gone wrong. I've tried to roll back but you should check to see if everything is OK.",
	}

	err = actions.Execute()
	fatalIf(err)

	fmt.Printf("\nA new version of your application has successfully been pushed!\n\n")

	err = plugin.appRepo.ListApplications()
	fatalIf(err)
}
예제 #2
0
	"github.com/compozed/autopilot/rewind"
)

var _ = Describe("Rewind", func() {
	It("runs through all actions if they're all successful", func() {
		firstRun := false
		secondRun := false

		actions := rewind.Actions{
			Actions: []rewind.Action{
				{
					Forward: func() error {
						firstRun = true
						return nil
					},
				},
				{
					Forward: func() error {
						secondRun = true
						return nil
					},
				},
			},
		}

		err := actions.Execute()
		Ω(err).ShouldNot(HaveOccurred())

		Ω(firstRun).Should(BeTrue())
		Ω(secondRun).Should(BeTrue())
	})