func connectionInfo(args NewAPIConnectionParams) (*api.Info, *jujuclient.ControllerDetails, error) {
	controller, err := args.Store.ControllerByName(args.ControllerName)
	if err != nil {
		return nil, nil, errors.Annotate(err, "cannot get controller details")
	}

	apiInfo := &api.Info{
		Addrs:          controller.APIEndpoints,
		CACert:         controller.CACert,
		ControllerUUID: controller.ControllerUUID,
	}
	if controller.Proxy != nil {
		apiInfo.Proxier = controller.Proxy.Proxier
	}
	if args.ModelUUID != "" {
		apiInfo.ModelTag = names.NewModelTag(args.ModelUUID)
	}
	if controller.PublicDNSName != "" {
		apiInfo.SNIHostName = controller.PublicDNSName
	}
	if args.AccountDetails == nil {
		apiInfo.SkipLogin = true
		return apiInfo, controller, nil
	}
	account := args.AccountDetails
	if account.User != "" {
		userTag := names.NewUserTag(account.User)
		if userTag.IsLocal() {
			apiInfo.Tag = userTag
		}
	}
	if args.AccountDetails.Password != "" {
		// If a password is available, we always use that.
		// If no password is recorded, we'll attempt to
		// authenticate using macaroons.
		apiInfo.Password = account.Password
	} else {
		// Optionally the account may have macaroons to use.
		apiInfo.Macaroons = account.Macaroons
	}
	return apiInfo, controller, nil
}
// connectionInfo returns connection information suitable for
// connecting to the controller and model specified in the given
// parameters. If there are no addresses known for the controller,
// it may return a *api.Info with no APIEndpoints, but all other
// information will be populated.
connectionInfo returns connection information suitable for
connecting to the controller and model specified in the given
parameters. If there are no addresses known for the controller,
it may return a *api.Info with no APIEndpoints, but all other
information will be populated.
// connectionInfo returns connection information suitable for // connecting to the controller and model specified in the given // parameters . If there are no addresses known for the controller // it may return a * api . Info with no APIEndpoints but all other // information will be populated .
func connectionInfo(args NewAPIConnectionParams) (*api.Info, *jujuclient.ControllerDetails, error) {
	controller, err := args.Store.ControllerByName(args.ControllerName)
	if err != nil {
		return nil, nil, errors.Annotate(err, "cannot get controller details")
	}
	apiInfo := &api.Info{
		Addrs:          controller.APIEndpoints,
		CACert:         controller.CACert,
		ControllerUUID: controller.ControllerUUID,
	}
	if controller.Proxy != nil {
		apiInfo.Proxier = controller.Proxy.Proxier
	}
	if args.ModelUUID != "" {
		apiInfo.ModelTag = names.NewModelTag(args.ModelUUID)
	}
	if controller.PublicDNSName != "" {
		apiInfo.SNIHostName = controller.PublicDNSName
	}
	if args.AccountDetails == nil {
		apiInfo.SkipLogin = true
		return apiInfo, controller, nil
	}
	account := args.AccountDetails
	if account.User != "" {
		userTag := names.NewUserTag(account.User)
		if userTag.IsLocal() {
			apiInfo.Tag = userTag
		}
	}
	if args.AccountDetails.Password != "" {
		apiInfo.Password = account.Password
	} else {
		apiInfo.Macaroons = account.Macaroons
	}
	return apiInfo, controller, nil
}
func connectionInfo ( args NewAPIConnectionParams ) ( * api . Info , * jujuclient . ControllerDetails , error ) { controller , err := args . Store . ControllerByName ( args . ControllerName ) if err != nil { return nil , nil , errors . Annotate ( err , " " ) } apiInfo := & api . Info { Addrs : controller . APIEndpoints , CACert : controller . CACert , ControllerUUID : controller . ControllerUUID , } if controller . Proxy != nil { apiInfo . Proxier = controller . Proxy . Proxier } if args . ModelUUID != " " { apiInfo . ModelTag = names . NewModelTag ( args . ModelUUID ) } if controller . PublicDNSName != " " { apiInfo . SNIHostName = controller . PublicDNSName } if args . AccountDetails == nil { apiInfo . SkipLogin = true return apiInfo , controller , nil } account := args . AccountDetails if account . User != " " { userTag := names . NewUserTag ( account . User ) if userTag . IsLocal ( ) { apiInfo . Tag = userTag } } if args . AccountDetails . Password != " " { apiInfo . Password = account . Password } else { apiInfo . Macaroons = account . Macaroons } return apiInfo , controller , nil }
connectionInfo returns connection information suitable for
connecting to the controller and model specified in the given
parameters.
connectionInfo returns connection information suitable for connecting to the controller and model specified in the given parameters .
// If a password is available, we always use that. // If no password is recorded, we'll attempt to // authenticate using macaroons. // Optionally the account may have macaroons to use.