本文整理汇总了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
}
开发者ID:bac,项目名称:juju,代码行数:33,代码来源:uniter.go
示例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
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:32,代码来源:uniter_base.go
示例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,
}, {
开发者ID:ktsakalozos,项目名称:juju,代码行数:31,代码来源:errors_test.go
注:本文中的github.com/juju/juju/apiserver/common.NoAddressSetError函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论