func (s *StepCaptureImage) Run(state multistep.StateBag) multistep.StepAction { s.say("Capturing image ...") var computeName = state.Get(constants.ArmComputeName).(string) var resourceGroupName = state.Get(constants.ArmResourceGroupName).(string) var parameters = state.Get(constants.ArmVirtualMachineCaptureParameters).(*compute.VirtualMachineCaptureParameters) s.say(fmt.Sprintf(" -> ResourceGroupName : '%s'", resourceGroupName)) s.say(fmt.Sprintf(" -> ComputeName : '%s'", computeName)) result := common.StartInterruptibleTask( func() bool { return common.IsStateCancelled(state) }, func(cancelCh <-chan struct{}) error { return s.capture(resourceGroupName, computeName, parameters, cancelCh) }) // HACK(chrboum): I do not like this. The capture method should be returning this value // instead having to pass in another lambda. I'm in this pickle because I am using // common.StartInterruptibleTask which is not parametric, and only returns a type of error. // I could change it to interface{}, but I do not like that solution either. // // Having to resort to capturing the template via an inspector is hack, and once I can // resolve that I can cleanup this code too. See the comments in azure_client.go for more // details. template := s.get(s.client) state.Put(constants.ArmCaptureTemplate, template) return processInterruptibleResult(result, s.error, state) }
func (s *StepDeleteResourceGroup) Run(state multistep.StateBag) multistep.StepAction { s.say("Deleting resource group ...") var resourceGroupName = state.Get(constants.ArmResourceGroupName).(string) s.say(fmt.Sprintf(" -> ResourceGroupName : '%s'", resourceGroupName)) result := common.StartInterruptibleTask( func() bool { return common.IsStateCancelled(state) }, func(cancelCh <-chan struct{}) error { return s.delete(resourceGroupName, cancelCh) }) stepAction := processInterruptibleResult(result, s.error, state) state.Put(constants.ArmIsResourceGroupCreated, false) return stepAction }
func (s *StepPowerOffCompute) Run(state multistep.StateBag) multistep.StepAction { s.say("Powering off machine ...") var resourceGroupName = state.Get(constants.ArmResourceGroupName).(string) var computeName = state.Get(constants.ArmComputeName).(string) s.say(fmt.Sprintf(" -> ResourceGroupName : '%s'", resourceGroupName)) s.say(fmt.Sprintf(" -> ComputeName : '%s'", computeName)) result := common.StartInterruptibleTask( func() bool { return common.IsStateCancelled(state) }, func(cancelCh <-chan struct{}) error { return s.powerOff(resourceGroupName, computeName, cancelCh) }) return processInterruptibleResult(result, s.error, state) }
func (s *StepDeployTemplate) Run(state multistep.StateBag) multistep.StepAction { s.say("Deploying deployment template ...") var resourceGroupName = state.Get(constants.ArmResourceGroupName).(string) var deploymentName = state.Get(constants.ArmDeploymentName).(string) s.say(fmt.Sprintf(" -> ResourceGroupName : '%s'", resourceGroupName)) s.say(fmt.Sprintf(" -> DeploymentName : '%s'", deploymentName)) result := common.StartInterruptibleTask( func() bool { return common.IsStateCancelled(state) }, func(cancelCh <-chan struct{}) error { return s.deploy(resourceGroupName, deploymentName, cancelCh) }, ) return processInterruptibleResult(result, s.error, state) }