Skip to content

CLOUDP-61621: Adding the projectID in mongocli config #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions internal/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type configOpts struct {
PublicAPIKey string
PrivateAPIKey string
OpsManagerURL string
ProjectID string
}

func (opts *configOpts) IsCloud() bool {
Expand All @@ -55,6 +56,9 @@ func (opts *configOpts) Save() error {
if opts.IsOpsManager() && opts.OpsManagerURL != "" {
config.SetOpsManagerURL(opts.OpsManagerURL)
}
if opts.ProjectID != "" {
config.SetProjectID(opts.ProjectID)
}

return config.Save()
}
Expand Down Expand Up @@ -82,6 +86,14 @@ func (opts *configOpts) Run() error {
Help: helpLink,
},
},
{
Name: "projectId",
Prompt: &survey.Input{
Message: "Project ID [optional]:",
Help: "This is the ID of an existing project your API keys have access to, you can leave this blank and specify it on every command with --projectId",
Default: config.ProjectID(),
},
},
}

if opts.IsOpsManager() {
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/ops_manager_servers_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (opts *opsManagerServersListOpts) initStore() error {
}

func (opts *opsManagerServersListOpts) Run() error {
servers, err := opts.store.Agents(opts.projectID, agentType)
servers, err := opts.store.Agents(opts.ProjectID(), agentType)

if err != nil {
return err
Expand Down