core_config

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 18 Imported by: 11

Documentation

Overview

Package core_config provides functions to load core configuration. The package is for internal only.

Index

Constants

View Source
const (
	SubjectTypeServiceID      = "ServiceId"
	SubjectTypeTrustedProfile = "Profile"
)

Variables

This section is empty.

Functions

func DecodeAccessToken added in v0.8.1

func DecodeAccessToken(token string) (tokenJSON []byte, err error)

DecodeAccessToken will decode an access token string into a raw JSON. The encoded string is expected to be in three parts separated by a period. This method does not validate the contents of the parts

Types

type AccountsInfo

type AccountsInfo struct {
	AccountID    string `json:"bss"`
	IMSAccountID string `json:"ims"`
	Valid        bool   `json:"valid"`
}

type Authn added in v0.6.8

type Authn struct {
	Subject   string `json:"sub"`
	IAMID     string `json:"iam_id"`
	Name      string `json:"name"`
	Firstname string `json:"given_name"`
	Lastname  string `json:"family_name"`
	Email     string `json:"email"`
}

type BXConfigData

type BXConfigData struct {
	APIEndpoint                 string
	IsPrivate                   bool
	IsAccessFromVPC             bool
	ConsoleEndpoint             string
	ConsolePrivateEndpoint      string
	ConsolePrivateVPCEndpoint   string
	CloudType                   string
	CloudName                   string
	CRIType                     string
	Region                      string
	RegionID                    string
	IAMEndpoint                 string
	IAMPrivateEndpoint          string
	IAMPrivateVPCEndpoint       string
	IAMToken                    string
	IAMRefreshToken             string
	IsLoggedInAsCRI             bool
	Account                     models.Account
	Profile                     models.Profile
	ResourceGroup               models.ResourceGroup
	LoginAt                     time.Time
	CFEETargeted                bool
	CFEEEnvID                   string
	PluginRepos                 []models.PluginRepo
	SSLDisabled                 bool
	Locale                      string
	MessageOfTheDayTime         int64
	LastSessionUpdateTime       int64
	Trace                       string
	ColorEnabled                string
	HTTPTimeout                 int
	CLIInfoEndpoint             string // overwrite the cli info endpoint
	CheckCLIVersionDisabled     bool
	UsageStatsDisabled          bool // deprecated: use UsageStatsEnabled
	UsageStatsEnabled           bool
	UsageStatsEnabledLastUpdate time.Time
	SDKVersion                  string
	UpdateCheckInterval         time.Duration
	UpdateRetryCheckInterval    time.Duration
	UpdateNotificationInterval  time.Duration
	// contains filtered or unexported fields
}

func NewBXConfigData

func NewBXConfigData() *BXConfigData

func (*BXConfigData) Marshal

func (data *BXConfigData) Marshal() ([]byte, error)

func (*BXConfigData) Unmarshal

func (data *BXConfigData) Unmarshal(bytes []byte) error

type CFConfig

type CFConfig interface {
	APIVersion() string
	APIEndpoint() string
	AsyncTimeout() uint
	ColorEnabled() string
	HasAPIEndpoint() bool
	AuthenticationEndpoint() string
	UAAEndpoint() string
	DopplerEndpoint() string
	RoutingAPIEndpoint() string
	SSHOAuthClient() string
	MinCFCLIVersion() string
	MinRecommendedCFCLIVersion() string
	Username() string
	UserGUID() string
	UserEmail() string
	Locale() string
	LoginAt() time.Time
	IsLoggedIn() bool
	SetLoginAt(loginAt time.Time)
	Trace() string
	UAAToken() string
	UAARefreshToken() string
	CurrentOrganization() models.OrganizationFields
	HasTargetedOrganization() bool
	CurrentSpace() models.SpaceFields
	HasTargetedSpace() bool

	UnsetAPI()
	SetAPIVersion(string)
	SetAPIEndpoint(string)
	SetAuthenticationEndpoint(string)
	SetDopplerEndpoint(string)
	SetUAAEndpoint(string)
	SetRoutingAPIEndpoint(string)
	SetSSHOAuthClient(string)
	SetMinCFCLIVersion(string)
	SetMinRecommendedCFCLIVersion(string)
	SetUAAToken(string)
	SetUAARefreshToken(string)
	SetOrganization(models.OrganizationFields)
	SetSpace(models.SpaceFields)
	ClearSession()
}

