本文整理匯總了Golang中github.com/mitchellh/multistep.BasicStateBag.Put方法的典型用法代碼示例。如果您正苦於以下問題:Golang BasicStateBag.Put方法的具體用法?Golang BasicStateBag.Put怎麽用?Golang BasicStateBag.Put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mitchellh/multistep.BasicStateBag
的用法示例。
在下文中一共展示了BasicStateBag.Put方法的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: 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
}
示例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: 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
}
示例7: 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
}
示例8: PostProcess
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
// Only accepts input from the vagrant post-processor
if artifact.BuilderId() != "mitchellh.post-processor.vagrant" {
return nil, false, fmt.Errorf(
"Unknown artifact type, requires box from vagrant post-processor: %s", artifact.BuilderId())
}
// We assume that there is only one .box file to upload
if !strings.HasSuffix(artifact.Files()[0], ".box") {
return nil, false, fmt.Errorf(
"Unknown files in artifact from vagrant post-processor: %s", artifact.Files())
}
// create the HTTP client
p.client = VagrantCloudClient{}.New(p.config.VagrantCloudUrl, p.config.AccessToken)
// The name of the provider for vagrant cloud, and vagrant
providerName := providerFromBuilderName(artifact.Id())
// Set up the state
state := new(multistep.BasicStateBag)
state.Put("config", p.config)
state.Put("client", p.client)
state.Put("artifact", artifact)
state.Put("artifactFilePath", artifact.Files()[0])
state.Put("ui", ui)
state.Put("providerName", providerName)
// Build the steps
steps := []multistep.Step{
new(stepVerifyBox),
new(stepCreateVersion),
new(stepCreateProvider),
new(stepPrepareUpload),
new(stepUpload),
new(stepVerifyUpload),
new(stepReleaseVersion),
}
// Run the steps
if p.config.PackerDebug {
p.runner = &multistep.DebugRunner{
Steps: steps,
PauseFn: common.MultistepDebugFn(ui),
}
} else {
p.runner = &multistep.BasicRunner{Steps: steps}
}
p.runner.Run(state)
// If there was an error, return that
if rawErr, ok := state.GetOk("error"); ok {
return nil, false, rawErr.(error)
}
return NewArtifact(providerName, p.config.Tag), true, nil
}
示例9: 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
}
示例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: 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
}
示例12: 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")
}
}
示例13: TestStepCheckRepo_Ignore_Repo_Name
func TestStepCheckRepo_Ignore_Repo_Name(t *testing.T) {
env := new(multistep.BasicStateBag)
os.MkdirAll("tmp", 0777)
env.Put("path", "tmp")
env.Put("ignored_owners", []string{})
env.Put("ignored_repos", []string{"bootstrap"})
repo := Repo{FullName: "pearkes/bootstrap"}
env.Put("repo", repo)
step := &StepCheckRepo{}
results := step.Run(env)
state := env.Get("repo_state").(string)
if state != "ignore" {
t.Fatal("repo state does not match ignore")
}
if results != multistep.ActionContinue {
t.Fatal("step did not return ActionContinue")
}
os.RemoveAll("tmp")
}
示例14: 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")
}
示例15: Run
func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) {
driver := &DockerDriver{Tpl: b.config.tpl, Ui: ui}
if err := driver.Verify(); err != nil {
return nil, err
}
steps := []multistep.Step{
&StepTempDir{},
&StepPull{},
&StepRun{},
&StepProvision{},
}
if b.config.Commit {
steps = append(steps, new(StepCommit))
} else {
steps = append(steps, new(StepExport))
}
// 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)
// Setup the driver that will talk to Docker
state.Put("driver", driver)
// Run!
if b.config.PackerDebug {
b.runner = &multistep.DebugRunner{
Steps: steps,
PauseFn: common.MultistepDebugFn(ui),
}
} else {
b.runner = &multistep.BasicRunner{Steps: steps}
}
b.runner.Run(state)
// If there was an error, return that
if rawErr, ok := state.GetOk("error"); ok {
return nil, rawErr.(error)
}
var artifact packer.Artifact
// No errors, must've worked
if b.config.Commit {
artifact = &ImportArtifact{
IdValue: state.Get("image_id").(string),
BuilderIdValue: BuilderIdImport,
Driver: driver,
}
} else {
artifact = &ExportArtifact{path: b.config.ExportPath}
}
return artifact, nil
}