本文整理汇总了Golang中github.com/juju/juju/api.Connection.ServerTag方法的典型用法代码示例。如果您正苦于以下问题:Golang Connection.ServerTag方法的具体用法?Golang Connection.ServerTag怎么用?Golang Connection.ServerTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/api.Connection
的用法示例。
在下文中一共展示了Connection.ServerTag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: cacheConnectionInfo
func (c *LoginCommand) cacheConnectionInfo(serverDetails envcmd.ServerFile, apiState api.Connection) (configstore.EnvironInfo, error) {
store, err := configstore.Default()
if err != nil {
return nil, errors.Trace(err)
}
serverInfo := store.CreateInfo(c.Name)
serverTag, err := apiState.ServerTag()
if err != nil {
return nil, errors.Wrap(err, errors.New("juju system too old to support login"))
}
connectedAddresses, err := network.ParseHostPorts(apiState.Addr())
if err != nil {
// Should never happen, since we've just connected with it.
return nil, errors.Annotatef(err, "invalid API address %q", apiState.Addr())
}
addressConnectedTo := connectedAddresses[0]
addrs, hosts, changed := juju.PrepareEndpointsForCaching(serverInfo, apiState.APIHostPorts(), addressConnectedTo)
if !changed {
logger.Infof("api addresses: %v", apiState.APIHostPorts())
logger.Infof("address connected to: %v", addressConnectedTo)
return nil, errors.New("no addresses returned from prepare for caching")
}
serverInfo.SetAPICredentials(
configstore.APICredentials{
User: serverDetails.Username,
Password: serverDetails.Password,
})
serverInfo.SetAPIEndpoint(configstore.APIEndpoint{
Addresses: addrs,
Hostnames: hosts,
CACert: serverDetails.CACert,
ServerUUID: serverTag.Id(),
})
if err = serverInfo.Write(); err != nil {
return nil, errors.Trace(err)
}
return serverInfo, nil
}