本文整理汇总了Golang中github.com/travis-ci/worker/config.ProviderConfig.Set方法的典型用法代码示例。如果您正苦于以下问题:Golang ProviderConfig.Set方法的具体用法?Golang ProviderConfig.Set怎么用?Golang ProviderConfig.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/travis-ci/worker/config.ProviderConfig
的用法示例。
在下文中一共展示了ProviderConfig.Set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: dockerTestSetup
func dockerTestSetup(t *testing.T, cfg *config.ProviderConfig) {
dockerTestMux = http.NewServeMux()
dockerTestServer = httptest.NewServer(dockerTestMux)
cfg.Set("ENDPOINT", dockerTestServer.URL)
provider, _ := newDockerProvider(cfg)
dockerTestProvider = provider.(*dockerProvider)
}
示例2: gceTestSetupSSH
func gceTestSetupSSH(t *testing.T, cfg *config.ProviderConfig) {
var (
td string
err error
)
if !cfg.IsSet("TEMP_DIR") {
td, err = ioutil.TempDir("", "travis-worker")
if err != nil {
t.Fatal(err)
}
cfg.Set("TEMP_DIR", td)
}
td = cfg.Get("TEMP_DIR")
keyPath := filepath.Join(td, "test_rsa")
pubKeyPath := filepath.Join(td, "test_rsa.pub")
err = ioutil.WriteFile(keyPath, []byte(gceTestSSHKey), 0644)
if err != nil {
t.Fatal(err)
}
err = ioutil.WriteFile(pubKeyPath, []byte(gceTestSSHPubKey), 0644)
if err != nil {
t.Fatal(err)
}
if !cfg.IsSet("SSH_KEY_PATH") {
cfg.Set("SSH_KEY_PATH", keyPath)
}
if !cfg.IsSet("SSH_PUB_KEY_PATH") {
cfg.Set("SSH_PUB_KEY_PATH", pubKeyPath)
}
if !cfg.IsSet("SSH_KEY_PASSPHRASE") {
cfg.Set("SSH_KEY_PASSPHRASE", gceTestSSHKeyPassphrase)
}
}
示例3: newGCEProvider
func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) {
var (
imageSelector image.Selector
err error
)
client, err := buildGoogleComputeService(cfg)
if err != nil {
return nil, err
}
if !cfg.IsSet("PROJECT_ID") {
return nil, fmt.Errorf("missing PROJECT_ID")
}
projectID := cfg.Get("PROJECT_ID")
if !cfg.IsSet("SSH_KEY_PATH") {
return nil, fmt.Errorf("missing SSH_KEY_PATH config key")
}
sshKeyBytes, err := ioutil.ReadFile(cfg.Get("SSH_KEY_PATH"))
if err != nil {
return nil, err
}
if !cfg.IsSet("SSH_PUB_KEY_PATH") {
return nil, fmt.Errorf("missing SSH_PUB_KEY_PATH config key")
}
sshPubKeyBytes, err := ioutil.ReadFile(cfg.Get("SSH_PUB_KEY_PATH"))
if err != nil {
return nil, err
}
block, _ := pem.Decode(sshKeyBytes)
if block == nil {
return nil, fmt.Errorf("ssh key does not contain a valid PEM block")
}
if !cfg.IsSet("SSH_KEY_PASSPHRASE") {
return nil, fmt.Errorf("missing SSH_KEY_PASSPHRASE config key")
}
der, err := x509.DecryptPEMBlock(block, []byte(cfg.Get("SSH_KEY_PASSPHRASE")))
if err != nil {
return nil, err
}
parsedKey, err := x509.ParsePKCS1PrivateKey(der)
if err != nil {
return nil, err
}
sshKeySigner, err := ssh.NewSignerFromKey(parsedKey)
if err != nil {
return nil, err
}
zoneName := defaultGCEZone
if cfg.IsSet("ZONE") {
zoneName = cfg.Get("ZONE")
}
cfg.Set("ZONE", zoneName)
mtName := defaultGCEMachineType
if cfg.IsSet("MACHINE_TYPE") {
mtName = cfg.Get("MACHINE_TYPE")
}
cfg.Set("MACHINE_TYPE", mtName)
nwName := defaultGCENetwork
if cfg.IsSet("NETWORK") {
nwName = cfg.Get("NETWORK")
}
cfg.Set("NETWORK", nwName)
diskSize := defaultGCEDiskSize
if cfg.IsSet("DISK_SIZE") {
ds, err := strconv.ParseInt(cfg.Get("DISK_SIZE"), 10, 64)
if err == nil {
diskSize = ds
}
}
bootPollSleep := defaultGCEBootPollSleep
if cfg.IsSet("BOOT_POLL_SLEEP") {
si, err := time.ParseDuration(cfg.Get("BOOT_POLL_SLEEP"))
if err != nil {
return nil, err
}
bootPollSleep = si
}
uploadRetries := defaultGCEUploadRetries
//.........这里部分代码省略.........
示例4: newGCEProvider
func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) {
var (
imageSelector image.Selector
err error
)
client, err := buildGoogleComputeService(cfg)
if err != nil {
return nil, err
}
if !cfg.IsSet("PROJECT_ID") {
return nil, fmt.Errorf("missing PROJECT_ID")
}
projectID := cfg.Get("PROJECT_ID")
imageProjectID := cfg.Get("PROJECT_ID")
if cfg.IsSet("IMAGE_PROJECT_ID") {
imageProjectID = cfg.Get("IMAGE_PROJECT_ID")
}
zoneName := defaultGCEZone
if cfg.IsSet("ZONE") {
zoneName = cfg.Get("ZONE")
}
cfg.Set("ZONE", zoneName)
mtName := defaultGCEMachineType
if cfg.IsSet("MACHINE_TYPE") {
mtName = cfg.Get("MACHINE_TYPE")
}
cfg.Set("MACHINE_TYPE", mtName)
premiumMTName := defaultGCEPremiumMachineType
if cfg.IsSet("PREMIUM_MACHINE_TYPE") {
premiumMTName = cfg.Get("PREMIUM_MACHINE_TYPE")
}
cfg.Set("PREMIUM_MACHINE_TYPE", premiumMTName)
nwName := defaultGCENetwork
if cfg.IsSet("NETWORK") {
nwName = cfg.Get("NETWORK")
}
cfg.Set("NETWORK", nwName)
diskSize := defaultGCEDiskSize
if cfg.IsSet("DISK_SIZE") {
ds, err := strconv.ParseInt(cfg.Get("DISK_SIZE"), 10, 64)
if err == nil {
diskSize = ds
}
}
bootPollSleep := defaultGCEBootPollSleep
if cfg.IsSet("BOOT_POLL_SLEEP") {
si, err := time.ParseDuration(cfg.Get("BOOT_POLL_SLEEP"))
if err != nil {
return nil, err
}
bootPollSleep = si
}
bootPrePollSleep := defaultGCEBootPrePollSleep
if cfg.IsSet("BOOT_PRE_POLL_SLEEP") {
si, err := time.ParseDuration(cfg.Get("BOOT_PRE_POLL_SLEEP"))
if err != nil {
return nil, err
}
bootPrePollSleep = si
}
stopPollSleep := defaultGCEStopPollSleep
if cfg.IsSet("STOP_POLL_SLEEP") {
si, err := time.ParseDuration(cfg.Get("STOP_POLL_SLEEP"))
if err != nil {
return nil, err
}
stopPollSleep = si
}
stopPrePollSleep := defaultGCEStopPrePollSleep
if cfg.IsSet("STOP_PRE_POLL_SLEEP") {
si, err := time.ParseDuration(cfg.Get("STOP_PRE_POLL_SLEEP"))
if err != nil {
return nil, err
}
stopPrePollSleep = si
}
skipStopPoll := false
if cfg.IsSet("SKIP_STOP_POLL") {
ssp, err := strconv.ParseBool(cfg.Get("SKIP_STOP_POLL"))
if err != nil {
return nil, err
}
//.........这里部分代码省略.........