当前位置: 首页>>代码示例>>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;未经允许,请勿转载。