type CFConfigData

type CFConfigData struct {
	AccessToken              string
	APIVersion               string
	AsyncTimeout             uint
	AuthorizationEndpoint    string
	ColorEnabled             string
	ConfigVersion            int
	DopplerEndpoint          string
	Locale                   string
	LogCacheEndPoint         string
	MinCLIVersion            string
	MinRecommendedCLIVersion string
	OrganizationFields       models.OrganizationFields
	PluginRepos              []models.PluginRepo
	RefreshToken             string
	RoutingAPIEndpoint       string
	SpaceFields              models.SpaceFields
	SSHOAuthClient           string
	SSLDisabled              bool
	Target                   string
	Trace                    string
	UaaEndpoint              string
	LoginAt                  time.Time
	UAAGrantType             string
	UAAOAuthClient           string
	UAAOAuthClientSecret     string
	// contains filtered or unexported fields
}

func NewCFConfigData

func NewCFConfigData() *CFConfigData

func (*CFConfigData) Marshal

func (data *CFConfigData) Marshal() ([]byte, error)

func (*CFConfigData) Unmarshal

func (data *CFConfigData) Unmarshal(bytes []byte) error

type IAMTokenInfo

type IAMTokenInfo struct {
	IAMID       string       `json:"iam_id"`
	ID          string       `json:"id"`
	RealmID     string       `json:"realmid"`
	SessionID   string       `json:"session_id"`
	Identifier  string       `json:"identifier"`
	Firstname   string       `json:"given_name"`
	Lastname    string       `json:"family_name"`
	Fullname    string       `json:"name"`
	UserEmail   string       `json:"email"`
	Accounts    AccountsInfo `json:"account"`
	Subject     string       `json:"sub"`
	SubjectType string       `json:"sub_type"`
	Issuer      string       `json:"iss"`
	GrantType   string       `json:"grant_type"`
	Scope       string       `json:"scope"`
	Authn       Authn        `json:"authn"`
	Expiry      time.Time
	IssueAt     time.Time
}

func NewIAMTokenInfo

func NewIAMTokenInfo(token string) IAMTokenInfo

type ReadWriter

type ReadWriter interface {
	Repository
}

Deprecated

func NewCoreConfig

func NewCoreConfig(errHandler func(error)) ReadWriter

func NewCoreConfigFromPath

func NewCoreConfigFromPath(cfConfigPath string, bxConfigPath string, errHandler func(error)) ReadWriter

func NewCoreConfigFromPersistor

func NewCoreConfigFromPersistor(cfPersistor configuration.Persistor, bxPersistor configuration.Persistor, errHandler func(error)) ReadWriter

type Repository

