本文整理匯總了Golang中github.com/dtan4/paus-frontend/store.Etcd類的典型用法代碼示例。如果您正苦於以下問題:Golang Etcd類的具體用法?Golang Etcd怎麽用?Golang Etcd使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Etcd類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Delete
func Delete(etcd *store.Etcd, username, appName, key string) error {
if err := etcd.Delete("/paus/users/" + username + "/apps/" + appName + "/build-args/" + key); err != nil {
return err
}
return nil
}
示例2: Create
func Create(etcd *store.Etcd, username, appName, key, value string) error {
if err := etcd.Set("/paus/users/"+username+"/apps/"+appName+"/build-args/"+key, value); err != nil {
return err
}
return nil
}
示例3: Update
func Update(etcd *store.Etcd, username, appName string, hc *Healthcheck) error {
b, err := json.Marshal(*hc)
if err != nil {
return err
}
if err := etcd.Set(etcdKey(username, appName), string(b)); err != nil {
return err
}
return nil
}
示例4: Get
func Get(etcd *store.Etcd, username, appName string) (*Healthcheck, error) {
val, err := etcd.Get(etcdKey(username, appName))
if err != nil {
return nil, err
}
var hc Healthcheck
if err := json.Unmarshal([]byte(val), &hc); err != nil {
return nil, err
}
return &hc, nil
}
示例5: List
func List(etcd *store.Etcd, username, appName string) (*map[string]string, error) {
envs, err := etcd.ListWithValues("/paus/users/"+username+"/apps/"+appName+"/build-args/", true)
if err != nil {
return nil, err
}
result := map[string]string{}
for key, value := range *envs {
envKey := strings.Replace(key, "/paus/users/"+username+"/apps/"+appName+"/build-args/", "", 1)
result[envKey] = value
}
return &result, nil
}
示例6: List
func List(etcd *store.Etcd, username string) ([]string, error) {
apps, err := etcd.List("/paus/users/"+username+"/apps/", true)
if err != nil {
return nil, err
}
result := make([]string, 0)
for _, app := range apps {
appName := strings.Replace(app, "/paus/users/"+username+"/apps/", "", 1)
result = append(result, appName)
}
return result, nil
}
示例7: Create
func Create(etcd *store.Etcd, username, appName string) error {
appKey := "/paus/users/" + username + "/apps/" + appName
if err := etcd.Mkdir(appKey); err != nil {
return err
}
for _, resource := range []string{"build-args", "envs", "deployments"} {
if err := etcd.Mkdir(appKey + "/" + resource); err != nil {
return err
}
}
hc := healthcheck.NewHealthcheck(defaultHealthcheckPath, defaultHealthcheckInterval, defaultHealthcheckMaxTry)
if err := healthcheck.Create(etcd, username, appName, hc); err != nil {
return err
}
return nil
}
示例8: URLs
func URLs(etcd *store.Etcd, uriScheme, baseDomain, username, appName string) ([]string, error) {
deployments, err := etcd.List("/paus/users/"+username+"/apps/"+appName+"/deployments/", true)
if err != nil {
return nil, err
}
result := make([]string, 0)
for _, deployment := range deployments {
revision, err := etcd.Get(deployment)
if err != nil {
return nil, err
}
identifier := username + "-" + appName + "-" + revision[0:8]
result = append(result, URL(uriScheme, identifier, baseDomain))
}
return result, nil
}
示例9: Create
func Create(etcd *store.Etcd, user *github.User) error {
username := *user.Login
if err := etcd.Mkdir("/paus/users/" + username); err != nil {
return err
}
if err := etcd.Set("/paus/users/"+username+"/avater_url", *user.AvatarURL); err != nil {
return err
}
if err := etcd.Mkdir("/paus/users/" + username + "/apps"); err != nil {
return err
}
return nil
}
示例10: RegisterAccessToken
func RegisterAccessToken(etcd *store.Etcd, username, accessToken string) error {
return etcd.Set("/paus/sessions/"+accessToken, username)
}
示例11: GetLoginUser
func GetLoginUser(etcd *store.Etcd, accessToken string) string {
username, _ := etcd.Get("/paus/sessions/" + accessToken)
return username
}
示例12: GetAvaterURL
func GetAvaterURL(etcd *store.Etcd, username string) string {
avaterURL, _ := etcd.Get("/paus/users/" + username + "/avater_url")
return avaterURL
}
示例13: Exists
func Exists(etcd *store.Etcd, username string) bool {
return etcd.HasKey("/paus/users/" + username)
}