本文整理匯總了Golang中launchpad/net/juju-core/state.Unit.SetMongoPassword方法的典型用法代碼示例。如果您正苦於以下問題:Golang Unit.SetMongoPassword方法的具體用法?Golang Unit.SetMongoPassword怎麽用?Golang Unit.SetMongoPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類launchpad/net/juju-core/state.Unit
的用法示例。
在下文中一共展示了Unit.SetMongoPassword方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: deploy
// deploy will deploy the supplied unit with the deployer's manager. It will
// panic if it observes inconsistent internal state.
func (d *Deployer) deploy(unit *state.Unit) error {
unitName := unit.Name()
if d.deployed[unit.Name()] {
panic("must not re-deploy a deployed unit")
}
log.Printf("worker/deployer: deploying unit %q", unit)
initialPassword, err := trivial.RandomPassword()
if err != nil {
return err
}
if err := unit.SetMongoPassword(initialPassword); err != nil {
return err
}
if err := d.mgr.DeployUnit(unitName, initialPassword); err != nil {
return err
}
d.deployed[unitName] = true
return nil
}
示例2: deploy
// deploy will deploy the supplied unit with the deployer's manager. It will
// panic if it observes inconsistent internal state.
func (d *Deployer) deploy(unit *state.Unit) error {
unitName := unit.Name()
if d.deployed.Contains(unit.Name()) {
panic("must not re-deploy a deployed unit")
}
logger.Infof("deploying unit %q", unit)
initialPassword, err := utils.RandomPassword()
if err != nil {
return err
}
if err := unit.SetPassword(initialPassword); err != nil {
return fmt.Errorf("cannot set password for unit %q: %v", unit, err)
}
if err := unit.SetMongoPassword(initialPassword); err != nil {
return fmt.Errorf("cannot set mongo password for unit %q: %v", unit, err)
}
if err := d.ctx.DeployUnit(unitName, initialPassword); err != nil {
return err
}
d.deployed.Add(unitName)
return nil
}