common

package
v1.63.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MetaFlag = cli.StringSliceFlag{
	Name:  "meta",
	Usage: "key=value label recorded in the object; repeatable",
}

MetaFlag is the repeatable --meta key=value flag of the commands that write a commit or a pin.

View Source
var RechunkFlag = cli.BoolFlag{
	Name:  "rechunk",
	Usage: "cut an existing destination with the backup's chunker, so parts that only moved are not downloaded",
}

RechunkFlag turns --rechunk on a restore command.

View Source
var SalvageFlag = cli.BoolFlag{
	Name:  "salvage",
	Usage: "write what can be read when parts are missing, leaving holes, and report them",
}

SalvageFlag turns --salvage on a restore command.

View Source
var View = gen.MapperImpl{}

View turns what a command did into what its JSON output shows.

Functions

func AgentID

func AgentID(c *cli.Context) string

AgentID is the global --agent-id flag, or the hostname.

func BlobCache

func BlobCache(c *cli.Context, repo *goback.Repo) *blobcache.Cache

BlobCache opens the repo's blob cache under --cache-dir, or exits. It returns nil when --cache-dir is unset.

func CloseRepo

func CloseRepo(repo *goback.Repo)

CloseRepo compacts the store when it can, then closes it and its index.

func Context

func Context(c *cli.Context) context.Context

Context returns the command's context: cancelled by the first SIGINT or SIGTERM, with a second signal ending the process as usual, and carrying the agent as the principal.

func Env

func Env(c *cli.Context, repo *goback.Repo, caches goback.Caches) *job.Env

Env is the job environment of repo with the caches c names, or exits. The programs runs start write to stderr as they are. Close it before the repo.

func Fail

func Fail(msg string)

Fail reports that a command failed: in JSON mode as an error object on stdout, otherwise as an error in the log.

func FailError

func FailError(err error)

FailError reports that a command failed with err, as Fail does with its message; in JSON mode the error object also carries err's gRPC status code name as "code", if err carries one.

func Fatal

func Fatal(v ...any)

Fatal fails the command with the values' message, as log.Fatal would, and exits 1. The first error among v gives the JSON error its code.

func Fatalf

func Fatalf(format string, v ...any)

Fatalf fails the command with the formatted message and exits 1. The first error among v gives the JSON error its code.

func Fatalln

func Fatalln(v ...any)

Fatalln fails the command as log.Fatalln would and exits 1. The first error among v gives the JSON error its code.

func GetRetention

func GetRetention(index backup.Index) backup.Retention

GetRetention returns the index's retention interface or exits.

func Graceful

func Graceful(c *cli.Context, grace time.Duration) (context.Context, <-chan struct{})

Graceful returns a context for a command that runs until SIGTERM: stop closes on the first SIGINT or SIGTERM, and ctx ends on the second or once grace has passed since the first. ctx carries the agent as the principal.

func JSON

func JSON() bool

JSON reports whether the command was asked for JSON output.

func Metadata

func Metadata(c *cli.Context) map[string]string

Metadata parses the --meta values; a bare key gets an empty value.

func OpenRepo

func OpenRepo(c *cli.Context) *goback.Repo

OpenRepo opens the store the global flags name, or exits. Close it with CloseRepo.

func ParseRef

func ParseRef(s string) *proto.Ref

ParseRef decodes a ref printed as hex.

func Restorer

func Restorer(c *cli.Context, repo *goback.Repo) *backup.Restorer

Restorer is a restorer of repo set up from the restore flags shared by commit restore and file restore, or exits.

func Result

func Result(v any, text func())

Result reports what a command produced: v as JSON on stdout in JSON mode, otherwise whatever text prints.

func SetOutput

func SetOutput(json bool)

SetOutput sets up a command's output: logs as text on stderr, or with json set as JSON lines on stderr, with results and errors as JSON on stdout. Output of the log package goes through the same handler.

func Settings

func Settings(c *cli.Context) (goback.Settings, error)

Settings are the store settings the global flags give.

func StoreKey

func StoreKey(c *cli.Context, repo *goback.Repo) *storekey.Key

StoreKey is the store key the global flags name, or exits. It is nil for a store written in the clear.

func SweepBlobCache

func SweepBlobCache(cache *blobcache.Cache)

SweepBlobCache trims the cache to its size limit and logs the result.

Types

type Done

type Done struct {
	Action string `json:"action"`
	Ref    string `json:"ref,omitempty"`
	Name   string `json:"name,omitempty"`
}

Done is the result of a command that changed something and has nothing more to say than what it changed.

Directories

Path Synopsis
Package views is what goback's commands print as JSON.
Package views is what goback's commands print as JSON.
gen

Jump to

Keyboard shortcuts

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