Skip to content

Commit

Permalink
feature: Adding global flag max-keys
Browse files Browse the repository at this point in the history
Possible to control nr keys that is return in  respnse body from s3 api
  • Loading branch information
dbgeek committed Mar 17, 2019
1 parent 65d0375 commit be71675
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func init() {
viper.BindPFlag("start-time", rootCmd.PersistentFlags().Lookup("start-time"))
rootCmd.PersistentFlags().StringP("end-time", "", time.Now().Format("2006-01-02 15:04:05"), "")
viper.BindPFlag("end-time", rootCmd.PersistentFlags().Lookup("end-time"))
rootCmd.PersistentFlags().Int64P("max-keys", "", 500, "control nr of keys that should be return from s3 api for each response.")
viper.BindPFlag("max-keys", rootCmd.PersistentFlags().Lookup("max-keys"))

// Cobra also supports local flags, which will only run
// when this action is called directly.
Expand Down
2 changes: 1 addition & 1 deletion logworker/logworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (l *LogWorker) listAccessLogs(s3Prefix string) *[]string {
Bucket: aws.String(l.Configuration.Bucket),
Prefix: aws.String(s3Prefix),
Delimiter: aws.String("/"),
MaxKeys: aws.Int64(200),
MaxKeys: aws.Int64(l.Configuration.MaxKeys),
}
err := l.S3.ListObjectsV2Pages(input,
func(page *s3.ListObjectsV2Output, lastPage bool) bool {
Expand Down

0 comments on commit be71675

Please sign in to comment.