本文整理匯總了Golang中github.com/mitchellh/multistep.BasicStateBag類的典型用法代碼示例。如果您正苦於以下問題:Golang BasicStateBag類的具體用法?Golang BasicStateBag怎麽用?Golang BasicStateBag使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了BasicStateBag類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DeleteTestStateBagStepDeleteResourceGroup
func DeleteTestStateBagStepDeleteResourceGroup() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put(constants.ArmResourceGroupName, "Unit Test: ResourceGroupName")
stateBag.Put(constants.ArmIsResourceGroupCreated, "Unit Test: IsResourceGroupCreated")
return stateBag
}
示例2: TestStepInjectConfiguration
func TestStepInjectConfiguration(t *testing.T) {
env := new(multistep.BasicStateBag)
os.Mkdir("tmp", 0777)
env.Put("config_path", "tmp/")
conf := config.NewDefault()
// Create the configuration file sections and items
conf.AddSection("gethub")
conf.AddSection("github")
conf.AddSection("ignores")
conf.AddOption("gethub", "path", "tmp")
conf.AddOption("github", "username", "foo")
conf.AddOption("github", "token", "bar")
conf.AddOption("ignores", "repo", "facebook")
conf.AddOption("ignores", "owner", "pearkes")
conf.WriteFile("tmp/.gethubconfig", 0644, "")
step := &StepInjectConfiguration{}
results := step.Run(env)
if results != multistep.ActionContinue {
t.Fatal("step did not return ActionContinue")
}
os.RemoveAll("tmp")
}
示例3: createTestStateBagStepGetIPAddress
func createTestStateBagStepGetIPAddress() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put(constants.ArmPublicIPAddressName, "Unit Test: PublicIPAddressName")
stateBag.Put(constants.ArmResourceGroupName, "Unit Test: ResourceGroupName")
return stateBag
}
示例4: createTestStateBagStepCreateResourceGroup
func createTestStateBagStepCreateResourceGroup() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put(constants.ArmLocation, "Unit Test: Location")
stateBag.Put(constants.ArmResourceGroupName, "Unit Test: ResourceGroupName")
return stateBag
}
示例5: createTestStateBagStepGetOSDisk
func createTestStateBagStepGetOSDisk() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put(constants.ArmComputeName, "Unit Test: ComputeName")
stateBag.Put(constants.ArmResourceGroupName, "Unit Test: ResourceGroupName")
return stateBag
}
示例6: createTestStateBagStepValidateTemplate
func createTestStateBagStepValidateTemplate() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put(constants.ArmDeploymentName, "Unit Test: DeploymentName")
stateBag.Put(constants.ArmResourceGroupName, "Unit Test: ResourceGroupName")
return stateBag
}
示例7: testStepCreateFloppyState
func testStepCreateFloppyState(t *testing.T) multistep.StateBag {
state := new(multistep.BasicStateBag)
state.Put("ui", &packer.BasicUi{
Reader: new(bytes.Buffer),
Writer: new(bytes.Buffer),
})
return state
}
示例8: getTestState
// getTestState is a utility function that sets up a BasicStateBag with a
// BasicUi
func getTestState() *multistep.BasicStateBag {
state := new(multistep.BasicStateBag)
state.Put("ui", &packer.BasicUi{
Reader: new(bytes.Buffer),
Writer: new(bytes.Buffer),
})
return state
}
示例9: testState
func testState(t *testing.T) multistep.StateBag {
state := new(multistep.BasicStateBag)
state.Put("driver", new(vmwcommon.DriverMock))
state.Put("ui", &packer.BasicUi{
Reader: new(bytes.Buffer),
Writer: new(bytes.Buffer),
})
return state
}
示例10: testState
func testState(t *testing.T) multistep.StateBag {
state := new(multistep.BasicStateBag)
state.Put("hook", &packer.MockHook{})
state.Put("ui", &packer.BasicUi{
Reader: new(bytes.Buffer),
Writer: new(bytes.Buffer),
})
return state
}
示例11: Run
func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) {
steps := []multistep.Step{
&communicator.StepConnect{
Config: &b.config.CommConfig,
Host: CommHost(b.config.CommConfig.Host()),
SSHConfig: SSHConfig(
b.config.CommConfig.SSHUsername,
b.config.CommConfig.SSHPassword,
b.config.CommConfig.SSHPrivateKey),
},
&common.StepProvision{},
}
// Setup the state bag and initial state for the steps
state := new(multistep.BasicStateBag)
state.Put("config", b.config)
state.Put("hook", hook)
state.Put("ui", ui)
// Run!
b.runner = common.NewRunner(steps, b.config.PackerConfig, ui)
b.runner.Run(state)
// If there was an error, return that
if rawErr, ok := state.GetOk("error"); ok {
return nil, rawErr.(error)
}
// No errors, must've worked
artifact := &NullArtifact{}
return artifact, nil
}
示例12: TestProcessStepResultShouldContinueForNonErrors
func TestProcessStepResultShouldContinueForNonErrors(t *testing.T) {
stateBag := new(multistep.BasicStateBag)
code := processStepResult(nil, func(error) { t.Fatal("Should not be called!") }, stateBag)
if _, ok := stateBag.GetOk(constants.Error); ok {
t.Errorf("Error was nil, but was still in the state bag.")
}
if code != multistep.ActionContinue {
t.Errorf("Expected ActionContinue(%d), but got=%d", multistep.ActionContinue, code)
}
}
示例13: TestStepCheckPath_Not_Exists
func TestStepCheckPath_Not_Exists(t *testing.T) {
env := new(multistep.BasicStateBag)
env.Put("path", "foobar/")
step := &StepCheckPath{}
results := step.Run(env)
if results != multistep.ActionHalt {
t.Fatal("step did not return ActionContinue")
}
}
示例14: testState
func testState(t *testing.T) multistep.StateBag {
state := new(multistep.BasicStateBag)
state.Put("config", testConfigStruct(t))
state.Put("driver", &MockDriver{})
state.Put("hook", &packer.MockHook{})
state.Put("ui", &packer.BasicUi{
Reader: new(bytes.Buffer),
Writer: new(bytes.Buffer),
})
return state
}
示例15: TestStepCheckPath_Exists
func TestStepCheckPath_Exists(t *testing.T) {
env := new(multistep.BasicStateBag)
env.Put("path", "tmp/")
os.Mkdir("tmp", 0777)
step := &StepCheckPath{}
results := step.Run(env)
if results != multistep.ActionContinue {
t.Fatal("step did not return ActionContinue")
}
os.RemoveAll("tmp")
}