xk6-frostfs/cmd/xk6-registry/importer/root.go
Ekaterina Lebedeva 6d3ecb6528
All checks were successful
DCO action / DCO (pull_request) Successful in 1m52s
Tests and linters / Tests (1.22) (pull_request) Successful in 2m9s
Tests and linters / Tests with -race (pull_request) Successful in 2m12s
Tests and linters / Tests (1.21) (pull_request) Successful in 2m56s
Tests and linters / Lint (pull_request) Successful in 3m16s
[#154] Add registry import cli utility
* Currently, objects created in preset are never deleted.
  k6 deletes only objects from registry, if registry file
  is not provided k6 delete load fails.
* Added cli utility to import objects created in preset
  into registry so k6 can delete them normally.

Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
2024-08-23 13:41:01 +03:00

27 lines
748 B
Go

package importer
import (
"git.frostfs.info/TrueCloudLab/xk6-frostfs/internal/registry"
"github.com/spf13/cobra"
)
// Cmd represents the import command.
var Cmd = &cobra.Command{
Use: "import",
Short: "Import objects into registry",
Long: "Import objects into registry from pregenerated files",
Example: `xk6-registry import registry.bolt preset.json
xk6-registry import --status created registry.bolt preset.json another_preset.json`,
RunE: runCmd,
Args: cobra.MinimumNArgs(2),
}
func runCmd(cmd *cobra.Command, args []string) error {
objRegistry := registry.NewObjRegistry(cmd.Context(), args[0])
for i := 1; i < len(args); i++ {
if err := ImportJSONPreGen(objRegistry, args[i]); err != nil {
return err
}
}
return nil
}