本文整理匯總了Golang中github.com/juju/juju/state.RelationUnit.Relation方法的典型用法代碼示例。如果您正苦於以下問題:Golang RelationUnit.Relation方法的具體用法?Golang RelationUnit.Relation怎麽用?Golang RelationUnit.Relation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/state.RelationUnit
的用法示例。
在下文中一共展示了RelationUnit.Relation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: checkRemoteUnit
func (u *UniterAPIV3) checkRemoteUnit(relUnit *state.RelationUnit, remoteUnitTag string) (string, error) {
// Make sure the unit is indeed remote.
if remoteUnitTag == u.auth.GetAuthTag().String() {
return "", common.ErrPerm
}
// Check remoteUnit is indeed related. Note that we don't want to actually get
// the *Unit, because it might have been removed; but its relation settings will
// persist until the relation itself has been removed (and must remain accessible
// because the local unit's view of reality may be time-shifted).
tag, err := names.ParseUnitTag(remoteUnitTag)
if err != nil {
return "", common.ErrPerm
}
remoteUnitName := tag.Id()
remoteServiceName, err := names.UnitApplication(remoteUnitName)
if err != nil {
return "", common.ErrPerm
}
rel := relUnit.Relation()
_, err = rel.RelatedEndpoints(remoteServiceName)
if err != nil {
return "", common.ErrPerm
}
return remoteUnitName, nil
}