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


Golang Client.CreateDir方法代碼示例

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


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

示例1: YAMLtoETCD

// parseYAML parses the config.yml file and returns the appropriate structs and strings.
func YAMLtoETCD(client *etcd.Client) (c goship.Config, err error) {
	config, err := yaml.ReadFile(*ConfigFile)
	if err != nil {
		return c, err
	}
	log.Printf("Setting project root => /projects")
	client.CreateDir("/projects", 0)
	configRoot, _ := config.Root.(yaml.Map)
	projects, _ := configRoot["projects"].(yaml.List)
	for _, p := range projects {
		for k, v := range p.(yaml.Map) {

			projectPath := "/projects/" + k + "/"

			log.Printf("Setting project => %s \n", projectPath)
			client.CreateDir(projectPath, 0)

			name := getYAMLString(v, "project_name")
			setETCD(client, projectPath+"project_name", name)

			repoOwner := getYAMLString(v, "repo_owner")
			setETCD(client, projectPath+"repo_owner", repoOwner)

			repoName := getYAMLString(v, "repo_name")
			setETCD(client, projectPath+"repo_name", repoName)

			for _, v := range v.(yaml.Map)["environments"].(yaml.List) {
				YAMLtoETCDEnvironment(v, client, projectPath)
			}

		}
	}

	pivProject, _ := config.Get("pivotal_project")
	setETCD(client, "pivotal_project", pivProject)

	pivToken, _ := config.Get("pivotal_token")
	setETCD(client, "pivotal_token", pivToken)

	deployUser, _ := config.Get("deploy_user")
	setETCD(client, "deploy_user", deployUser)

	goshipHost, _ := config.Get("goship_host")
	setETCD(client, "goship_host", goshipHost)

	notify, _ := config.Get("notify")
	setETCD(client, "notify", notify)

	return c, err
}
開發者ID:gnomix,項目名稱:goship,代碼行數:51,代碼來源:convert.go

示例2: YAMLtoETCDEnvironment

// parseYAMLEnvironment populates an Environment given a yaml.Node and returns the Environment.
func YAMLtoETCDEnvironment(m yaml.Node, client *etcd.Client, projPath string) {

	for k, v := range m.(yaml.Map) {
		projPath = projPath + "environments/" + k + "/"

		log.Printf("Setting env name=> %s \n", projPath)
		client.CreateDir(projPath, 0)

		branch := getYAMLString(v, "branch")
		setETCD(client, projPath+"branch", branch)

		repoPath := getYAMLString(v, "repo_path")
		setETCD(client, projPath+"repo_path", repoPath)

		deploy := getYAMLString(v, "deploy")
		setETCD(client, projPath+"deploy", deploy)

		projPath = projPath + "hosts/"
		log.Printf("Creating Host Directory => %s \n", projPath+"hosts/")
		client.CreateDir(projPath, 0)

		for _, host := range v.(yaml.Map)["hosts"].(yaml.List) {
			h := goship.Host{URI: host.(yaml.Scalar).String()}
			log.Printf("Setting Hosts => %s \n", projPath+h.URI)
			client.CreateDir(projPath+h.URI, 0)
		}
	}
}
開發者ID:gnomix,項目名稱:goship,代碼行數:29,代碼來源:convert.go

示例3: NewEtcdEphemeral

// NewEtcdEphemeral creates a etcd implementation of ephemeral
// TODO: add option for user to support:
//       1. fatal after retrying set heartbeat many times
func NewEtcdEphemeral(client *etcd.Client, options ...func(*EtcdEphemeral) error) (*EtcdEphemeral, error) {
	impl := &EtcdEphemeral{
		client:       client,
		ctr:          dummyStat{},
		ephemeralTTL: DefaultEphemeralTTL,
		listCancel:   make(map[context.Context]func()),
	}

	// Set options.
	for _, option := range options {
		if err := option(impl); err != nil {
			return nil, err
		}
	}

	// ensure ephemeral dir exists, the error is not important
	if _, err := client.CreateDir(WatcherDir, 0); err != nil &&
		translateEtcdErr(err) != ErrPathExists {
		return nil, err
	}

	return impl, nil
}
開發者ID:csigo,項目名稱:ephemeral,代碼行數:26,代碼來源:etcd.go

示例4: mkdirEtcd

func mkdirEtcd(client *etcd.Client, path string) {
	_, err := client.CreateDir(path, 0)
	if err != nil && !strings.Contains(err.Error(), "Key already exists") {
		log.Warn(err)
	}
}
開發者ID:CloudSide,項目名稱:deis,代碼行數:6,代碼來源:boot.go

示例5: mkdirEtcd

func mkdirEtcd(client *etcd.Client, path string) {
	_, err := client.CreateDir(path, 0)
	if err != nil {
		log.Warn(err)
	}
}
開發者ID:pombredanne,項目名稱:deo,代碼行數:6,代碼來源:boot.go


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