Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultMongoDBMajorVersion() (string, error)
- func DeploymentStatus(baseURL, projectID string) string
- func DescriptionServiceName() string
- func ExampleAtlasEntryPoint() string
- func GenerateAliases(use string, extra ...string) []string
- func GetHostnameAndPort(hostInfo string) (hostname string, port int, err error)
- func InitProfile(profile string) error
- func ParseServiceVersion(v *opsmngr.ServiceVersion) (*semver.Version, error)
- func ReturnValueForSetting(enableFlag, disableFlag bool) *bool
- type AutoFunc
- type DefaultSetterOpts
- func (opts *DefaultSetterOpts) AskOrg() error
- func (opts *DefaultSetterOpts) AskProject() error
- func (*DefaultSetterOpts) DefaultQuestions() []*survey.Question
- func (opts *DefaultSetterOpts) InitStore(ctx context.Context) error
- func (opts *DefaultSetterOpts) IsCloud() bool
- func (opts *DefaultSetterOpts) IsOpsManager() bool
- func (opts *DefaultSetterOpts) OrgExists(id string) bool
- func (opts *DefaultSetterOpts) ProjectExists(id string) bool
- func (opts *DefaultSetterOpts) SetUpOrg()
- func (opts *DefaultSetterOpts) SetUpOutput()
- func (opts *DefaultSetterOpts) SetUpProject()
- type DeleteOpts
- type DigestConfigOpts
- type DownloaderOpts
- type GlobalOpts
- type InputOpts
- type ListOpts
- type MetricsOpts
- func (opts *MetricsOpts) NewDatabaseMeasurementsAPIParams(groupID string, processID string, dbName string) *atlasv2.GetDatabaseMeasurementsApiParams
- func (opts *MetricsOpts) NewDiskMeasurementsAPIParams(groupID string, processID string, partitionName string) *atlasv2.GetDiskMeasurementsApiParams
- func (opts *MetricsOpts) NewProcessMeasurementsAPIParams(groupID string, processID string) *atlasv2.GetHostMeasurementsApiParams
- func (opts *MetricsOpts) NewProcessMetricsListOptions() *atlas.ProcessMeasurementListOptions
- func (opts *MetricsOpts) ValidatePeriodStartEnd() error
- type OutputOpts
- func (*OutputOpts) AutoCompleteOutputFlag() ...
- func (opts *OutputOpts) ConfigOutput() string
- func (opts *OutputOpts) ConfigWriter() io.Writer
- func (opts *OutputOpts) InitOutput(w io.Writer, t string) func() error
- func (opts *OutputOpts) IsCygwinTerminal() bool
- func (opts *OutputOpts) IsGoTemplate() bool
- func (opts *OutputOpts) IsJSONOutput() bool
- func (opts *OutputOpts) IsJSONPathOutput() bool
- func (opts *OutputOpts) IsPlainOutput() bool
- func (opts *OutputOpts) IsTerminal() bool
- func (opts *OutputOpts) Print(o interface{}) error
- func (opts *OutputOpts) PrintForCompactResultsResponse(o interface{}) error
- type PerformanceAdvisorOpts
- type ProjectOrgsLister
- type Refresher
- type RefresherOpts
- func (opts *RefresherOpts) InitFlow(c oauth.ServiceGetter) func() error
- func (opts *RefresherOpts) PollToken(c context.Context, d *atlasauth.DeviceCode) (*atlasauth.Token, *atlas.Response, error)
- func (opts *RefresherOpts) RefreshAccessToken(ctx context.Context) error
- func (opts *RefresherOpts) RegistrationConfig(c context.Context) (*atlasauth.RegistrationConfig, *atlas.Response, error)
- func (opts *RefresherOpts) RequestCode(c context.Context) (*atlasauth.DeviceCode, *atlas.Response, error)
- func (opts *RefresherOpts) WithFlow(f Refresher)
- type WatchOpts
- type Watcher
Constants ¶
const ( DefaultPage = 1 DefaultPageLimit = 100 )
const StdOutMode = "-"
Variables ¶
var ErrFreeClusterAlreadyExists = errors.New("this project already has another free cluster. To learn how to create non-free clusters, run \"atlas cluster create --help\"")
var ErrInvalidRefreshToken = errors.New("session expired")
var ErrMissingOrgID = fmt.Errorf(requiredF, flag.OrgID)
var ErrNameExists = errors.New(`the name already exists. Please run "atlas cluster list" to review existing cluster names`)
var ErrNoRegionExistsTryCommand = errors.New(`the region does not exist. To find the available regions, run "atlas cluster availableRegions list"`)
var TokenRefreshed bool
Functions ¶
func DeploymentStatus ¶
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 ¶
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 ¶
GetHostnameAndPort return the hostname and the port starting from the string hostname:port.
func InitProfile ¶
func ParseServiceVersion ¶
func ParseServiceVersion(v *opsmngr.ServiceVersion) (*semver.Version, error)
ParseServiceVersion parses service version into semver.Version.
func ReturnValueForSetting ¶
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 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 ¶
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 ¶
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) ShouldDownloadToStdout ¶
func (opts *DownloaderOpts) ShouldDownloadToStdout() bool
type GlobalOpts ¶
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) ValidateOrgID ¶
func (opts *GlobalOpts) ValidateOrgID() error
ValidateOrgID validates orgID.
func (*GlobalOpts) ValidateProjectID ¶
func (opts *GlobalOpts) ValidateProjectID() error
ValidateProjectID validates projectID.
type InputOpts ¶
func (*InputOpts) ConfigReader ¶
ConfigReader returns the io.Reader. If the reader is nil, it defaults to os.Stdin and caches it.
func (*InputOpts) IsCygwinTerminalInput ¶
IsCygwinTerminalInput returns true is the current file descriptor is cygwin.
func (*InputOpts) IsTerminalInput ¶
IsTerminalInput returns true is the current file descriptor is TTY kind of terminal.
type ListOpts ¶
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 ¶
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 ¶
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 Refresher ¶
type Refresher interface { RequestCode(context.Context) (*atlasauth.DeviceCode, *atlas.Response, error) PollToken(context.Context, *atlasauth.DeviceCode) (*atlasauth.Token, *atlas.Response, error) RefreshToken(context.Context, string) (*atlasauth.Token, *atlas.Response, error) RegistrationConfig(ctx context.Context) (*atlasauth.RegistrationConfig, *atlas.Response, 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 (opts *RefresherOpts) PollToken(c context.Context, d *atlasauth.DeviceCode) (*atlasauth.Token, *atlas.Response, error)
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 }