core_config

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 17 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
	PluginRepos               []models.PluginRepo
	SSLDisabled               bool
	Locale                    string
	MessageOfTheDayTime       int64
	LastSessionUpdateTime     int64
	Trace                     string
	ColorEnabled              string
	AlphaCommandsEnabled      string
	HTTPTimeout               int
	TypeOfSSO                 string
	FallbackIAMTokens         struct {
		IAMToken        string
		IAMRefreshToken string
	}
	AssumedTrustedProfileId     string
	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
	PaginationURLs              []models.PaginationURL
	// 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 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

func (IAMTokenInfo) HasExpired added in v1.6.0

func (t IAMTokenInfo) HasExpired() bool

type ReadWriter

type ReadWriter interface {
	Repository
}

Deprecated

func NewCoreConfig

func NewCoreConfig(errHandler func(error)) ReadWriter

func NewCoreConfigFromPath

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

func NewCoreConfigFromPersistor

func NewCoreConfigFromPersistor(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
	TypeOfSSO() string
	AlphaCommandsEnabled() string
	AssumedTrustedProfileId() string
	FallbackIAMToken() string
	FallbackIAMRefreshToken() string
	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)
	SetFallbackIAMTokens(string, string)
	SetAssumedTrustedProfileId(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)
	SetTypeOfSSO(string)
	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)
	SetAlphaCommandsEnabled(string)

	CheckMessageOfTheDay() bool
	SetMessageOfTheDayTime()

	SetLastSessionUpdateTime()
	LastSessionUpdateTime() (session int64)

	SetPaginationURLs(paginationURLs []models.PaginationURL)
	ClearPaginationURLs()
	AddPaginationURL(lastIndex int, nextURL string)
	PaginationURLs() []models.PaginationURL
}

Jump to

Keyboard shortcuts

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