fix(cli): fix varius cmds

- cmd backup consistency, fix flags
- revisions purge, fix flags
This commit is contained in:
Florian Schade
2025-12-12 13:32:55 +01:00
parent 5824d8df34
commit efb7e73195
2 changed files with 18 additions and 14 deletions

View File

@@ -4,6 +4,8 @@ import (
"errors"
"fmt"
"github.com/spf13/cobra"
"github.com/opencloud-eu/opencloud/opencloud/pkg/backup"
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
"github.com/opencloud-eu/opencloud/pkg/config"
@@ -11,7 +13,6 @@ import (
"github.com/opencloud-eu/opencloud/pkg/config/parser"
decomposedbs "github.com/opencloud-eu/reva/v2/pkg/storage/fs/decomposed/blobstore"
decomposeds3bs "github.com/opencloud-eu/reva/v2/pkg/storage/fs/decomposeds3/blobstore"
"github.com/spf13/cobra"
)
// BackupCommand is the entrypoint for the backup command
@@ -19,13 +20,9 @@ func BackupCommand(cfg *config.Config) *cobra.Command {
bckCmd := &cobra.Command{
Use: "backup",
Short: "OpenCloud backup functionality",
PreRunE: func(cmd *cobra.Command, args []string) error {
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return configlog.ReturnError(parser.ParseConfig(cfg, true))
},
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("Read the docs")
return nil
},
}
bckCmd.AddCommand(ConsistencyCommand(cfg))
return bckCmd
@@ -82,7 +79,7 @@ func ConsistencyCommand(cfg *config.Config) *cobra.Command {
if err != nil {
fmt.Println(err)
}
consCmd.Flags().StringP("blobstore", "b", "", "the blobstore type. Can be (none, decomposed, decomposeds3). Default decomposed")
consCmd.Flags().StringP("blobstore", "b", "decomposed", "the blobstore type. Can be (none, decomposed, decomposeds3). Default decomposed")
consCmd.Flags().Bool("fail", false, "exit with non-zero status if consistency check fails")
return consCmd
}

View File

@@ -6,6 +6,7 @@ import (
"path/filepath"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/opencloud-eu/opencloud/opencloud/pkg/register"
"github.com/opencloud-eu/opencloud/opencloud/pkg/revisions"
"github.com/opencloud-eu/opencloud/pkg/config"
@@ -29,13 +30,9 @@ func RevisionsCommand(cfg *config.Config) *cobra.Command {
revCmd := &cobra.Command{
Use: "revisions",
Short: "OpenCloud revisions functionality",
PreRunE: func(cmd *cobra.Command, args []string) error {
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return configlog.ReturnError(parser.ParseConfig(cfg, true))
},
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("Read the docs")
return nil
},
}
revCmd.AddCommand(PurgeRevisionsCommand(cfg))
@@ -113,8 +110,18 @@ func PurgeRevisionsCommand(cfg *config.Config) *cobra.Command {
ch = revisions.List(p, 10)
}
files, blobs, revisions := revisions.PurgeRevisions(ch, bs, cmd.Flag("dry-run").Changed, cmd.Flag("verbose").Changed)
printResults(files, blobs, revisions, cmd.Flag("dry-run").Changed)
flagDryRun, err := cmd.Flags().GetBool("dry-run")
if err != nil {
return err
}
flagVerbose, err := cmd.Flags().GetBool("verbose")
if err != nil {
return err
}
files, blobs, revisionResults := revisions.PurgeRevisions(ch, bs, flagDryRun, flagVerbose)
printResults(files, blobs, revisionResults, flagDryRun)
return nil
},
}