client

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigcheckCmd = &cli.Subcommand{
	Use:   "configcheck",
	Short: "check if config can be parsed without errors",
	SetupFlags: func(f *pflag.FlagSet) {
		f.StringVar(&configcheckArgs.format, "format", "", "dump parsed config object [pretty|yaml|json]")
		f.StringVar(&configcheckArgs.what, "what", "all", "what to print [all|config|jobs|logging]")
		f.BoolVar(&configcheckArgs.skipCertCheck, "skip-cert-check", false, "skip checking cert files")
	},
	Run: func(ctx context.Context, subcommand *cli.Subcommand, args []string) error {
		formatMap := map[string]func(interface{}){
			"": func(i interface{}) {},
			"pretty": func(i interface{}) {
				if _, err := pretty.Println(i); err != nil {
					panic(err)
				}
			},
			"json": func(i interface{}) {
				if err := json.NewEncoder(os.Stdout).Encode(subcommand.Config()); err != nil {
					panic(err)
				}
			},
			"yaml": func(i interface{}) {
				if err := yaml.NewEncoder(os.Stdout).Encode(subcommand.Config()); err != nil {
					panic(err)
				}
			},
		}

		formatter, ok := formatMap[configcheckArgs.format]
		if !ok {
			return fmt.Errorf("unsupported --format %q", configcheckArgs.format)
		}

		var hadErr bool

		parseFlags := config.ParseFlagsNone

		if configcheckArgs.skipCertCheck {
			parseFlags |= config.ParseFlagsNoCertCheck
		}

		confJobs, err := job.JobsFromConfig(subcommand.Config(), parseFlags)

		if err != nil {
			err := errors.Wrap(err, "cannot build jobs from config")
			if configcheckArgs.what == "jobs" {
				return err
			} else {
				fmt.Fprintf(os.Stderr, "%s\n", err)
				confJobs = nil
				hadErr = true
			}
		}

		outlets, err := logging.OutletsFromConfig(*subcommand.Config().Global.Logging)
		if err != nil {
			err := errors.Wrap(err, "cannot build logging from config")
			if configcheckArgs.what == "logging" {
				return err
			} else {
				fmt.Fprintf(os.Stderr, "%s\n", err)
				outlets = nil
				hadErr = true
			}
		}

		whatMap := map[string]func(){
			"all": func() {
				o := struct {
					config  *config.Config
					jobs    []job.Job
					logging *logger.Outlets
				}{
					subcommand.Config(),
					confJobs,
					outlets,
				}
				formatter(o)
			},
			"config": func() {
				formatter(subcommand.Config())
			},
			"jobs": func() {
				formatter(confJobs)
			},
			"logging": func() {
				formatter(outlets)
			},
		}

		wf, ok := whatMap[configcheckArgs.what]
		if !ok {
			return fmt.Errorf("unsupported --format %q", configcheckArgs.what)
		}
		wf()

		if hadErr {
			return fmt.Errorf("config parsing failed")
		} else {
			return nil
		}
	},
}
View Source
var (
	MigrateCmd = &cli.Subcommand{
		Use:   "migrate",
		Short: "perform migration of the on-disk / zfs properties",
		SetupSubcommands: func() []*cli.Subcommand {
			return migrations
		},
	}
)
View Source
var PprofCmd = &cli.Subcommand{
	Use: "pprof",
	SetupSubcommands: func() []*cli.Subcommand {
		return []*cli.Subcommand{PprofListenCmd, pprofActivityTraceCmd}
	},
}
View Source
var PprofListenCmd = &cli.Subcommand{
	Use:   "listen off | [on TCP_LISTEN_ADDRESS]",
	Short: "start a http server exposing go-tool-compatible profiling endpoints at TCP_LISTEN_ADDRESS",
	Run: func(ctx context.Context, subcommand *cli.Subcommand, args []string) error {
		if len(args) < 1 {
			goto enargs
		}
		switch args[0] {
		case "on":
			pprofListenCmd.Run = true
			if len(args) != 2 {
				return errors.New("must specify TCP_LISTEN_ADDRESS as second positional argument")
			}
			pprofListenCmd.HttpListenAddress = args[1]
		case "off":
			if len(args) != 1 {
				goto enargs
			}
			pprofListenCmd.Run = false
		}

		RunPProf(subcommand.Config())
		return nil
	enargs:
		return errors.New("invalid number of positional arguments")

	},
}
View Source
var SignalCmd = &cli.Subcommand{
	Use:   "signal [wakeup|reset] JOB",
	Short: "wake up a job from wait state or abort its current invocation",
	Run: func(ctx context.Context, subcommand *cli.Subcommand, args []string) error {
		return runSignalCmd(subcommand.Config(), args)
	},
}
View Source
var StdinserverCmd = &cli.Subcommand{
	Use:   "stdinserver CLIENT_IDENTITY",
	Short: "stdinserver transport mode (started from authorized_keys file as forced command)",
	Run: func(ctx context.Context, subcommand *cli.Subcommand, args []string) error {
		return runStdinserver(subcommand.Config(), args)
	},
}
View Source
var TestCmd = &cli.Subcommand{
	Use: "test",
	SetupSubcommands: func() []*cli.Subcommand {
		return []*cli.Subcommand{testFilter, testPlaceholder, testDecodeResumeToken}
	},
}
View Source
var VersionCmd = &cli.Subcommand{
	Use:             "version",
	Short:           "print version of zrepl binary and running daemon",
	NoRequireConfig: true,
	SetupFlags: func(f *pflag.FlagSet) {
		f.StringVar(&versionArgs.Show, "show", "", "version info to show (client|daemon)")
	},
	Run: func(ctx context.Context, subcommand *cli.Subcommand, args []string) error {
		versionArgs.Config = subcommand.Config()
		versionArgs.ConfigErr = subcommand.ConfigParsingError()
		return runVersionCmd()
	},
}
View Source
var (
	ZFSAbstractionsCmd = &cli.Subcommand{
		Use:   "zfs-abstraction",
		Short: "manage abstractions that zrepl builds on top of ZFS",
		SetupSubcommands: func() []*cli.Subcommand {
			return []*cli.Subcommand{
				zabsCmdList,
				zabsCmdReleaseAll,
				zabsCmdReleaseStale,
				zabsCmdCreate,
			}
		},
	}
)

