[MM-63555] mmctl: Add compliance export show and cancel cmds (#30569)

* add compliance export cancel command and tests

- Introduced `ComplianceExportCancelCmd` to allow cancellation of compliance export jobs.
- Implemented unit tests for the cancellation command, covering successful cancellation, error handling for non-existent jobs, and cancellation in non-cancellable states.
- Added end-to-end tests to validate the command's functionality in the E2E test suite.

* mmctl docs

* clean up example text; remove unneeded getJob

* fix tests

* fix tests, again.

* prefer hyphen for command naming

* update docs
Этот коммит содержится в:
Christopher Poile
2025-06-24 12:26:43 -04:00
коммит произвёл GitHub
родитель 9399398e04
Коммит e60f878090
8 изменённых файлов: 256 добавлений и 17 удалений

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

@@ -12,7 +12,7 @@ import (
)
var ComplianceExportCmd = &cobra.Command{
Use: "compliance_export",
Use: "compliance-export",
Short: "Management of compliance exports",
}
@@ -26,12 +26,20 @@ var ComplianceExportListCmd = &cobra.Command{
var ComplianceExportShowCmd = &cobra.Command{
Use: "show [complianceExportJobID]",
Example: " compliance_export show o98rj3ur83dp5dppfyk5yk6osy",
Example: "compliance-export show o98rj3ur83dp5dppfyk5yk6osy",
Short: "Show compliance export job",
Args: cobra.ExactArgs(1),
RunE: withClient(complianceExportShowCmdF),
}
var ComplianceExportCancelCmd = &cobra.Command{
Use: "cancel [complianceExportJobID]",
Example: "compliance-export cancel o98rj3ur83dp5dppfyk5yk6osy",
Short: "Cancel compliance export job",
Args: cobra.ExactArgs(1),
RunE: withClient(complianceExportCancelCmdF),
}
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")
@@ -40,6 +48,7 @@ func init() {
ComplianceExportCmd.AddCommand(
ComplianceExportListCmd,
ComplianceExportShowCmd,
ComplianceExportCancelCmd,
)
RootCmd.AddCommand(ComplianceExportCmd)
}
@@ -58,3 +67,11 @@ func complianceExportShowCmdF(c client.Client, command *cobra.Command, args []st
return nil
}
func complianceExportCancelCmdF(c client.Client, command *cobra.Command, args []string) error {
if _, err := c.CancelJob(context.TODO(), args[0]); err != nil {
return fmt.Errorf("failed to cancel compliance export job: %w", err)
}
return nil
}