本文整理汇总了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
}
示例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)
}
}
}
示例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
}
示例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)
}
}
示例5: mkdirEtcd
func mkdirEtcd(client *etcd.Client, path string) {
_, err := client.CreateDir(path, 0)
if err != nil {
log.Warn(err)
}
}