config

package
v0.0.0-...-c2296b7 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MongoCLIEnvPrefix = "MCLI"          // MongoCLIEnvPrefix prefix for MongoCLI ENV variables
	AtlasCLIEnvPrefix = "MONGODB_ATLAS" // AtlasCLIEnvPrefix prefix for AtlasCLI ENV variables
	DefaultProfile    = "default"       // DefaultProfile default
	CloudService      = "cloud"         // CloudService setting when using Atlas API
	CloudGovService   = "cloudgov"      // CloudGovService setting when using Atlas API for Government

	AccessTokenField   = "access_token"
	RefreshTokenField  = "refresh_token"
	ClientIDField      = "client_id"
	OpsManagerURLField = "ops_manager_url"

	TelemetryEnabledProperty = "telemetry_enabled"
	AtlasCLI                 = "atlascli"
	ContainerizedHostNameEnv = "MONGODB_ATLAS_IS_CONTAINERIZED"
	GitHubActionsHostNameEnv = "GITHUB_ACTIONS"
	AtlasActionHostNameEnv   = "ATLAS_GITHUB_ACTION"
	CLIUserTypeEnv           = "CLI_USER_TYPE" // CLIUserTypeEnv is used to separate MongoDB University users from default users
	DefaultUser              = "default"       // Users that do NOT use ATLAS CLI with MongoDB University
	UniversityUser           = "university"    // Users that uses ATLAS CLI with MongoDB University
	NativeHostName           = "native"
	DockerContainerHostName  = "container"
	GitHubActionsHostName    = "all_github_actions"
	AtlasActionHostName      = "atlascli_github_action"
)

Variables

View Source
var (
	HostName    = getConfigHostnameFromEnvs()
	CLIUserType = newCLIUserTypeFromEnvs()
)
View Source
var (
	ErrProfileNameHasDots = errors.New("profile should not contain '.'")
)

Functions

func AccessToken

func AccessToken() string

AccessToken get configured access token.

func AccessTokenSubject

func AccessTokenSubject() (string, error)

AccessTokenSubject will return the encoded subject in a JWT. This method won't verify the token signature, it's only safe to use to get the token claims.

func BooleanProperties

func BooleanProperties() []string

func CLIConfigHome

func CLIConfigHome() (string, error)

CLIConfigHome retrieves configHome path.

func ClientID

func ClientID() string

ClientID get configured output format.

func Delete

func Delete() error

Delete deletes an existing configuration. The profiles are reloaded afterwards, as this edits the file directly.

func Exists

func Exists(name string) bool

Exists returns true if there are any set settings for the profile name.

func Filename

func Filename() string

func Get

func Get(name string) any

func GetBool

func GetBool(name string) bool

func GetString

func GetString(name string) string

func GlobalProperties

func GlobalProperties() []string

func HttpBaseURL

func HttpBaseURL() string

func HttpClient

func HttpClient() *http.Client

func HttpTransport

func HttpTransport(httpTransport http.RoundTripper) http.RoundTripper

func IsAccessSet

func IsAccessSet() bool

IsAccessSet return true if API keys have been set up. For Ops Manager we also check for the base URL.

func IsCloud

func IsCloud() bool

func IsTelemetryEnabledSet

func IsTelemetryEnabledSet() bool

IsTelemetryEnabledSet return true if telemetry_enabled has been set.

func IsTrue

func IsTrue(s string) bool

func List

func List() []string

List returns the names of available profiles.

func LoadAtlasCLIConfig

func LoadAtlasCLIConfig() error

func Map

func Map() map[string]string

Map returns a map describing the configuration.

func Name

func Name() string

func OpsManagerURL

func OpsManagerURL() string

OpsManagerURL get configured ops manager base url.

func OrgID

func OrgID() string

OrgID get configured organization ID.

func Output

func Output() string

Output get configured output format.

func Path

func Path(f string) (string, error)

func PrivateAPIKey

func PrivateAPIKey() string

PrivateAPIKey get configured private api key.

func ProjectID

func ProjectID() string

ProjectID get configured project ID.

func Properties

func Properties() []string

func PublicAPIKey

func PublicAPIKey() string

PublicAPIKey get configured public api key.

func RefreshToken

func RefreshToken() string

RefreshToken get configured refresh token.

func Rename

func Rename(newProfileName string) error

Rename replaces the Profile to a new Profile name, overwriting any Profile that existed before.

func Save

func Save() error

Save the configuration to disk.

func Service

func Service() string

Service get configured service.

func Set

func Set(name string, value any)

func SetAccessToken

func SetAccessToken(v string)

SetAccessToken set configured access token.

func SetGlobal

func SetGlobal(name string, value any)

func SetName

func SetName(name string) error

func SetOpsManagerURL

func SetOpsManagerURL(v string)

SetOpsManagerURL set configured ops manager base url.

func SetOrgID

func SetOrgID(v string)

SetOrgID sets the global organization ID.

func SetOutput

func SetOutput(v string)

SetOutput sets the global output format.

func SetPrivateAPIKey

func SetPrivateAPIKey(v string)

SetPrivateAPIKey set configured private api key.

func SetProjectID

func SetProjectID(v string)

SetProjectID sets the global project ID.

func SetPublicAPIKey

func SetPublicAPIKey(v string)

SetPublicAPIKey set configured publicAPIKey.

func SetRefreshToken

func SetRefreshToken(v string)

SetRefreshToken set configured refresh token.

