storage

package
v0.5.17-RC1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2025 License: Apache-2.0, MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommonConfigFlags = []cli.Flag{
	&cli.IntFlag{
		Name:        "client-retry-max",
		Usage:       "Max number of retries for IO read errors",
		DefaultText: "10",
		Category:    "Retry Strategy",
	},
	&cli.DurationFlag{
		Name:        "client-retry-delay",
		Usage:       "The initial delay before retrying IO read errors",
		DefaultText: "1s",
		Category:    "Retry Strategy",
	},
	&cli.DurationFlag{
		Name:        "client-retry-backoff",
		Usage:       "The constant delay backoff for retrying IO read errors",
		DefaultText: "1s",
		Category:    "Retry Strategy",
	},
	&cli.Float64Flag{
		Name:        "client-retry-backoff-exp",
		Usage:       "The exponential delay backoff for retrying IO read errors",
		DefaultText: "1.0",
		Category:    "Retry Strategy",
	},
	&cli.BoolFlag{
		Name:     "client-skip-inaccessible",
		Usage:    "Skip inaccessible files when opening",
		Category: "Retry Strategy",
	},
	&cli.IntFlag{
		Name:        "client-low-level-retries",
		Usage:       "Maximum number of retries for low-level client errors",
		DefaultText: "10",
		Category:    "Retry Strategy",
	},
	&cli.IntFlag{
		Name:        "client-scan-concurrency",
		Usage:       "Max number of concurrent listing requests when scanning data source",
		DefaultText: "1",
		Category:    "Client Config",
	},
}
View Source
var CreateCmd = &cli.Command{
	Name:  "create",
	Usage: "Create a new storage which can be used as source or output",
	Subcommands: underscore.Map(storagesystem.Backends, func(backend storagesystem.Backend) *cli.Command {
		if len(backend.ProviderOptions) > 1 {
			return &cli.Command{
				Name:  backend.Prefix,
				Usage: backend.Description,
				Subcommands: underscore.Map(backend.ProviderOptions, func(providerOption storagesystem.ProviderOptions) *cli.Command {
					command := providerOption.ToCLICommand(strings.ToLower(providerOption.Provider), providerOption.Provider, providerOption.ProviderDescription)
					command.Action = func(c *cli.Context) error {
						return createAction(c, backend.Prefix, providerOption.Provider)
					}
					command.Flags = append(command.Flags, &cli.StringFlag{
						Name:        "name",
						Usage:       "Name of the storage",
						DefaultText: "Auto generated",
						Category:    "General",
					}, &cli.StringFlag{
						Name:     "path",
						Usage:    "Path of the storage",
						Category: "General",
						Required: true,
					})
					command.Flags = append(command.Flags, httpClientConfigFlags...)
					command.Flags = append(command.Flags, CommonConfigFlags...)
					return command
				}),
			}
		}
		command := backend.ProviderOptions[0].ToCLICommand(backend.Prefix, backend.Name, backend.Description)
		command.Action = func(c *cli.Context) error {
			return createAction(c, backend.Prefix, "")
		}
		command.Flags = append(command.Flags, &cli.StringFlag{
			Name:        "name",
			Usage:       "Name of the storage",
			DefaultText: "Auto generated",
			Category:    "General",
		}, &cli.StringFlag{
			Name:     "path",
			Usage:    "Path of the storage",
			Category: "General",
			Required: true,
		})
		if backend.Prefix != localStorageType {
			command.Flags = append(command.Flags, httpClientConfigFlags...)
		}
		command.Flags = append(command.Flags, CommonConfigFlags...)
		return command
	}),
}
View Source
var ExploreCmd = &cli.Command{
	Name:      "explore",
	Usage:     "Explore a storage by listing all entries under a path",
	ArgsUsage: "<name|id> [path]",
	Before:    cliutil.CheckNArgs,
	Action: func(c *cli.Context) error {
		db, closer, err := database.OpenFromCLI(c)
		if err != nil {
			return errors.WithStack(err)
		}
		defer closer.Close()

		entries, err := storage.Default.ExploreHandler(c.Context, db, c.Args().Get(0), c.Args().Get(1))
		if err != nil {
			return errors.WithStack(err)
		}
		cliutil.Print(c, entries)
		return nil
	},
}
View Source
var HTTPClientConfigFlagsForUpdate = []cli.Flag{
	&cli.DurationFlag{
		Name:        "client-connect-timeout",
		Usage:       "HTTP Client Connect timeout",
		DefaultText: defaultClientConfig.ConnectTimeout.String(),
		Category:    "Client Config",
	},
	&cli.DurationFlag{
		Name:        "client-timeout",
		Usage:       "IO idle timeout",
		DefaultText: defaultClientConfig.Timeout.String(),
		Category:    "Client Config",
	},
	&cli.DurationFlag{
		Name:        "client-expect-continue-timeout",
		Usage:       "Timeout when using expect / 100-continue in HTTP",
		DefaultText: defaultClientConfig.ExpectContinueTimeout.String(),
		Category:    "Client Config",
	},
	&cli.BoolFlag{
		Name:        "client-insecure-skip-verify",
		Usage:       "Do not verify the server SSL certificate (insecure)",
		DefaultText: "false",
		Category:    "Client Config",
	},
	&cli.BoolFlag{
		Name:        "client-no-gzip",
		Usage:       "Don't set Accept-Encoding: gzip",
		DefaultText: "false",
		Category:    "Client Config",
	},
	&cli.StringFlag{
		Name:        "client-user-agent",
		Usage:       "Set the user-agent to a specified string. To remove, use empty string.",
		DefaultText: defaultClientConfig.UserAgent,
		Category:    "Client Config",
	},
	&cli.PathFlag{
		Name:     "client-ca-cert",
		Usage:    "Path to CA certificate used to verify servers. To remove, use empty string.",
		Category: "Client Config",
	},
	&cli.PathFlag{
		Name:     "client-cert",
		Usage:    "Path to Client SSL certificate (PEM) for mutual TLS auth. To remove, use empty string.",
		Category: "Client Config",
	},
	&cli.PathFlag{
		Name:     "client-key",
		Usage:    "Path to Client SSL private key (PEM) for mutual TLS auth. To remove, use empty string.",
		Category: "Client Config",
	},
	&cli.StringSliceFlag{
		Name:     "client-header",
		Usage:    "Set HTTP header for all transactions (i.e. key=value). This will replace the existing header values. To remove a header, use --http-header \"key=\"\". To remove all headers, use --http-header \"\"",
		Category: "Client Config",
	},
	&cli.BoolFlag{
		Name:     "client-use-server-mod-time",
		Usage:    "Use server modified time if possible",
		Category: "Client Config",
	},
}
View Source
var ListCmd = &cli.Command{
	Name:  "list",
	Usage: "List all storage system connections",
	Action: func(c *cli.Context) error {
		db, closer, err := database.OpenFromCLI(c)
		if err != nil {
			return errors.WithStack(err)
		}
		defer closer.Close()

		storages, err := storage.Default.ListStoragesHandler(c.Context, db)
		if err != nil {
			return errors.WithStack(err)
		}
		cliutil.Print(c, storages)
		return nil
	},
}
View Source
var RemoveCmd = &cli.Command{
	Name:      "remove",
	Usage:     "Remove a storage connection if it's not used by any preparation",
	ArgsUsage: "<name|id>",
	Before:    cliutil.CheckNArgs,
	Action: func(c *cli.Context) error {
		db, closer, err := database.OpenFromCLI(c)
		if err != nil {
			return errors.WithStack(err)
		}
		defer closer.Close()

		err = storage.Default.RemoveHandler(c.Context, db, c.Args().Get(0))
		if err != nil {
			return errors.WithStack(err)
		}
		return nil
	},
}
View Source
var RenameCmd = &cli.Command{
	Name:      "rename",
	Usage:     "Rename a storage system connection",
	ArgsUsage: "<name|id> <new_name>",
	Before:    cliutil.CheckNArgs,
	Action: func(c *cli.Context) error {
		db, closer, err := database.OpenFromCLI(c)
		if err != nil {
			return errors.WithStack(err)
		}
		defer closer.Close()

		storage, err := storage.Default.RenameStorageHandler(c.Context, db, c.Args().Get(0), storage.RenameRequest{Name: c.Args().Get(1)})
		if err != nil {
			return errors.WithStack(err)
		}
		cliutil.Print(c, storage)
		return nil
	},
}
View Source
var UpdateCmd = &cli.Command{
	Name:  "update",
	Usage: "Update the configuration of an existing storage connection",
	Subcommands: underscore.Map(storagesystem.Backends, func(backend storagesystem.Backend) *cli.Command {
		if len(backend.ProviderOptions) > 1 {
			return &cli.Command{
				Name:  backend.Prefix,
				Usage: backend.Description,
				Subcommands: underscore.Map(backend.ProviderOptions, func(providerOption storagesystem.ProviderOptions) *cli.Command {
					command := providerOption.ToCLICommand(strings.ToLower(providerOption.Provider), providerOption.Provider, providerOption.ProviderDescription)
					command.Action = func(c *cli.Context) error {
						return updateAction(c, backend.Prefix, providerOption.Provider)
					}
					command.ArgsUsage = "<name|id>"
					command.Before = cliutil.CheckNArgs
					command.Flags = append(command.Flags, HTTPClientConfigFlagsForUpdate...)
					command.Flags = append(command.Flags, CommonConfigFlags...)
					return command
				}),
			}
		}
		command := backend.ProviderOptions[0].ToCLICommand(backend.Prefix, backend.Name, backend.Description)
		command.Action = func(c *cli.Context) error {
			return updateAction(c, backend.Prefix, "")
		}
		command.ArgsUsage = "<name|id>"
		command.Before = cliutil.CheckNArgs
		if backend.Prefix != "local" {
			command.Flags = append(command.Flags, HTTPClientConfigFlagsForUpdate...)
		}
		command.Flags = append(command.Flags, CommonConfigFlags...)
		return command
	}),
}

Functions

func GetClientConfigForUpdate added in v0.5.0

func GetClientConfigForUpdate(c *cli.Context) (*model.ClientConfig, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL