本文整理匯總了Golang中github.com/juju/juju/core/description.Unit.Tools方法的典型用法代碼示例。如果您正苦於以下問題:Golang Unit.Tools方法的具體用法?Golang Unit.Tools怎麽用?Golang Unit.Tools使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/core/description.Unit
的用法示例。
在下文中一共展示了Unit.Tools方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: makeUnitDoc
func (i *importer) makeUnitDoc(s description.Service, u description.Unit) (*unitDoc, error) {
// NOTE: if we want to support units having different charms deployed
// than the service recomments and migrate that, then we should serialize
// the charm url for each unit rather than grabbing the services charm url.
// Currently the units charm url matching the service is a precondiation
// to migration.
charmUrl, err := charm.ParseURL(s.CharmURL())
if err != nil {
return nil, errors.Trace(err)
}
var subordinates []string
if subs := u.Subordinates(); len(subs) > 0 {
for _, s := range subs {
subordinates = append(subordinates, s.Id())
}
}
return &unitDoc{
Name: u.Name(),
Service: s.Name(),
Series: s.Series(),
CharmURL: charmUrl,
Principal: u.Principal().Id(),
Subordinates: subordinates,
// StorageAttachmentCount int `bson:"storageattachmentcount"`
MachineId: u.Machine().Id(),
Tools: i.makeTools(u.Tools()),
Life: Alive,
PasswordHash: u.PasswordHash(),
}, nil
}