MM-38698: Add limit to the CLI compliance export command (#20997)

```release-note
A batchSize option has been added to the mattermost export
CLI command to limit the number of items exported. By default,
if it is not included, it exports all the posts.
```

https://mattermost.atlassian.net/browse/MM-38698


Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Agniva De Sarker
2022-09-15 08:46:43 +05:30
коммит произвёл GitHub
родитель 4f363574fc
Коммит a8154ddae0
4 изменённых файлов: 23 добавлений и 9 удалений

Просмотреть файл

@@ -71,9 +71,13 @@ func init() {
ScheduleExportCmd.Flags().Int("timeoutSeconds", -1, "The maximum number of seconds to wait for the job to complete before timing out.")
CsvExportCmd.Flags().Int64("exportFrom", -1, "The timestamp of the earliest post to export, expressed in seconds since the unix epoch.")
CsvExportCmd.Flags().Int("limit", -1, "The number of posts to export. The default of -1 means no limit.")
ActianceExportCmd.Flags().Int64("exportFrom", -1, "The timestamp of the earliest post to export, expressed in seconds since the unix epoch.")
ActianceExportCmd.Flags().Int("limit", -1, "The number of posts to export. The default of -1 means no limit.")
GlobalRelayZipExportCmd.Flags().Int64("exportFrom", -1, "The timestamp of the earliest post to export, expressed in seconds since the unix epoch.")
GlobalRelayZipExportCmd.Flags().Int("limit", -1, "The number of posts to export. The default of -1 means no limit.")
BulkExportCmd.Flags().Bool("all-teams", true, "Export all teams from the server.")
BulkExportCmd.Flags().Bool("attachments", false, "Also export file attachments.")
@@ -164,11 +168,16 @@ func buildExportCmdF(format string) func(command *cobra.Command, args []string)
return errors.New("exportFrom must be a positive integer")
}
limit, err := command.Flags().GetInt("limit")
if err != nil {
return errors.New("limit flag error")
}
if a.MessageExport() == nil || license == nil || !*license.Features.MessageExport {
return errors.New("message export feature not available")
}
warningsCount, appErr := a.MessageExport().RunExport(format, startTime)
warningsCount, appErr := a.MessageExport().RunExport(format, startTime, limit)
if appErr != nil {
return appErr
}