config

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 17 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
	CloudManagerService = "cloud-manager" // CloudManagerService settings when using CLoud Manager API
	OpsManagerService   = "ops-manager"   // OpsManagerService settings when using Ops Manager API
	JSON                = "json"          // JSON output format as json

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

	TelemetryEnabledProperty = "telemetry_enabled"
	MongoCLI                 = "mongocli"
	AtlasCLI                 = "atlascli"
	ContainerizedHostNameEnv = "MONGODB_ATLAS_IS_CONTAINERIZED"
	GitHubActionsHostNameEnv = "GITHUB_ACTIONS"
	AtlasActionHostNameEnv   = "ATLAS_GITHUB_ACTION"
	NativeHostName           = "native"
	DockerContainerHostName  = "container"
	GitHubActionsHostName    = "all_github_actions"
	AtlasActionHostName      = "atlascli_github_action"
)

Variables

View Source
var (
	ToolName  = MongoCLI
	HostName  = getConfigHostnameFromEnvs()
	UserAgent = fmt.Sprintf("%s/%s (%s;%s;%s)", ToolName, version.Version, runtime.GOOS, runtime.GOARCH, HostName)
)
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 AtlasCLIConfigHome

func AtlasCLIConfigHome() (string, error)

AtlasCLIConfigHome retrieves configHome path based used by AtlasCLI.

func BinName

func BinName() string

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) interface{}

func GetBool

func GetBool(name string) bool

func GetString

func GetString(name string) string

func GlobalProperties

func GlobalProperties() []string

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 LoadMongoCLIConfig

func LoadMongoCLIConfig() error

func Map

func Map() map[string]string

Map returns a map describing the configuration.

func MongoCLIConfigHome

func MongoCLIConfigHome() (string, error)

MongoCLIConfigHome retrieves configHome path based used by MongoCLI.

func Name

func Name() string

func OldMongoCLIConfigHome deprecated

func OldMongoCLIConfigHome() (string, error)

OldMongoCLIConfigHome retrieves configHome path based used by MongoCLI.

Deprecated: MongoCLI versions below v1.24.0 use this path.

func OpsManagerCACertificate

func OpsManagerCACertificate() string

OpsManagerCACertificate get configured ops manager CA certificate location.

func OpsManagerSkipVerify

func OpsManagerSkipVerify() string

OpsManagerSkipVerify get configured if transport should skip CA verification.

func OpsManagerURL

func OpsManagerURL() string

OpsManagerURL get configured ops manager base url.

func OpsManagerVersionManifestURL

func OpsManagerVersionManifestURL() string

OpsManagerVersionManifestURL get configured ops manager version manifest 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 interface{})

func SetAccessToken

func SetAccessToken(v string)

SetAccessToken set configured access token.

func SetGlobal

func SetGlobal(name string, value interface{})

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.

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, interface{})
}

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) interface{}

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) 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) LoadMongoCLIConfig

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

func (*Profile) Map

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

func (*Profile) Name

func (p *Profile) Name() string

func (*Profile) OpsManagerCACertificate

func (p *Profile) OpsManagerCACertificate() string

func (*Profile) OpsManagerSkipVerify

func (p *Profile) OpsManagerSkipVerify() string

func (*Profile) OpsManagerURL

func (p *Profile) OpsManagerURL() string

func (*Profile) OpsManagerVersionManifestURL

func (p *Profile) OpsManagerVersionManifestURL() 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 interface{})

func (*Profile) SetAccessToken

func (p *Profile) SetAccessToken(v string)

func (*Profile) SetGlobal

func (*Profile) SetGlobal(name string, value interface{})

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, interface{})
}

Jump to

Keyboard shortcuts

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