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 CAS
- type Filter
- type PathInfo
- type Rule
- type Settings
- func (s *Settings) FindAddress() (string, bool)
- func (s *Settings) OpenStore(ctx context.Context) (CAS, error)
- func (s *Settings) OpenStoreAddress(_ context.Context, addr string) (CAS, error)
- func (s *Settings) ResolveAddress(addr string) string
- func (s *Settings) WithStore(ctx context.Context, f func(CAS) error) error
- func (s *Settings) WithStoreAddress(ctx context.Context, addr string, f func(CAS) error) error
- 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 CAS ¶
CAS is a wrapper around a blob.CAS that adds methods to expose the root and data buckets.
Tools using this package partition the keyspace into two buckets. The "data" bucket comprises all content-addressed keys; the "roots" bucket is for all other (non-content-addressed) keys. This is mapped onto the underlying store by appending the suffix "." (Unicode 46) to data keys, and "@" (Unicode 64) to root keys.
The methods of the CAS access the data keyspace by default; call Roots to derive a view of the root keyspace.
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"` // 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) FindAddress ¶
FindAddress reports whether s has a storage server address, and returns it if so. If a tag was selected but not matched, it is returned.
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) OpenStoreAddress ¶
OpenStoreAddress connects to the store service at addr. 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 expanded form of the tag is returned; otherwise addr is returned unmodified.