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


Golang Config.ReadBoolDefault方法代碼示例

本文整理匯總了Golang中github.com/hashicorp/nomad/client/config.Config.ReadBoolDefault方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.ReadBoolDefault方法的具體用法?Golang Config.ReadBoolDefault怎麽用?Golang Config.ReadBoolDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/hashicorp/nomad/client/config.Config的用法示例。


在下文中一共展示了Config.ReadBoolDefault方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Fingerprint

func (d *RawExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) {
	// Check that the user has explicitly enabled this executor.
	enabled := cfg.ReadBoolDefault(rawExecConfigOption, false)

	if enabled {
		d.logger.Printf("[WARN] driver.raw_exec: raw exec is enabled. Only enable if needed")
		node.Attributes["driver.raw_exec"] = "1"
		return true, nil
	}

	return false, nil
}
開發者ID:dgshep,項目名稱:nomad,代碼行數:12,代碼來源:raw_exec.go

示例2: Fingerprint

// Fingerprint fingerprints the lxc driver configuration
func (d *LxcDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) {
	enabled := cfg.ReadBoolDefault(lxcConfigOption, true)
	if !enabled && !cfg.DevMode {
		return false, nil
	}
	version := lxc.Version()
	if version == "" {
		return false, nil
	}
	node.Attributes["driver.lxc.version"] = version
	node.Attributes["driver.lxc"] = "1"
	return true, nil
}
開發者ID:zanella,項目名稱:nomad,代碼行數:14,代碼來源:lxc.go

示例3: Fingerprint

func (d *RawExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) {
	// Get the current status so that we can log any debug messages only if the
	// state changes
	_, currentlyEnabled := node.Attributes[rawExecDriverAttr]

	// Check that the user has explicitly enabled this executor.
	enabled := cfg.ReadBoolDefault(rawExecConfigOption, false)

	if enabled {
		if currentlyEnabled {
			d.logger.Printf("[WARN] driver.raw_exec: raw exec is enabled. Only enable if needed")
		}
		node.Attributes[rawExecDriverAttr] = "1"
		return true, nil
	}

	delete(node.Attributes, rawExecDriverAttr)
	return false, nil
}
開發者ID:iverberk,項目名稱:nomad,代碼行數:19,代碼來源:raw_exec.go

示例4: consulContext

func consulContext(clientConfig *config.Config, containerID string) *executor.ConsulContext {
	cfg := consul.ConsulConfig{
		Addr:      clientConfig.ReadDefault("consul.address", "127.0.0.1:8500"),
		Token:     clientConfig.Read("consul.token"),
		Auth:      clientConfig.Read("consul.auth"),
		EnableSSL: clientConfig.ReadBoolDefault("consul.ssl", false),
		VerifySSL: clientConfig.ReadBoolDefault("consul.verifyssl", true),
		CAFile:    clientConfig.Read("consul.tls_ca_file"),
		CertFile:  clientConfig.Read("consul.tls_cert_file"),
		KeyFile:   clientConfig.Read("consul.tls_key_file"),
	}
	return &executor.ConsulContext{
		ConsulConfig:   &cfg,
		ContainerID:    containerID,
		DockerEndpoint: clientConfig.Read("docker.endpoint"),
		TLSCa:          clientConfig.Read("docker.tls.ca"),
		TLSCert:        clientConfig.Read("docker.tls.cert"),
		TLSKey:         clientConfig.Read("docker.tls.key"),
	}
}
開發者ID:carriercomm,項目名稱:nomad,代碼行數:20,代碼來源:utils.go

示例5: templateRunner

// templateRunner returns a consul-template runner for the given templates and a
// lookup by destination to the template. If no templates are given, a nil
// template runner and lookup is returned.
func templateRunner(tmpls []*structs.Template, config *config.Config,
	vaultToken, taskDir string, taskEnv *env.TaskEnvironment) (
	*manager.Runner, map[string][]*structs.Template, error) {

	if len(tmpls) == 0 {
		return nil, nil, nil
	}

	runnerConfig, err := runnerConfig(config, vaultToken)
	if err != nil {
		return nil, nil, err
	}

	// Parse the templates
	allowAbs := config.ReadBoolDefault(hostSrcOption, true)
	ctmplMapping, err := parseTemplateConfigs(tmpls, taskDir, taskEnv, allowAbs)
	if err != nil {
		return nil, nil, err
	}

	// Set the config
	flat := make([]*ctconf.ConfigTemplate, 0, len(ctmplMapping))
	for ctmpl := range ctmplMapping {
		local := ctmpl
		flat = append(flat, &local)
	}
	runnerConfig.ConfigTemplates = flat

	runner, err := manager.NewRunner(runnerConfig, false, false)
	if err != nil {
		return nil, nil, err
	}

	// Build the lookup
	idMap := runner.ConfigTemplateMapping()
	lookup := make(map[string][]*structs.Template, len(idMap))
	for id, ctmpls := range idMap {
		for _, ctmpl := range ctmpls {
			templates := lookup[id]
			templates = append(templates, ctmplMapping[ctmpl])
			lookup[id] = templates
		}
	}

	return runner, lookup, nil
}
開發者ID:zanella,項目名稱:nomad,代碼行數:49,代碼來源:consul_template.go


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