(svc advancedAppServices, parent commandParent)
| 41 | } |
| 42 | |
| 43 | func (c *commandRepositoryCreate) setup(svc advancedAppServices, parent commandParent) { |
| 44 | cmd := parent.Command("create", "Create new repository in a specified location.") |
| 45 | |
| 46 | cmd.Flag("block-hash", "Content hash algorithm.").PlaceHolder("ALGO").Default(hashing.DefaultAlgorithm).EnumVar(&c.createBlockHashFormat, hashing.SupportedAlgorithms()...) |
| 47 | cmd.Flag("encryption", "Content encryption algorithm.").PlaceHolder("ALGO").Default(encryption.DefaultAlgorithm).EnumVar(&c.createBlockEncryptionFormat, encryption.SupportedAlgorithms(false)...) |
| 48 | cmd.Flag("ecc", "[EXPERIMENTAL] Error correction algorithm.").PlaceHolder("ALGO").Default(ecc.DefaultAlgorithm).EnumVar(&c.createBlockECCFormat, ecc.SupportedAlgorithms()...) |
| 49 | cmd.Flag("ecc-overhead-percent", "[EXPERIMENTAL] How much space overhead can be used for error correction, in percentage. Use 0 to disable ECC.").Default("0").IntVar(&c.createBlockECCOverheadPercent) |
| 50 | cmd.Flag("object-splitter", "The splitter to use for new objects in the repository").Default(splitter.DefaultAlgorithm).EnumVar(&c.createSplitter, splitter.SupportedAlgorithms()...) |
| 51 | cmd.Flag("create-only", "Create repository, but don't connect to it.").Short('c').BoolVar(&c.createOnly) |
| 52 | cmd.Flag("format-version", "Force a particular repository format version (1, 2 or 3, 0==default)").IntVar(&c.createFormatVersion) |
| 53 | cmd.Flag("retention-mode", "Set the blob retention-mode for supported storage backends.").EnumVar(&c.retentionMode, blob.Governance.String(), blob.Compliance.String()) |
| 54 | cmd.Flag("retention-period", "Set the blob retention-period for supported storage backends.").DurationVar(&c.retentionPeriod) |
| 55 | //nolint:lll |
| 56 | cmd.Flag("format-block-key-derivation-algorithm", "Algorithm to derive the encryption key for the format block from the repository password").Default(format.DefaultKeyDerivationAlgorithm).EnumVar(&c.createBlockKeyDerivationAlgorithm, format.SupportedFormatBlobKeyDerivationAlgorithms()...) |
| 57 | |
| 58 | c.co.setup(svc, cmd) |
| 59 | c.svc = svc |
| 60 | c.out.setup(svc) |
| 61 | |
| 62 | for _, prov := range svc.storageProviders() { |
| 63 | // Set up 'create' subcommand |
| 64 | f := prov.NewFlags() |
| 65 | cc := cmd.Command(prov.Name, "Create repository in "+prov.Description) |
| 66 | f.Setup(svc, cc) |
| 67 | cc.Action(func(kpc *kingpin.ParseContext) error { |
| 68 | return svc.runAppWithContext(kpc.SelectedCommand, func(ctx context.Context) error { |
| 69 | st, err := f.Connect(ctx, true, c.createFormatVersion) |
| 70 | if err != nil { |
| 71 | return errors.Wrap(err, "can't connect to storage") |
| 72 | } |
| 73 | |
| 74 | return c.runCreateCommandWithStorage(ctx, st) |
| 75 | }) |
| 76 | }) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | func (c *commandRepositoryCreate) newRepositoryOptionsFromFlags() *repo.NewRepositoryOptions { |
| 81 | return &repo.NewRepositoryOptions{ |
nothing calls this directly
no test coverage detected