forked from TrueCloudLab/xk6-frostfs
Ekaterina Lebedeva
6d3ecb6528
* 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>
27 lines
748 B
Go
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
|
|
}
|