[MM-62888] mmctl: Add compliance export list cmd (#30914)

* Add compliance export list cmd and tests

- Introduced `ListComplianceExports` method in the Client interface to retrieve compliance export jobs.
- Added `compliance_export` command with subcommand `list` for listing compliance export jobs, including pagination options.
- Implemented end-to-end and unit tests for the compliance export listing functionality.

* Add docs for mmctl

* fix test typo

* added paging, tested

* update docs with better desc (how it's sorted)

* simplified, reusing job call

* add show cmd, unit tests, e2e tests

* update mmctl docs
Этот коммит содержится в:
Christopher Poile
2025-06-24 11:20:40 -04:00
коммит произвёл GitHub
родитель 5d7c3b52ed
Коммит 9399398e04
8 изменённых файлов: 593 добавлений и 4 удалений

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

@@ -0,0 +1,60 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package commands
import (
"context"
"fmt"
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/client"
"github.com/spf13/cobra"
)
var ComplianceExportCmd = &cobra.Command{
Use: "compliance_export",
Short: "Management of compliance exports",
}
var ComplianceExportListCmd = &cobra.Command{
Use: "list",
Aliases: []string{"ls"},
Short: "List compliance export jobs, sorted by creation date descending (newest first)",
Args: cobra.NoArgs,
RunE: withClient(complianceExportListCmdF),
}
var ComplianceExportShowCmd = &cobra.Command{
Use: "show [complianceExportJobID]",
Example: " compliance_export show o98rj3ur83dp5dppfyk5yk6osy",
Short: "Show compliance export job",
Args: cobra.ExactArgs(1),
RunE: withClient(complianceExportShowCmdF),
}
func init() {
ComplianceExportListCmd.Flags().Int("page", 0, "Page number to fetch for the list of compliance export jobs")
ComplianceExportListCmd.Flags().Int("per-page", DefaultPageSize, "Number of compliance export jobs to be fetched")
ComplianceExportListCmd.Flags().Bool("all", false, "Fetch all compliance export jobs. --page flag will be ignored if provided")
ComplianceExportCmd.AddCommand(
ComplianceExportListCmd,
ComplianceExportShowCmd,
)
RootCmd.AddCommand(ComplianceExportCmd)
}
func complianceExportListCmdF(c client.Client, command *cobra.Command, args []string) error {
return jobListCmdF(c, command, "message_export", "")
}
func complianceExportShowCmdF(c client.Client, command *cobra.Command, args []string) error {
job, _, err := c.GetJob(context.TODO(), args[0])
if err != nil {
return fmt.Errorf("failed to get compliance export job: %w", err)
}
printJob(job)
return nil
}