本文整理汇总了Golang中github.com/juju/juju/apiserver/common.NoAddressSetError函数的典型用法代码示例。如果您正苦于以下问题:Golang NoAddressSetError函数的具体用法?Golang NoAddressSetError怎么用?Golang NoAddressSetError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NoAddressSetError函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PrivateAddress
// PrivateAddress returns the private address for each given unit, if set.
func (u *UniterAPIV3) PrivateAddress(args params.Entities) (params.StringResults, error) {
result := params.StringResults{
Results: make([]params.StringResult, len(args.Entities)),
}
canAccess, err := u.accessUnit()
if err != nil {
return params.StringResults{}, err
}
for i, entity := range args.Entities {
tag, err := names.ParseUnitTag(entity.Tag)
if err != nil {
result.Results[i].Error = common.ServerError(common.ErrPerm)
continue
}
err = common.ErrPerm
if canAccess(tag) {
var unit *state.Unit
unit, err = u.getUnit(tag)
if err == nil {
var address network.Address
address, err = unit.PrivateAddress()
if err == nil {
result.Results[i].Result = address.Value
} else if network.IsNoAddressError(err) {
err = common.NoAddressSetError(tag, "private")
}
}
}
result.Results[i].Error = common.ServerError(err)
}
return result, nil
}
示例2: PublicAddress
// PublicAddress returns the public address for each given unit, if set.
func (u *uniterBaseAPI) PublicAddress(args params.Entities) (params.StringResults, error) {
result := params.StringResults{
Results: make([]params.StringResult, len(args.Entities)),
}
canAccess, err := u.accessUnit()
if err != nil {
return params.StringResults{}, err
}
for i, entity := range args.Entities {
tag, err := names.ParseUnitTag(entity.Tag)
if err != nil {
result.Results[i].Error = common.ServerError(common.ErrPerm)
continue
}
err = common.ErrPerm
if canAccess(tag) {
var unit *state.Unit
unit, err = u.getUnit(tag)
if err == nil {
address, ok := unit.PublicAddress()
if ok {
result.Results[i].Result = address
} else {
err = common.NoAddressSetError(tag, "public")
}
}
}
result.Results[i].Error = common.ServerError(err)
}
return result, nil
}
示例3:
code: params.CodeDead,
helperFunc: params.IsCodeDead,
}, {
err: txn.ErrExcessiveContention,
code: params.CodeExcessiveContention,
helperFunc: params.IsCodeExcessiveContention,
}, {
err: state.ErrUnitHasSubordinates,
code: params.CodeUnitHasSubordinates,
helperFunc: params.IsCodeUnitHasSubordinates,
}, {
err: common.ErrBadId,
code: params.CodeNotFound,
helperFunc: params.IsCodeNotFound,
}, {
err: common.NoAddressSetError(names.NewUnitTag("mysql/0"), "public"),
code: params.CodeNoAddressSet,
helperFunc: params.IsCodeNoAddressSet,
}, {
err: common.ErrBadCreds,
code: params.CodeUnauthorized,
helperFunc: params.IsCodeUnauthorized,
}, {
err: common.ErrPerm,
code: params.CodeUnauthorized,
helperFunc: params.IsCodeUnauthorized,
}, {
err: common.ErrNotLoggedIn,
code: params.CodeUnauthorized,
helperFunc: params.IsCodeUnauthorized,
}, {