type Repository interface {
	APIEndpoint() string
	HasAPIEndpoint() bool
	IsPrivateEndpointEnabled() bool
	IsAccessFromVPC() bool
	ConsoleEndpoints() models.Endpoints
	IAMEndpoint() string
	IAMEndpoints() models.Endpoints
	CloudName() string
	CloudType() string
	CurrentRegion() models.Region
	HasTargetedRegion() bool
	IAMToken() string
	IAMRefreshToken() string
	IsLoggedIn() bool
	IsLoggedInWithServiceID() bool
	IsLoggedInAsProfile() bool
	IsLoggedInAsCRI() bool
	UserEmail() string
	// UserDisplayText is the human readable ID for logged-in users which include non-human IDs
	UserDisplayText() string
	IAMID() string
	CurrentAccount() models.Account
	HasTargetedAccount() bool
	HasTargetedProfile() bool
	HasTargetedComputeResource() bool
	IMSAccountID() string
	CurrentProfile() models.Profile
	CurrentResourceGroup() models.ResourceGroup
	// CRIType returns the type of compute resource the user logged in as, if applicable. Valid values are `IKS`, `VPC`, or `OTHER`
	CRIType() string
	HasTargetedResourceGroup() bool
	PluginRepos() []models.PluginRepo
	PluginRepo(string) (models.PluginRepo, bool)
	IsSSLDisabled() bool
	HTTPTimeout() int
	CLIInfoEndpoint() string
	CheckCLIVersionDisabled() bool
	UpdateCheckInterval() time.Duration
	UpdateRetryCheckInterval() time.Duration
	UpdateNotificationInterval() time.Duration
	// VPCCRITokenURL() returns the value specified by the environment variable 'IBMCLOUD_CR_VPC_URL', if set.
	// Otherwise, the default VPC auth url specified by the constant `DefaultServerEndpoint` is returned
	VPCCRITokenURL() string

	// UsageSatsDisabled returns whether the usage statistics data collection is disabled or not
	// Deprecated: use UsageSatsEnabled instead. We change to disable usage statistics by default,
	// So this property will not be used anymore
	UsageStatsDisabled() bool
	// UsageSatsEnabled returns whether the usage statistics data collection is enabled or not
	UsageStatsEnabled() bool
	// UsageStatsEnabledLastUpdate returns last time when `UsageStatsEnabled` was updated
	UsageStatsEnabledLastUpdate() time.Time
	Locale() string
	LoginAt() time.Time
	Trace() string
	ColorEnabled() string
	SDKVersion() string

	UnsetAPI()
	RefreshIAMToken() (string, error)
	SetAPIEndpoint(string)
	SetPrivateEndpointEnabled(bool)
	SetAccessFromVPC(bool)
	SetConsoleEndpoints(models.Endpoints)
	SetIAMEndpoints(models.Endpoints)
	SetCloudType(string)
	SetCloudName(string)
	SetCRIType(string)
	SetIsLoggedInAsCRI(bool)
	SetRegion(models.Region)
	SetIAMToken(string)
	SetIAMRefreshToken(string)
	ClearSession()
	SetAccount(models.Account)
	SetProfile(models.Profile)
	SetResourceGroup(models.ResourceGroup)
	SetLoginAt(loginAt time.Time)
	SetCheckCLIVersionDisabled(bool)
	SetCLIInfoEndpoint(string)
	SetPluginRepo(models.PluginRepo)
	UnsetPluginRepo(string)
	SetSSLDisabled(bool)
	SetHTTPTimeout(int)
	// SetUsageSatsDisabled disable or enable usage statistics data collection
	// Deprecated: use SetUsageSatsEnabled instead
	SetUsageStatsDisabled(bool)
	// SetUsageSatsEnabled enable or disable usage statistics data collection
	SetUsageStatsEnabled(bool)
	SetUpdateCheckInterval(time.Duration)
	SetUpdateRetryCheckInterval(time.Duration)
	SetUpdateNotificationInterval(time.Duration)
	SetLocale(string)
	SetTrace(string)
	SetColorEnabled(string)

	CFConfig() CFConfig
	HasTargetedCF() bool
	HasTargetedCFEE() bool
	HasTargetedPublicCF() bool
	SetCFEETargeted(bool)
	CFEEEnvID() string
	SetCFEEEnvID(string)

	CheckMessageOfTheDay() bool
	SetMessageOfTheDayTime()

	SetLastSessionUpdateTime()
	LastSessionUpdateTime() (session int64)
}

type UAATokenInfo

type UAATokenInfo struct {
	Username string `json:"user_name"`
	Email    string `json:"email"`
	UserGUID string `json:"user_id"`
	Expiry   time.Time
	IssueAt  time.Time
}

func NewUAATokenInfo

func NewUAATokenInfo(token string) UAATokenInfo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL