cli

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: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPage      = 1
	DefaultPageLimit = 100
)
View Source
const StdOutMode = "-"

Variables

View Source
var ErrFreeClusterAlreadyExists = errors.New("this project already has another free cluster. To learn how to create non-free clusters, run \"atlas cluster create --help\"")
View Source
var ErrInvalidRefreshToken = errors.New("session expired")
View Source
var ErrMissingOrgID = fmt.Errorf(requiredF, flag.OrgID)
View Source
var ErrNameExists = errors.New(`the name already exists. Please run "atlas cluster list" to review existing cluster names`)
View Source
var ErrNoRegionExistsTryCommand = errors.New(`the region does not exist. To find the available regions, run "atlas cluster availableRegions list"`)
View Source
var TokenRefreshed bool

Functions

func DefaultMongoDBMajorVersion

func DefaultMongoDBMajorVersion() (string, error)

func DeploymentStatus

func DeploymentStatus(baseURL, projectID string) string

func DescriptionServiceName

func DescriptionServiceName() string

DescriptionServiceName returns the name of the service that uses a given IAM command.

func ExampleAtlasEntryPoint

func ExampleAtlasEntryPoint() string

ExampleAtlasEntryPoint returns the entry point for an atlas command while taking into account if the bin is atlas or mongocli.

func GenerateAliases

func GenerateAliases(use string, extra ...string) []string

GenerateAliases return aliases for use such that they are: a version all lower case, a version with dashes, a singular versions with the same rules.

func GetHostnameAndPort

func GetHostnameAndPort(hostInfo string) (hostname string, port int, err error)

GetHostnameAndPort return the hostname and the port starting from the string hostname:port.

func InitProfile

func InitProfile(profile string) error

func ParseServiceVersion

func ParseServiceVersion(v *opsmngr.ServiceVersion) (*semver.Version, error)

ParseServiceVersion parses service version into semver.Version.

func ReturnValueForSetting

func ReturnValueForSetting(enableFlag, disableFlag bool) *bool

ReturnValueForSetting returns a boolean value that is useful when working with boolean flags to inform whether the given option should be active or inactive.

Types

type AutoFunc

type AutoFunc func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

type DefaultSetterOpts

type DefaultSetterOpts struct {
	Service                  string
	OpsManagerURL            string
	ProjectID                string
	OrgID                    string
	TelemetryEnabled         bool
	Output                   string
	Store                    ProjectOrgsLister
	OutWriter                io.Writer
	AskedOrgsOrProjects      bool
	OnMultipleOrgsOrProjects func()
}

func (*DefaultSetterOpts) AskOrg

func (opts *DefaultSetterOpts) AskOrg() error

AskOrg will try to construct a select based on fetched organizations. If it fails or there are no organizations to show we fallback to ask for org by ID. If only one organization, select it by default without prompting the user.

func (*DefaultSetterOpts) AskProject

func (opts *DefaultSetterOpts) AskProject() error

AskProject will try to construct a select based on fetched projects. If it fails or there are no projects to show we fallback to ask for project by ID. If only one project, select it by default without prompting the user.

func (*DefaultSetterOpts) DefaultQuestions

func (*DefaultSetterOpts) DefaultQuestions() []*survey.Question

func (*DefaultSetterOpts) InitStore

func (opts *DefaultSetterOpts) InitStore(ctx context.Context) error

func (*DefaultSetterOpts) IsCloud

func (opts *DefaultSetterOpts) IsCloud() bool

func (*DefaultSetterOpts) IsOpsManager

func (opts *DefaultSetterOpts) IsOpsManager() bool

func (*DefaultSetterOpts) OrgExists

func (opts *DefaultSetterOpts) OrgExists(id string) bool

OrgExists checks if the org exists and the current user has access to it.

func (*DefaultSetterOpts) ProjectExists

func (opts *DefaultSetterOpts) ProjectExists(id string) bool

ProjectExists checks if the project exists and the current user has access to it.

func (*DefaultSetterOpts) SetUpOrg

func (opts *DefaultSetterOpts) SetUpOrg()

func (*DefaultSetterOpts) SetUpOutput

func (opts *DefaultSetterOpts) SetUpOutput()

func (*DefaultSetterOpts) SetUpProject

func (opts *DefaultSetterOpts) SetUpProject()

type DeleteOpts

type DeleteOpts struct {
	Entry   string
	Confirm bool
	// contains filtered or unexported fields
}

DeleteOpts options required when deleting a resource. A command can compose this struct and then safely rely on the methods Prompt, or Delete to manage the interactions with the user.

func NewDeleteOpts

func NewDeleteOpts(successMsg, failMsg string) *DeleteOpts

func (*DeleteOpts) Delete

func (opts *DeleteOpts) Delete(d interface{}, a ...string) error

Delete deletes a resource not associated to a project, it expects a callback that should perform the deletion from the store.

func (*DeleteOpts) FailMessage

func (opts *DeleteOpts) FailMessage() string

FailMessage gets the set fail message or the default value.

func (*DeleteOpts) Prompt

func (opts *DeleteOpts) Prompt() error

Prompt confirms that the resource should be deleted.

func (*DeleteOpts) PromptWithMessage

func (opts *DeleteOpts) PromptWithMessage(message string) error

PromptWithMessage confirms that the resource should be deleted.

func (*DeleteOpts) SuccessMessage

func (opts *DeleteOpts) SuccessMessage() string

SuccessMessage gets the set success message or the default value.

type DigestConfigOpts

type DigestConfigOpts struct {
	DefaultSetterOpts
	PublicAPIKey  string
	PrivateAPIKey string
}

func (*DigestConfigOpts) SetUpDigestAccess

func (opts *DigestConfigOpts) SetUpDigestAccess()

func (*DigestConfigOpts) SetUpServiceAndKeys

func (opts *DigestConfigOpts) SetUpServiceAndKeys()

type DownloaderOpts

type DownloaderOpts struct {
	Out   string
	Force bool
	Fs    afero.Fs
}

DownloaderOpts options required when deleting a resource. A command can compose this struct and then safely rely on the methods Prompt, or Delete to manage the interactions with the user.

func (*DownloaderOpts) NewWriteCloser

func (opts *DownloaderOpts) NewWriteCloser() (io.WriteCloser, error)

NewWriteCloser creates a new file, if Force is false then don't allow to overwrite the file.

func (*DownloaderOpts) OnError

func (opts *DownloaderOpts) OnError(f io.Closer) error

func (*DownloaderOpts) ShouldDownloadToStdout

func (opts *DownloaderOpts) ShouldDownloadToStdout() bool

type GlobalOpts

type GlobalOpts struct {
	OrgID     string
	ProjectID string
}

func (*GlobalOpts) ConfigOrgID

func (opts *GlobalOpts) ConfigOrgID() string

ConfigOrgID returns the organization id. If the id is empty, it caches it after querying config.

func (*GlobalOpts) ConfigProjectID

func (opts *GlobalOpts) ConfigProjectID() string

ConfigProjectID returns the project id. If the id is empty, it caches it after querying config.

func (*GlobalOpts) PreRunE

func (*GlobalOpts) PreRunE(cbs ...prerun.CmdOpt) error

func (*GlobalOpts) ValidateOrgID

func (opts *GlobalOpts) ValidateOrgID() error

ValidateOrgID validates orgID.

func (*GlobalOpts) ValidateProjectID

func (opts *GlobalOpts) ValidateProjectID() error

ValidateProjectID validates projectID.

type InputOpts

type InputOpts struct {
	InReader io.Reader
}

func (*InputOpts) ConfigReader

func (opts *InputOpts) ConfigReader() io.Reader

ConfigReader returns the io.Reader. If the reader is nil, it defaults to os.Stdin and caches it.

func (*InputOpts) InitInput

func (opts *InputOpts) InitInput(r io.Reader) func() error

InitInput allow to init the InputOpts in a functional way.

func (*InputOpts) IsCygwinTerminalInput

func (opts *InputOpts) IsCygwinTerminalInput() bool

IsCygwinTerminalInput returns true is the current file descriptor is cygwin.

func (*InputOpts) IsTerminalInput

func (opts *InputOpts) IsTerminalInput() bool

IsTerminalInput returns true is the current file descriptor is TTY kind of terminal.

type ListOpts

type ListOpts struct {
	PageNum      int
	ItemsPerPage int
}

func (*ListOpts) NewAtlasListOptions

func (opts *ListOpts) NewAtlasListOptions() *store.ListOptions

func (*ListOpts) NewListOptions

func (opts *ListOpts) NewListOptions() *mongodbatlas.ListOptions

type MetricsOpts

type MetricsOpts struct {
	ListOpts
	Granularity     string
	Period          string
	Start           string
	End             string
	MeasurementType []string
}

func (*MetricsOpts) NewDatabaseMeasurementsAPIParams

func (opts *MetricsOpts) NewDatabaseMeasurementsAPIParams(groupID string, processID string, dbName string) *atlasv2.GetDatabaseMeasurementsApiParams

func (*MetricsOpts) NewDiskMeasurementsAPIParams

func (opts *MetricsOpts) NewDiskMeasurementsAPIParams(groupID string, processID string, partitionName string) *atlasv2.GetDiskMeasurementsApiParams

func (*MetricsOpts) NewProcessMeasurementsAPIParams

func (opts *MetricsOpts) NewProcessMeasurementsAPIParams(groupID string, processID string) *atlasv2.GetHostMeasurementsApiParams

func (*MetricsOpts) NewProcessMetricsListOptions

func (opts *MetricsOpts) NewProcessMetricsListOptions() *atlas.ProcessMeasurementListOptions

func (*MetricsOpts) ValidatePeriodStartEnd

func (opts *MetricsOpts) ValidatePeriodStartEnd() error

ValidatePeriodStartEnd validates period, start and end flags.

type OutputOpts

type OutputOpts struct {
	Template  string
	OutWriter io.Writer
	Output    string
}

func (*OutputOpts) AutoCompleteOutputFlag

func (*OutputOpts) AutoCompleteOutputFlag() func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

func (*OutputOpts) ConfigOutput

func (opts *OutputOpts) ConfigOutput() string

ConfigOutput returns the output format. If the format is empty, it caches it after querying config.

func (*OutputOpts) ConfigWriter

func (opts *OutputOpts) ConfigWriter() io.Writer

ConfigWriter returns the io.Writer. If the writer is nil, it defaults to os.Stdout and caches it.

func (*OutputOpts) InitOutput

func (opts *OutputOpts) InitOutput(w io.Writer, t string) func() error

InitOutput allow to init the OutputOpts in a functional way.

func (*OutputOpts) IsCygwinTerminal

func (opts *OutputOpts) IsCygwinTerminal() bool

IsCygwinTerminal returns true is the current file descriptor is cygwin.

func (*OutputOpts) IsGoTemplate

func (opts *OutputOpts) IsGoTemplate() bool

func (*OutputOpts) IsJSONOutput

func (opts *OutputOpts) IsJSONOutput() bool

func (*OutputOpts) IsJSONPathOutput

func (opts *OutputOpts) IsJSONPathOutput() bool

func (*OutputOpts) IsPlainOutput

func (opts *OutputOpts) IsPlainOutput() bool

func (*OutputOpts) IsTerminal

func (opts *OutputOpts) IsTerminal() bool

IsTerminal returns true is the current file descriptor is TTY kind of terminal.

func (*OutputOpts) Print

func (opts *OutputOpts) Print(o interface{}) error

Print will evaluate the defined format and try to parse it accordingly outputting to the set writer.

func (*OutputOpts) PrintForCompactResultsResponse

func (opts *OutputOpts) PrintForCompactResultsResponse(o interface{}) error

type PerformanceAdvisorOpts

type PerformanceAdvisorOpts struct {
	ProcessName string
	HostID      string
}

func (*PerformanceAdvisorOpts) Host

func (opts *PerformanceAdvisorOpts) Host() (string, error)

Host returns the correct processName or the hostId in accordance with the service.

func (*PerformanceAdvisorOpts) MarkRequiredFlagsByService

func (*PerformanceAdvisorOpts) MarkRequiredFlagsByService(cmd *cobra.Command) func() error

MarkRequiredFlagsByService marks processName or hostId as required in accordance with the service.

Atlas: processName is required

OM/CM: hostId is required.

type ProjectOrgsLister

type ProjectOrgsLister interface {
	Project(id string) (interface{}, error)
	Projects(*atlas.ListOptions) (interface{}, error)
	Organization(id string) (interface{}, error)
	Organizations(*atlas.OrganizationsListOptions) (interface{}, error)
	GetOrgProjects(string, *atlas.ProjectsListOptions) (interface{}, error)
}

type RefresherOpts

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

func (*RefresherOpts) InitFlow

func (opts *RefresherOpts) InitFlow(c oauth.ServiceGetter) func() error

func (*RefresherOpts) PollToken

func (*RefresherOpts) RefreshAccessToken

func (opts *RefresherOpts) RefreshAccessToken(ctx context.Context) error

func (*RefresherOpts) RegistrationConfig

func (opts *RefresherOpts) RegistrationConfig(c context.Context) (*atlasauth.RegistrationConfig, *atlas.Response, error)

func (*RefresherOpts) RequestCode

func (opts *RefresherOpts) RequestCode(c context.Context) (*atlasauth.DeviceCode, *atlas.Response, error)

func (*RefresherOpts) WithFlow

func (opts *RefresherOpts) WithFlow(f Refresher)

WithFlow set a flow for testing.

type WatchOpts

type WatchOpts struct {
	OutputOpts

	EnableWatch    bool
	DefaultWait    *time.Duration
	Timeout        uint
	IsRetryableErr func(err error) bool
	// contains filtered or unexported fields
}

func (*WatchOpts) GetDefaultWait

func (opts *WatchOpts) GetDefaultWait() time.Duration

func (*WatchOpts) Watch

func (opts *WatchOpts) Watch(f Watcher) (interface{}, error)

Watch allow to init the OutputOpts in a functional way.

func (*WatchOpts) WatchWatcher

func (opts *WatchOpts) WatchWatcher(w *watchers.Watcher) error

type Watcher

type Watcher func() (interface{}, bool, error)

Directories

Path Synopsis
iam
mongocli
root

Jump to

Keyboard shortcuts

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