本文整理汇总了Golang中github.com/juju/juju/worker/uniter/runner/context.HookContext.PrivateAddress方法的典型用法代码示例。如果您正苦于以下问题:Golang HookContext.PrivateAddress方法的具体用法?Golang HookContext.PrivateAddress怎么用?Golang HookContext.PrivateAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/worker/uniter/runner/context.HookContext
的用法示例。
在下文中一共展示了HookContext.PrivateAddress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AssertCoreContext
func (s *HookContextSuite) AssertCoreContext(c *gc.C, ctx *context.HookContext) {
c.Assert(ctx.UnitName(), gc.Equals, "u/0")
c.Assert(context.ContextMachineTag(ctx), jc.DeepEquals, names.NewMachineTag("0"))
expect, expectErr := s.unit.PrivateAddress()
actual, actualErr := ctx.PrivateAddress()
c.Assert(actual, gc.Equals, expect.Value)
c.Assert(actualErr, jc.DeepEquals, expectErr)
expect, expectErr = s.unit.PublicAddress()
actual, actualErr = ctx.PublicAddress()
c.Assert(actual, gc.Equals, expect.Value)
c.Assert(actualErr, jc.DeepEquals, expectErr)
env, err := s.State.Environment()
c.Assert(err, jc.ErrorIsNil)
name, uuid := context.ContextEnvInfo(ctx)
c.Assert(name, gc.Equals, env.Name())
c.Assert(uuid, gc.Equals, env.UUID())
ids, err := ctx.RelationIds()
c.Assert(err, jc.ErrorIsNil)
c.Assert(ids, gc.HasLen, 2)
r, err := ctx.Relation(0)
c.Assert(err, jc.ErrorIsNil)
c.Assert(r.Name(), gc.Equals, "db")
c.Assert(r.FakeId(), gc.Equals, "db:0")
r, err = ctx.Relation(1)
c.Assert(err, jc.ErrorIsNil)
c.Assert(r.Name(), gc.Equals, "db")
c.Assert(r.FakeId(), gc.Equals, "db:1")
}