Functions

func RunPProf

func RunPProf(conf *config.Config)

Types

type AbstractionTypesFlag added in v0.3.0

type AbstractionTypesFlag map[endpoint.AbstractionType]bool

func (AbstractionTypesFlag) FlagValue added in v0.3.0

func (*AbstractionTypesFlag) Set added in v0.3.0

func (f *AbstractionTypesFlag) Set(s string) error

func (AbstractionTypesFlag) String added in v0.3.0

func (f AbstractionTypesFlag) String() string

func (AbstractionTypesFlag) Type added in v0.3.0

func (f AbstractionTypesFlag) Type() string

type FilesystemsFilterFlag added in v0.3.0

type FilesystemsFilterFlag struct {
	F endpoint.ListZFSHoldsAndBookmarksQueryFilesystemFilter
}

func (FilesystemsFilterFlag) FlagValue added in v0.3.0

func (*FilesystemsFilterFlag) Set added in v0.3.0

func (flag *FilesystemsFilterFlag) Set(s string) error

func (FilesystemsFilterFlag) String added in v0.3.0

func (flag FilesystemsFilterFlag) String() string

func (FilesystemsFilterFlag) Type added in v0.3.0

func (flag FilesystemsFilterFlag) Type() string

type JobIDFlag added in v0.3.0

type JobIDFlag struct{ J *endpoint.JobID }

func (JobIDFlag) FlagValue added in v0.3.0

func (f JobIDFlag) FlagValue() *endpoint.JobID

func (*JobIDFlag) Set added in v0.3.0

func (f *JobIDFlag) Set(s string) error

func (JobIDFlag) String added in v0.3.0

func (f JobIDFlag) String() string

func (JobIDFlag) Type added in v0.3.0

func (f JobIDFlag) Type() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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