本文整理汇总了Golang中github.com/juju/juju/core/description.Unit.Subordinates方法的典型用法代码示例。如果您正苦于以下问题:Golang Unit.Subordinates方法的具体用法?Golang Unit.Subordinates怎么用?Golang Unit.Subordinates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/core/description.Unit
的用法示例。
在下文中一共展示了Unit.Subordinates方法的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
}