config

package
v0.0.0-...-c24ad15 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package config defines the configuration settings shared by the subcommands of the ffs command-line tool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandString

func ExpandString(s *string)

ExpandString calls os.ExpandEnv to expand environment variables in *s. The value of *s is replaced.

func OpenStore

func OpenStore(_ context.Context, addr string) (blob.CAS, error)

OpenStore connects to the store service at addr. The caller is responsible for closing the store when it is no longer needed.

func ParseKey

func ParseKey(s string) (string, error)

ParseKey parses the string encoding of a key. By default, s must be hex encoded. If s begins with "@", it is taken literally. If s begins with "+" it is taken as base64.

func PrintableKey

func PrintableKey(key string) interface{}

PrintableKey converts key into a value that will marshal into JSON as a sensible human-readable string.

func RootKey

func RootKey(s string) string

RootKey converts s into a root key.

func RootKeys

func RootKeys(args []string) ([]string, error)

RootKeys returns a slice of root keys from args, or an error if any of the keys is invalid.

func ToJSON

func ToJSON(msg interface{}) string

ToJSON converts a value to indented JSON.

func WithStore

func WithStore(ctx context.Context, addr string, f func(blob.CAS) error) error

WithStore calls f with a store opened at addr. The store is closed after f returns. The error returned by f is returned by WithStore.

Types

type Settings

type Settings struct {
	// Context value governing the execution of the tool.
	Context context.Context `json:"-" yaml:"-"`

	// The default address for the blob store service (required).
	StoreAddress string `json:"storeAddress" yaml:"store-address"`
}

Settings represents the stored configuration settings for the ffs tool.

func Load

func Load(path string) (*Settings, error)

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

func (s *Settings) OpenStore(ctx context.Context) (blob.CAS, error)

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) WithStore

func (s *Settings) WithStore(ctx context.Context, f func(blob.CAS) error) error

WithStore calls f with a store opened from the configuration. The store is closed after f returns. The error returned by f is returned by WithStore.

Jump to

Keyboard shortcuts

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