func (c *ConfigRepository) SetCLIVersion(v string) {
	c.CFCLIVersion = v
}
SetCLIVersion should only be used in testing
package coreconfig
import (
	"strings"
	"sync"
	"code.cloudfoundry.org/cli/cf/configuration"
	"code.cloudfoundry.org/cli/cf/models"
	"code.cloudfoundry.org/cli/version"
	"github.com/blang/semver"
)
type ConfigRepository struct {
	CFCLIVersion string
	data         *Data
	mutex        *sync.RWMutex
	initOnce     *sync.Once
	persistor    configuration.Persistor
	onError      func(error)
}
type CCInfo struct {
	APIVersion               string `json:"api_version"`
	AuthorizationEndpoint    string `json:"authorization_endpoint"`
	DopplerEndpoint          string `json:"doppler_logging_endpoint"`
	MinCLIVersion            string `json:"min_cli_version"`
	MinRecommendedCLIVersion string `json:"min_recommended_cli_version"`
	SSHOAuthClient           string `json:"app_ssh_oauth_client"`
	RoutingAPIEndpoint       string `json:"routing_endpoint"`
}
func NewRepositoryFromFilepath(filepath string, errorHandler func(error)) Repository {
	if errorHandler == nil {
		return nil
	}
	return NewRepositoryFromPersistor(configuration.NewDiskPersistor(filepath), errorHandler)
}
func NewRepositoryFromPersistor(persistor configuration.Persistor, errorHandler func(error)) Repository {
	data := NewData()
	if !persistor.Exists() {
		data.PluginRepos = append(data.PluginRepos, models.PluginRepo{
			Name: "CF-Community",
			URL:  "https://plugins.cloudfoundry.org",
		})
	}
	return &ConfigRepository{
		data:      data,
		mutex:     new(sync.RWMutex),
		initOnce:  new(sync.Once),
		persistor: persistor,
		onError:   errorHandler,
	}
}
type Reader interface {
	APIEndpoint() string
	APIVersion() string
	HasAPIEndpoint() bool
	AuthenticationEndpoint() string
	DopplerEndpoint() string
	UaaEndpoint() string
	RoutingAPIEndpoint() string
	AccessToken() string
	UAAOAuthClient() string
	UAAOAuthClientSecret() string
	SSHOAuthClient() string
	RefreshToken() string
	OrganizationFields() models.OrganizationFields
	HasOrganization() bool
	SpaceFields() models.SpaceFields
	HasSpace() bool
	Username() string
	UserGUID() string
	UserEmail() string
	IsLoggedIn() bool
	IsSSLDisabled() bool
	IsMinAPIVersion(semver.Version) bool
	IsMinCLIVersion(string) bool
	MinCLIVersion() string
	MinRecommendedCLIVersion() string
	CLIVersion() string
	AsyncTimeout() uint
	Trace() string
	ColorEnabled() string
	Locale() string
	PluginRepos() []models.PluginRepo
}
type ReadWriter interface {
	Reader
	ClearSession()
	SetAPIEndpoint(string)
	SetAPIVersion(string)
	SetMinCLIVersion(string)
	SetMinRecommendedCLIVersion(string)
	SetAuthenticationEndpoint(string)
	SetDopplerEndpoint(string)
	SetUaaEndpoint(string)
	SetRoutingAPIEndpoint(string)
	SetAccessToken(string)
	SetUAAOAuthClient(string)
	SetUAAOAuthClientSecret(string)
	SetSSHOAuthClient(string)
	SetRefreshToken(string)
	SetOrganizationFields(models.OrganizationFields)
	SetSpaceFields(models.SpaceFields)
	SetSSLDisabled(bool)
	SetAsyncTimeout(uint)
	SetTrace(string)
	SetColorEnabled(string)
	SetLocale(string)
	SetPluginRepo(models.PluginRepo)
	UnSetPluginRepo(int)
	SetCLIVersion(string)
}
type Repository interface {
	ReadWriter
	Close()
}
func (c *ConfigRepository) init() {
	c.initOnce.Do(func() {
		err := c.persistor.Load(c.data)
		if err != nil {
			c.onError(err)
		}
	})
}
func (c *ConfigRepository) read(cb func()) {
	c.mutex.RLock()
	defer c.mutex.RUnlock()
	c.init()
	cb()
}
func (c *ConfigRepository) write(cb func()) {
	c.mutex.Lock()
	defer c.mutex.Unlock()
	c.init()
	cb()
	err := c.persistor.Save(c.data)
	if err != nil {
		c.onError(err)
	}
}
func (c *ConfigRepository) Close() {
	c.read(func() {
	})
}
func (c *ConfigRepository) APIVersion() (apiVersion string) {
	c.read(func() {
		apiVersion = c.data.APIVersion
	})
	return
}
func (c *ConfigRepository) AuthenticationEndpoint() (authEndpoint string) {
	c.read(func() {
		authEndpoint = c.data.AuthorizationEndpoint
	})
	return
}
func (c *ConfigRepository) DopplerEndpoint() (dopplerEndpoint string) {
	c.read(func() {
		dopplerEndpoint = c.data.DopplerEndPoint
	})
	return
}
func (c *ConfigRepository) UaaEndpoint() (uaaEndpoint string) {
	c.read(func() {
		uaaEndpoint = c.data.UaaEndpoint
	})
	return
}
func (c *ConfigRepository) RoutingAPIEndpoint() (routingAPIEndpoint string) {
	c.read(func() {
		routingAPIEndpoint = c.data.RoutingAPIEndpoint
	})
	return
}
func (c *ConfigRepository) APIEndpoint() string {
	var apiEndpoint string
	c.read(func() {
		apiEndpoint = c.data.Target
	})
	apiEndpoint = strings.TrimRight(apiEndpoint, "/")
	return apiEndpoint
}
func (c *ConfigRepository) HasAPIEndpoint() (hasEndpoint bool) {
	c.read(func() {
		hasEndpoint = c.data.APIVersion != "" && c.data.Target != ""
	})
	return
}
func (c *ConfigRepository) AccessToken() (accessToken string) {
	c.read(func() {
		accessToken = c.data.AccessToken
	})
	return
}
func (c *ConfigRepository) UAAOAuthClient() (clientID string) {
	c.read(func() {
		clientID = c.data.UAAOAuthClient
	})
	return
}
func (c *ConfigRepository) UAAOAuthClientSecret() (clientID string) {
	c.read(func() {
		clientID = c.data.UAAOAuthClientSecret
	})
	return
}
func (c *ConfigRepository) SSHOAuthClient() (clientID string) {
	c.read(func() {
		clientID = c.data.SSHOAuthClient
	})
	return
}
func (c *ConfigRepository) RefreshToken() (refreshToken string) {
	c.read(func() {
		refreshToken = c.data.RefreshToken
	})
	return
}
func (c *ConfigRepository) OrganizationFields() (org models.OrganizationFields) {
	c.read(func() {
		org = c.data.OrganizationFields
	})
	return
}
func (c *ConfigRepository) SpaceFields() (space models.SpaceFields) {
	c.read(func() {
		space = c.data.SpaceFields
	})
	return
}
func (c *ConfigRepository) UserEmail() (email string) {
	c.read(func() {
		email = NewTokenInfo(c.data.AccessToken).Email
	})
	return
}
func (c *ConfigRepository) UserGUID() (guid string) {
	c.read(func() {
		guid = NewTokenInfo(c.data.AccessToken).UserGUID
	})
	return
}
func (c *ConfigRepository) Username() (name string) {
	c.read(func() {
		name = NewTokenInfo(c.data.AccessToken).Username
	})
	return
}
func (c *ConfigRepository) IsLoggedIn() (loggedIn bool) {
	c.read(func() {
		loggedIn = c.data.AccessToken != ""
	})
	return
}
func (c *ConfigRepository) HasOrganization() (hasOrg bool) {
	c.read(func() {
		hasOrg = c.data.OrganizationFields.GUID != "" && c.data.OrganizationFields.Name != ""
	})
	return
}
func (c *ConfigRepository) HasSpace() (hasSpace bool) {
	c.read(func() {
		hasSpace = c.data.SpaceFields.GUID != "" && c.data.SpaceFields.Name != ""
	})
	return
}
func (c *ConfigRepository) IsSSLDisabled() (isSSLDisabled bool) {
	c.read(func() {
		isSSLDisabled = c.data.SSLDisabled
	})
	return
}