示例#1
0
文件: api.go 项目: jameinel/core
// apiInfoConnect looks for endpoint on the given environment and
// tries to connect to it, sending the result on the returned channel.
func apiInfoConnect(store configstore.Storage, info configstore.EnvironInfo, apiOpen apiOpenFunc, stop <-chan struct{}) (apiState, error) {
	endpoint := info.APIEndpoint()
	if info == nil || len(endpoint.Addresses) == 0 {
		return nil, &infoConnectError{fmt.Errorf("no cached addresses")}
	}
	logger.Infof("connecting to API addresses: %v", endpoint.Addresses)
	apiInfo := &api.Info{
		Addrs:    endpoint.Addresses,
		CACert:   endpoint.CACert,
		Tag:      names.UserTag(info.APICredentials().User),
		Password: info.APICredentials().Password,
	}
	st, err := apiOpen(apiInfo, api.DefaultDialOpts())
	if err != nil {
		return nil, &infoConnectError{err}
	}
	return st, nil
}
示例#2
0
文件: user.go 项目: jameinel/core
// Tag returns the Tag for
// the user ("user-$username")
func (u *User) Tag() string {
	return names.UserTag(u.doc.Name)
}
示例#3
0
func (s *userSuite) TestUserTag(c *gc.C) {
	c.Assert(names.UserTag("admin"), gc.Equals, "user-admin")
}