func SetService

func SetService(v string)

SetService set configured service.

func SetSkipUpdateCheck

func SetSkipUpdateCheck(v bool)

SetSkipUpdateCheck sets the global skip update check.

func SetTelemetryEnabled

func SetTelemetryEnabled(v bool)

SetTelemetryEnabled sets the telemetry enabled value.

func SkipUpdateCheck

func SkipUpdateCheck() bool

SkipUpdateCheck get the global skip update check.

func SortedKeys

func SortedKeys() []string

SortedKeys returns the properties of the Profile sorted.

func TelemetryEnabled

func TelemetryEnabled() bool

TelemetryEnabled get the configured telemetry enabled value.

func Token

func Token() (*auth.Token, error)

Token gets configured auth.Token.

func UserAgent

func UserAgent(version string) string

Types

type AuthMechanism

type AuthMechanism int
const (
	APIKeys AuthMechanism = iota

	OAuth
	NotLoggedIn
)

func AuthType

func AuthType() AuthMechanism

AuthType returns the type of authentication used in the profile.

type GlobalSetter

type GlobalSetter interface {
	SetGlobal(string, any)
}

type Profile

type Profile struct {
	// contains filtered or unexported fields
}

func Default

func Default() *Profile

func (*Profile) AccessToken

func (p *Profile) AccessToken() string

func (*Profile) AccessTokenSubject

func (p *Profile) AccessTokenSubject() (string, error)

func (*Profile) AuthType

func (p *Profile) AuthType() AuthMechanism

func (*Profile) ClientID

func (p *Profile) ClientID() string

func (*Profile) Delete

func (p *Profile) Delete() error

func (*Profile) Filename

func (p *Profile) Filename() string

func (*Profile) Get

func (p *Profile) Get(name string) any

func (*Profile) GetBool

func (p *Profile) GetBool(name string) bool

func (*Profile) GetBoolWithDefault

func (p *Profile) GetBoolWithDefault(name string, defaultValue bool) bool

func (*Profile) GetString

func (p *Profile) GetString(name string) string

func (*Profile) HttpBaseURL

func (p *Profile) HttpBaseURL() string

func (*Profile) HttpClient

func (p *Profile) HttpClient() *http.Client

func (*Profile) HttpTransport

func (p *Profile) HttpTransport(httpTransport http.RoundTripper) http.RoundTripper

func (*Profile) IsAccessSet

func (p *Profile) IsAccessSet() bool

func (*Profile) IsTelemetryEnabledSet

func (*Profile) IsTelemetryEnabledSet() bool

func (*Profile) LoadAtlasCLIConfig

func (p *Profile) LoadAtlasCLIConfig(readEnvironmentVars bool) error

func (*Profile) Map

func (p *Profile) Map() map[string]string

func (*Profile) Name

func (p *Profile) Name() string

func (*Profile) OpsManagerURL

func (p *Profile) OpsManagerURL() string

func (*Profile) OrgID

func (p *Profile) OrgID() string

func (*Profile) Output

func (p *Profile) Output() string

func (*Profile) PrivateAPIKey

func (p *Profile) PrivateAPIKey() string

func (*Profile) ProjectID

func (p *Profile) ProjectID() string

func (*Profile) PublicAPIKey

func (p *Profile) PublicAPIKey() string

func (*Profile) RefreshToken

func (p *Profile) RefreshToken() string

func (*Profile) Rename

func (p *Profile) Rename(newProfileName string) error

func (*Profile) Save

func (p *Profile) Save() error

func (*Profile) Service

func (p *Profile) Service() string

func (*Profile) Set

func (p *Profile) Set(name string, value any)

func (*Profile) SetAccessToken

func (p *Profile) SetAccessToken(v string)

func (*Profile) SetGlobal

func (*Profile) SetGlobal(name string, value any)

func (*Profile) SetName

func (p *Profile) SetName(name string) error

func (*Profile) SetOpsManagerURL

func (p *Profile) SetOpsManagerURL(v string)

func (*Profile) SetOrgID

func (p *Profile) SetOrgID(v string)

func (*Profile) SetOutput

func (p *Profile) SetOutput(v string)

func (*Profile) SetPrivateAPIKey

func (p *Profile) SetPrivateAPIKey(v string)

func (*Profile) SetProjectID

func (p *Profile) SetProjectID(v string)

func (*Profile) SetPublicAPIKey

func (p *Profile) SetPublicAPIKey(v string)

func (*Profile) SetRefreshToken

func (p *Profile) SetRefreshToken(v string)

func (*Profile) SetService

func (p *Profile) SetService(v string)

func (*Profile) SetSkipUpdateCheck

func (*Profile) SetSkipUpdateCheck(v bool)

func (*Profile) SetTelemetryEnabled

func (*Profile) SetTelemetryEnabled(v bool)

func (*Profile) SkipUpdateCheck

func (p *Profile) SkipUpdateCheck() bool

func (*Profile) SortedKeys

func (p *Profile) SortedKeys() []string

func (*Profile) TelemetryEnabled

func (p *Profile) TelemetryEnabled() bool

func (*Profile) Token

func (p *Profile) Token() (*auth.Token, error)

type Saver

type Saver interface {
	Save() error
}

type SetSaver

type SetSaver interface {
	Setter
	Saver
	GlobalSetter
}

type Setter

type Setter interface {
	Set(string, any)
}

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

func (*Transport) RoundTrip

func (tr *Transport) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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