Documentation ¶
Overview ¶
Package config defines the configuration settings shared by the subcommands of the ffs command-line tool.
Index ¶
- Constants
- func Dial(ntype, addr string) (net.Conn, error)
- func ExpandString(s *string)
- func FormatKey(key string) string
- func LoadIndex(ctx context.Context, s blob.CAS, key string) (*index.Index, error)
- func ParseKey(s string) (string, error)
- func Path() string
- func PrintableKey(key string) any
- func SplitPath(s string) (first, rest string)
- func ToJSON(msg any) string
- type Filter
- type PathInfo
- type Rule
- type Settings
- func (s *Settings) OpenStore(ctx context.Context) (Store, error)
- func (s *Settings) ResolveAddress(addr string) StoreSpec
- func (s *Settings) ResolveSpec(spec string) StoreSpec
- func (s *Settings) WithStore(ctx context.Context, f func(Store) error) error
- func (s *Settings) WithStoreAddress(ctx context.Context, addr string, f func(Store) error) error
- type Store
- type StoreSpec
Constants ¶
const DefaultPath = "$HOME/.config/ffs/config.yml"
DefaultPath is the configuration file path used if not overridden by the FFS_CONFIG environment variable.
Variables ¶
This section is empty.
Functions ¶
func Dial ¶
Dial calls net.Dial with the specified arguments. If they succeed and ntype is not "unix", the resulting connection is wrapped to redial the address if the connection fails during a read or write (ECONNRESET or ECONNABORTED).
If redial succeeds, the failed Read or Write operation is transparently retried; otherwise the original error is propagated to the caller.
func ExpandString ¶
func ExpandString(s *string)
ExpandString calls os.ExpandEnv to expand environment variables in *s. The value of *s is replaced.
func ParseKey ¶
ParseKey parses the string encoding of a key. A key must be a hex string, a base64 string, or a literal string prefixed with "@":
@foo encodes "foo" @@foo encodes "@foo" 414243 encodes "ABC" eHl6enk= encodes "xyzzy"
func Path ¶
func Path() string
Path returns the effective configuration file path. If FFS_CONFIG is set, its value is used; otherwise DefaultPath is expanded.
func PrintableKey ¶
PrintableKey converts key into a value that will marshal into JSON as a sensible human-readable string.
Types ¶
type Filter ¶
Filter is a collection of path filters used to control what parts of a file tree get copied by "put" operations. Each line of a filter file specifies a glob matching a filename. By default, all files are included, and any file matching a rule is filtered out.
Each directory is checked for a filter file, which governs paths under that directory. If a rule is prefixed with "!", a match of that rule inverts the sense of the parent directory for that path, including if it was filtered and vice versa.
type PathInfo ¶
type PathInfo struct { Path string // the original input path (unparsed) Base *file.File // the root or starting file of the path BaseKey string // the storage key of the base file File *file.File // the target file of the path FileKey string // the storage key of the target file Root *root.Root // the specified root, or nil if none RootKey string // the key of root, or "" }
PathInfo is the result of parsing and opening a path spec.
type Rule ¶
type Rule struct { *regexp.Regexp // the compiled glob expression Negate bool // whether this rule negates a parent match }
A Rule is a single filter rule.
type Settings ¶
type Settings struct { // The default address for the blob store service (required). This must be // either a store tag (@name) or an address. DefaultStore string `json:"defaultStore" yaml:"default-store"` // The default method name prefix to use for the service. ServicePrefix string `json:"servicePrefix" yaml:"service-prefix"` // The substore name to use within the service. Substore string `json:"substore" yaml:"substore"` // Enable debug logging for the storage service. EnableDebugLogging bool `json:"enableDebugLogging" yaml:"enable-debug-logging"` // Well-known store specifications, addressable by tag. Stores []*StoreSpec `json:"stores" yaml:"stores"` }
Settings represents the stored configuration settings for the ffs tool.
func Load ¶
Load reads and parses the contents of a config file from path. If the specified path does not exist, an empty config is returned without error.
func (*Settings) OpenStore ¶
OpenStore connects to the store service address in the configuration. The caller is responsible for closing the store when it is no longer needed.
func (*Settings) ResolveAddress ¶
ResolveAddress resolves the given address against the settings. If addr is of the form @tag and that tag exists in the settings, the spec for that tag is returned; otherwise it returns a spec whose address is addr.
As a special case, if @tag has the form "@tag+name", the name without the separator is used as a substore indicator, overriding the config.
As a special case, if the address has a "+name" suffix, the name without the separator is used as a substore indicator.
func (*Settings) ResolveSpec ¶ added in v0.9.2
ResolveSpec resolves the given store spec against the settings. If spec is of the form @tag and that tag exists in the settings, the expanded form of that spec is returned; otherwise it returns a verbatim spec.
type Store ¶ added in v0.10.0
type Store struct {
// contains filtered or unexported fields
}
Store is a wrapper around a store that adds methods to expose the root and data buckets.
type StoreSpec ¶
type StoreSpec struct { Tag string `json:"tag" yaml:"tag"` // identifies the spec Address string `json:"address" yaml:"address"` // the listen address Spec string `json:"spec" yaml:"spec"` // the desired storage URL Prefix string `json:"prefix" yaml:"prefix"` // service method name prefix Substore string `json:"substore" yaml:"substore"` // substore name (optional) }
A StoreSpec associates a tag (handle) with a storage address.