本文整理匯總了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)
}
}