-
Notifications
You must be signed in to change notification settings - Fork 86
CLOUDP-60954: mongocli om logs collect #123
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
Conversation
"github.com/mongodb/mongocli/internal/config" | ||
) | ||
|
||
type LogsDownloader interface { | ||
DownloadLog(string, string, string, io.Writer, *atlas.DateRangetOptions) error | ||
} | ||
|
||
type Logs interface { | ||
Collect(string, *om.LogCollectionJob) (*om.LogCollectionJob, error) |
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.
Happy to change its name. Maybe to CreateLogJob
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.
Couple of nits here and there but great initial work
internal/usage/usage.go
Outdated
ResourceType = "Type of resource from which to collect logs." | ||
LogTypes = "Array of strings specifying the types of logs to collect." | ||
SizeRequestedPerFileBytes = "Size for each log file in bytes." | ||
Redacted = "If set to true, emails, hostnames, IP addresses, and namespaces in API responses involving this job are replaced with random string values." |
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.
same as above
Redacted = "If set to true, emails, hostnames, IP addresses, and namespaces in API responses involving this job are replaced with random string values." | |
LogRedacted = "If set to true, emails, hostnames, IP addresses, and namespaces in API responses involving this job are replaced with random string values." |
Or RedactedLog
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.
Do you want me to rename also SizeRequestedPerFileBytes
?
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.
Up to you, I think that one is quite unique for this command but redacted may show up in other commands and we may use it without realising it has log copy in it and not something generic
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.
couple of copy changes and then we are good, also to clarify something
things in the flags
package are ok to be generic, things like type
, redacted
, start
, end
are probably going to be used in more than one command but things in the usage
package need to either be generic as well or specific of the command, if we include copy like log, measurements or similar in a generic Type
usage we risk that someone reusing the constant shows the wrong usage for a different command (this happened to me the other day reusing start and end)
func OpsManagerLogsCollectOptsBuilder() *cobra.Command { | ||
opts := &opsManagerLogsCollectOpts{} | ||
cmd := &cobra.Command{ | ||
Use: "collect", |
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.
smal nit
Use: "collect", | |
Use: "collect [resourceType] [resourceName]", |
|
||
args[0] = strings.ToLower(args[0]) | ||
if !search.StringInSlice(cmd.ValidArgs, args[0]) { | ||
return fmt.Errorf("invalid Resource Type. The Resource Type must be cluster, process or replicaset but was %q", args[0]) |
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.
we don't need that many capital letters here, they are not proper nouns
return fmt.Errorf("invalid Resource Type. The Resource Type must be cluster, process or replicaset but was %q", args[0]) | |
return fmt.Errorf("invalid resource type '%s', expected one of %v", args[0], cmd. ValidArgs) |
internal/flags/flags.go
Outdated
@@ -115,4 +115,7 @@ const ( | |||
Normalization = "normalization" // Normalization flag | |||
Backwards = "backwards" // Backwards flag | |||
Strength = "strength" // Strength flag | |||
LogTypes = "logTypes" // LogTypes flag | |||
SizeRequestedPerFileBytes = "sizeRequestedPerFileBytes" //SizeRequestedPerFileBytes flag | |||
LogRedacted = "redacted" // LogRedacted flag |
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.
This could have stayed Redacted
, there's no log in the value so anyone should be free to use it
internal/flags/flags.go
Outdated
@@ -115,4 +115,7 @@ const ( | |||
Normalization = "normalization" // Normalization flag | |||
Backwards = "backwards" // Backwards flag | |||
Strength = "strength" // Strength flag | |||
LogTypes = "logTypes" // LogTypes flag |
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's already a Type
const in this file, let's use that one.
we don't need the log part in the flag since are already in a log command
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.
LGTM, thanks for all the fixes
Proposed changes
Jira ticket: CLOUDP-60954
Checklist
make fmt
and formatted my codeFurther comments