github.com/DaAlbrecht/cf-cli@v0.0.0-20231128151943-1fe19bb400b9/util/configv3/dynamic_user_config.go (about)

     1  package configv3
     2  
     3  type DynamicUserConfig struct {
     4  	ConfigFile           *JSONConfig
     5  	DefaultUserConfig    UserConfig
     6  	KubernetesUserConfig UserConfig
     7  }
     8  
     9  func (config DynamicUserConfig) CurrentUser() (User, error) {
    10  	return config.pickConfig().CurrentUser()
    11  }
    12  
    13  func (config DynamicUserConfig) CurrentUserName() (string, error) {
    14  	return config.pickConfig().CurrentUserName()
    15  }
    16  
    17  func (config DynamicUserConfig) pickConfig() UserConfig {
    18  	if config.ConfigFile.CFOnK8s.Enabled {
    19  		return config.KubernetesUserConfig
    20  	}
    21  	return config.DefaultUserConfig
    22  }