33 lines
889 B
Go
33 lines
889 B
Go
|
package importer
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"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,
|
||
|
}
|
||
|
|
||
|
func runCmd(cmd *cobra.Command, args []string) error {
|
||
|
if len(args) < 2 {
|
||
|
return fmt.Errorf("expected at least two non-flag argumets: paths to the registry and to the pregenerated file, got: %s", args)
|
||
|
}
|
||
|
|
||
|
objRegistry := registry.NewObjRegistry(cmd.Context(), args[0])
|
||
|
for i := 1; i < len(args); i++ {
|
||
|
if err := registry.ImportJSONPreGen(objRegistry, args[i]); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|