-
Notifications
You must be signed in to change notification settings - Fork 87
CLOUDP-60955: mongocli om logs list #125
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b1d8819
CLOUDP-60954 mongocli om logs collect
andreaangiolillo 9c6b950
CLOUDP-60955 mongocli om logs list
andreaangiolillo eba6779
Updated OM client to v0.2.1
andreaangiolillo 603f09f
Addressed PR comments
andreaangiolillo 3fe95ea
Merge remote-tracking branch 'origin/CLOUDP-60954' into CLOUDP-60955
andreaangiolillo db86d82
Added unit test
andreaangiolillo 7d97232
Merge remote-tracking branch 'origin/master' into CLOUDP-60955
andreaangiolillo dd052bb
Refactoring
andreaangiolillo 9468ba3
Generated mock
andreaangiolillo c014335
Making opsManagerLogsListOptsBuilder public
andreaangiolillo e787ab1
Update internal/cli/ops_manager_logs_list.go
andreaangiolillo ec77d7e
Addressed PR comments
andreaangiolillo 0c5088d
Merge branch 'master' into CLOUDP-60955
andreaangiolillo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2020 MongoDB Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cli | ||
|
||
import ( | ||
om "github.com/mongodb/go-client-mongodb-ops-manager/opsmngr" | ||
"github.com/mongodb/mongocli/internal/description" | ||
"github.com/mongodb/mongocli/internal/flags" | ||
"github.com/mongodb/mongocli/internal/json" | ||
"github.com/mongodb/mongocli/internal/store" | ||
"github.com/mongodb/mongocli/internal/usage" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type opsManagerLogsListOpts struct { | ||
globalOpts | ||
verbose bool | ||
store store.LogJobLister | ||
} | ||
|
||
func (opts *opsManagerLogsListOpts) initStore() error { | ||
var err error | ||
opts.store, err = store.New() | ||
return err | ||
} | ||
|
||
func (opts *opsManagerLogsListOpts) Run() error { | ||
result, err := opts.store.LogCollectionJobs(opts.ProjectID(), opts.newLogListOptions()) | ||
if err != nil { | ||
return err | ||
} | ||
return json.PrettyPrint(result) | ||
} | ||
|
||
func (opts *opsManagerLogsListOpts) newLogListOptions() *om.LogListOptions { | ||
return &om.LogListOptions{Verbose: opts.verbose} | ||
} | ||
|
||
// mongocli om logs list --verbose verbose [--projectId projectId] | ||
func OpsManagerLogsListOptsBuilder() *cobra.Command { | ||
opts := &opsManagerLogsListOpts{} | ||
cmd := &cobra.Command{ | ||
Use: "list", | ||
Aliases: []string{"ls"}, | ||
Short: description.ListLogCollectionJobs, | ||
PreRunE: func(cmd *cobra.Command, args []string) error { | ||
return opts.PreRunE(opts.initStore) | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return opts.Run() | ||
}, | ||
} | ||
|
||
cmd.Flags().BoolVar(&opts.verbose, flags.Verbose, false, usage.Verbose) | ||
|
||
cmd.Flags().StringVar(&opts.projectID, flags.ProjectID, "", usage.ProjectID) | ||
|
||
return cmd | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2020 MongoDB Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package cli | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
om "github.com/mongodb/go-client-mongodb-ops-manager/opsmngr" | ||
"github.com/mongodb/mongocli/internal/mocks" | ||
) | ||
|
||
func TestOpsManagerLogsListOpts_Run(t *testing.T) { | ||
ctrl := gomock.NewController(t) | ||
mockStore := mocks.NewMockLogJobLister(ctrl) | ||
|
||
defer ctrl.Finish() | ||
|
||
expected := &om.LogCollectionJobs{} | ||
|
||
listOpts := &opsManagerLogsListOpts{ | ||
store: mockStore, | ||
verbose: true, | ||
} | ||
|
||
mockStore. | ||
EXPECT().LogCollectionJobs(listOpts.projectID, listOpts.newLogListOptions()). | ||
Return(expected, nil). | ||
Times(1) | ||
|
||
if err := listOpts.Run(); err != nil { | ||
t.Fatalf("Run() unexpected error: %v", err) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a comment in the jira ticket about making this, maybe,
mongocli om log jobs list
we could do that on a separate PR but just letting you know this may changeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I haven’t done it yet because it seems to be something that we still have to decide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created this ticket https://jira.mongodb.org/browse/CLOUDP-61392 to keep track of this change