當前位置: 首頁>>代碼示例>>Golang>>正文


Golang multistep.BasicStateBag類代碼示例

本文整理匯總了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
}
開發者ID:boumenot,項目名稱:packer,代碼行數:7,代碼來源:step_delete_resource_group_test.go

示例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")
}
開發者ID:Jacke,項目名稱:gethub,代碼行數:29,代碼來源:step_inject_configuration_test.go

示例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
}
開發者ID:pinterb,項目名稱:packer-azure,代碼行數:8,代碼來源:step_get_ip_address_test.go

示例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
}
開發者ID:boumenot,項目名稱:packer,代碼行數:8,代碼來源:step_create_resource_group_test.go

示例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
}
開發者ID:lvjp,項目名稱:packer,代碼行數:8,代碼來源:step_get_os_disk_test.go

示例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
}
開發者ID:rnaveiras,項目名稱:packer,代碼行數:8,代碼來源:step_validate_template_test.go

示例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
}
開發者ID:rnaveiras,項目名稱:packer,代碼行數:8,代碼來源:step_create_floppy_test.go

示例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
}
開發者ID:brkt,項目名稱:packer,代碼行數:11,代碼來源:step_create_image_test.go

示例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
}
開發者ID:JNPRAutomate,項目名稱:packer,代碼行數:9,代碼來源:step_test.go

示例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
}
開發者ID:c12simple,項目名稱:packer,代碼行數:9,代碼來源:step_connect_test.go

示例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
}
開發者ID:rnaveiras,項目名稱:packer,代碼行數:32,代碼來源:builder.go

示例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)
	}
}
開發者ID:rnaveiras,項目名稱:packer,代碼行數:12,代碼來源:step_test.go

示例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")
	}
}
開發者ID:sibysabu,項目名稱:gethub,代碼行數:13,代碼來源:step_check_path_test.go

示例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
}
開發者ID:rastasheep,項目名稱:packer-builder-docker-commit,代碼行數:11,代碼來源:step_test.go

示例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")
}
開發者ID:sibysabu,項目名稱:gethub,代碼行數:15,代碼來源:step_check_path_test.go


注:本文中的github.com/mitchellh/multistep.BasicStateBag類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。