本文整理匯總了Golang中github.com/tsuru/tsuru/provision.ExtensibleProvisioner.PlatformUpdate方法的典型用法代碼示例。如果您正苦於以下問題:Golang ExtensibleProvisioner.PlatformUpdate方法的具體用法?Golang ExtensibleProvisioner.PlatformUpdate怎麽用?Golang ExtensibleProvisioner.PlatformUpdate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tsuru/tsuru/provision.ExtensibleProvisioner
的用法示例。
在下文中一共展示了ExtensibleProvisioner.PlatformUpdate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PlatformUpdate
func PlatformUpdate(opts provision.PlatformOptions) error {
var (
provisioner provision.ExtensibleProvisioner
platform Platform
ok bool
)
if provisioner, ok = Provisioner.(provision.ExtensibleProvisioner); !ok {
return ErrProvisionerIsNotExtensible
}
if opts.Name == "" {
return ErrPlatformNameMissing
}
conn, err := db.Conn()
if err != nil {
return err
}
defer conn.Close()
err = conn.Platforms().Find(bson.M{"_id": opts.Name}).One(&platform)
if err != nil {
if err == mgo.ErrNotFound {
return ErrPlatformNotFound
}
return err
}
if opts.Args["dockerfile"] != "" || opts.Input != nil {
err = provisioner.PlatformUpdate(opts)
if err != nil {
return err
}
var apps []App
err = conn.Apps().Find(bson.M{"framework": opts.Name}).All(&apps)
if err != nil {
return err
}
for _, app := range apps {
app.SetUpdatePlatform(true)
}
}
if opts.Args["disabled"] != "" {
disableBool, err := strconv.ParseBool(opts.Args["disabled"])
if err != nil {
return err
}
err = conn.Platforms().Update(bson.M{"_id": opts.Name}, bson.M{"$set": bson.M{"disabled": disableBool}})
if err != nil {
return err
}
}
return nil
}
示例2: PlatformUpdate
func PlatformUpdate(name string, args map[string]string, w io.Writer) error {
var (
provisioner provision.ExtensibleProvisioner
platform Platform
ok bool
)
if provisioner, ok = Provisioner.(provision.ExtensibleProvisioner); !ok {
return errors.New("Provisioner is not extensible")
}
if name == "" {
return errors.New("Platform name is required.")
}
conn, err := db.Conn()
if err != nil {
return err
}
defer conn.Close()
err = conn.Platforms().Find(bson.M{"_id": name}).One(&platform)
if err != nil {
if err == mgo.ErrNotFound {
return errors.New("Platform doesn't exist.")
}
return err
}
if args["dockerfile"] != "" {
err = provisioner.PlatformUpdate(name, args, w)
if err != nil {
return err
}
var apps []App
err = conn.Apps().Find(bson.M{"framework": name}).All(&apps)
if err != nil {
return err
}
for _, app := range apps {
app.SetUpdatePlatform(true)
}
}
if args["disabled"] != "" {
disableBool, err := strconv.ParseBool(args["disabled"])
if err != nil {
return err
}
err = conn.Platforms().Update(bson.M{"_id": name}, bson.M{"$set": bson.M{"disabled": disableBool}})
if err != nil {
return err
}
}
return nil
}
示例3: PlatformUpdate
func PlatformUpdate(name string, args map[string]string, w io.Writer) error {
var (
provisioner provision.ExtensibleProvisioner
platform Platform
ok bool
)
if provisioner, ok = Provisioner.(provision.ExtensibleProvisioner); !ok {
return errors.New("Provisioner is not extensible")
}
if name == "" {
return errors.New("Platform name is required.")
}
conn, err := db.Conn()
if err != nil {
return err
}
err = conn.Platforms().Find(bson.M{"_id": name}).One(&platform)
if err != nil {
if err == mgo.ErrNotFound {
return errors.New("Platform doesn't exist.")
}
return err
}
err = provisioner.PlatformUpdate(name, args, w)
if err != nil {
return err
}
var apps []App
err = conn.Apps().Find(bson.M{"framework": name}).All(&apps)
if err != nil {
return err
}
for _, app := range apps {
app.SetUpdatePlatform(true)
}
return nil
}