state

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorEmptyState = errors.New("state is empty")
	ErrorNotFound   = errors.New("key not found in state")
	ErrorKeyExists  = errors.New("key already exists in state")
	ErrorReadOnly   = errors.New("state is read-only")
)
View Source
var (
	ErrorFileNotFound = errors.New("not found")
)

Functions

func ArgListContains added in v0.11.1

func ArgListContains(args Arguments, arg Argument) bool

func ArgumentTypesEqual

func ArgumentTypesEqual(arg Argument, argTypes ...ArgumentType) bool

func BucketAndPath added in v0.12.0

func BucketAndPath(u *url.URL) (string, string)

func EqualArgs added in v0.11.0

func EqualArgs(a []Argument, b []Argument) bool

EqualArgs checks that the argument list a and b are equal. We go out of our way to check equality despite the order. complexity o(n^2)

func GetValueAsString added in v0.11.0

func GetValueAsString(ctx context.Context, r Reader, arg Argument) (string, error)

func MustGetBool added in v0.11.0

func MustGetBool(s Handler, ctx context.Context, arg Argument) bool

func MustGetDirectory added in v0.11.0

func MustGetDirectory(s Handler, ctx context.Context, arg Argument) fs.FS

func MustGetDirectoryString added in v0.11.0

func MustGetDirectoryString(s Handler, ctx context.Context, arg Argument) string

func MustGetFile added in v0.11.0

func MustGetFile(s Handler, ctx context.Context, arg Argument) *os.File

func MustGetFloat64 added in v0.11.0

func MustGetFloat64(s Handler, ctx context.Context, arg Argument) float64

func MustGetInt64 added in v0.11.0

func MustGetInt64(s Handler, ctx context.Context, arg Argument) int64

func MustGetString added in v0.11.0

func MustGetString(s Handler, ctx context.Context, arg Argument) string

func SetValueFromJSON added in v0.11.0

func SetValueFromJSON(ctx context.Context, w Writer, value StateValueJSON) error

Types

type ArgMapReader

type ArgMapReader struct {
	// contains filtered or unexported fields
}

ArgMapReader attempts to read state values from the provided "ArgMap". The ArgMap is provided by the user by using the '-arg={key}={value}' argument. This is typically only used in local executions where some values will not be provided.

func NewArgMapReader

func NewArgMapReader(defaults args.ArgMap) *ArgMapReader

func (*ArgMapReader) Exists

func (s *ArgMapReader) Exists(ctx context.Context, arg Argument) (bool, error)

func (*ArgMapReader) GetBool

func (s *ArgMapReader) GetBool(ctx context.Context, arg Argument) (bool, error)

func (*ArgMapReader) GetDirectory

func (s *ArgMapReader) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)

func (*ArgMapReader) GetDirectoryString

func (s *ArgMapReader) GetDirectoryString(ctx context.Context, arg Argument) (string, error)

func (*ArgMapReader) GetFile

func (s *ArgMapReader) GetFile(ctx context.Context, arg Argument) (*os.File, error)

func (*ArgMapReader) GetFloat64

func (s *ArgMapReader) GetFloat64(ctx context.Context, arg Argument) (float64, error)

func (*ArgMapReader) GetInt64

func (s *ArgMapReader) GetInt64(ctx context.Context, arg Argument) (int64, error)

func (*ArgMapReader) GetString

func (s *ArgMapReader) GetString(ctx context.Context, arg Argument) (string, error)

type Argument

type Argument struct {
	Type ArgumentType
	Key  string
}

An Argument is a pre-defined argument that is used in a typical CI pipeline. This allows the scribe library to define different methods of retrieving the same information on various clients. For example, when running in CLI or Dagger client, getting the git ref might be as simple as running `git rev-parse HEAD`. But in a Drone pipeline, that information may be available before the repository has been cloned in an environment variable. Other arguments may require the user to be prompted if they have not been provided. These arguments can be provided to the CLI by using the flag `-arg`, for example `-arg=workdir=./example` will set the "workdir" argument to "example" in the CLI client. By default, all steps expect a WorkingDir and Repository.

func NewBoolArgument

func NewBoolArgument(key string) Argument

func NewDirectoryArgument

func NewDirectoryArgument(key string) Argument

func NewFileArgument

func NewFileArgument(key string) Argument

func NewFloat64Argument

func NewFloat64Argument(key string) Argument

func NewInt64Argument

func NewInt64Argument(key string) Argument

func NewSecretArgument

func NewSecretArgument(key string) Argument

func NewStringArgument

func NewStringArgument(key string) Argument

func NewUnpackagedDirectoryArgument

func NewUnpackagedDirectoryArgument(key string) Argument

func Without added in v0.11.0

func Without(args []Argument, exclude []Argument) []Argument

Without returns a list of Arguments equal to `args` without the args in the `exclude` list. complexity o(n^2)

type ArgumentType

type ArgumentType int
const (
	ArgumentTypeString ArgumentType = iota
	ArgumentTypeInt64
	ArgumentTypeFloat64
	ArgumentTypeBool
	ArgumentTypeSecret
	ArgumentTypeFile
	ArgumentTypeFS
	// An ArgumentTypeUnpackagedFS is used for filesystems that are invariably consistent regardless of operating system.
	// Developers can get around packaging and unpackaging of large directories using this argument type.
	// Filesystems and directories used with this argument should always exist on every machine. This basically means that they should be available within the source tree.
	// If this argument type is used for directories outside of the source tree, then expect divergeant behavior between operating systems.
	ArgumentTypeUnpackagedFS
)

func (ArgumentType) String

func (a ArgumentType) String() string

type Arguments added in v0.11.0

type Arguments []Argument

func (*Arguments) String added in v0.11.0

func (a *Arguments) String() string

type FilesystemState

type FilesystemState struct {
	// contains filtered or unexported fields
}

FilesystemState stores state in a JSON file on the filesystem.

func NewFilesystemState

func NewFilesystemState(path string) (*FilesystemState, error)

func (*FilesystemState) Exists

func (f *FilesystemState) Exists(ctx context.Context, arg Argument) (bool, error)

func (*FilesystemState) GetBool

func (f *FilesystemState) GetBool(ctx context.Context, arg Argument) (bool, error)

func (*FilesystemState) GetDirectory

func (f *FilesystemState) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)

func (*FilesystemState) GetDirectoryString

func (f *FilesystemState) GetDirectoryString(ctx context.Context, arg Argument) (string, error)

GetDirectoryString retrieves the original directory path. This can be particularly useful for things stored within the source filesystem.

func (*FilesystemState) GetFile

func (f *FilesystemState) GetFile(ctx context.Context, arg Argument) (*os.File, error)

func (*FilesystemState) GetFloat64

func (f *FilesystemState) GetFloat64(ctx context.Context, arg Argument) (float64, error)

func (*FilesystemState) GetInt64

func (f *FilesystemState) GetInt64(ctx context.Context, arg Argument) (int64, error)

func (*FilesystemState) GetString

func (f *FilesystemState) GetString(ctx context.Context, arg Argument) (string, error)

func (*FilesystemState) SetBool

func (f *FilesystemState) SetBool(ctx context.Context, arg Argument, value bool) error

func (*FilesystemState) SetDirectory

func (f *FilesystemState) SetDirectory(ctx context.Context, arg Argument, value string) error

func (*FilesystemState) SetFile

func (f *FilesystemState) SetFile(ctx context.Context, arg Argument, value string) error

func (*FilesystemState) SetFileReader

func (f *FilesystemState) SetFileReader(ctx context.Context, arg Argument, value io.Reader) (string, error)

func (*FilesystemState) SetFloat64

func (f *FilesystemState) SetFloat64(ctx context.Context, arg Argument, value float64) error

func (*FilesystemState) SetInt64

func (f *FilesystemState) SetInt64(ctx context.Context, arg Argument, value int64) error

func (*FilesystemState) SetString

func (f *FilesystemState) SetString(ctx context.Context, arg Argument, value string) error

type GCSHandler added in v0.12.0

type GCSHandler struct {
	*ObjectStorageHandler
}

GCSHandler uses the S3 API but with a round-tripper that makes the API client compatible with the S3 api

func NewGCSHandler added in v0.12.0

func NewGCSHandler(client *storage.Client, u *url.URL) (*GCSHandler, error)

type GCSObjectStorage added in v0.12.0

type GCSObjectStorage struct {
	Client *storage.Client
}

func (*GCSObjectStorage) GetObject added in v0.12.0

func (s *GCSObjectStorage) GetObject(ctx context.Context, bucket, key string) (*GetObjectResponse, error)

func (*GCSObjectStorage) PutObject added in v0.12.0

func (s *GCSObjectStorage) PutObject(ctx context.Context, bucket, key string, body io.Reader) error

type GetObjectResponse added in v0.12.0

type GetObjectResponse struct {
	Body io.ReadCloser
}

type Handler added in v0.11.0

type Handler interface {
	Reader
	Writer
}

type HandlerLogWrapper added in v0.11.0

type HandlerLogWrapper struct {
	*ReaderLogWrapper
	*WriterLogWrapper
}

func HandlerWithLogs added in v0.11.0

func HandlerWithLogs(log logrus.FieldLogger, state Handler) *HandlerLogWrapper

type JSONState added in v0.12.0

type JSONState map[string]StateValueJSON

type NoOpHandler added in v0.11.0

type NoOpHandler struct{}

NoOpHandler is a Handler that does nothing and is only used in tests where state is ignored but should never be nil.

func NewNoOpHandler added in v0.11.0

func NewNoOpHandler() *NoOpHandler

func (*NoOpHandler) Exists added in v0.11.0

func (n *NoOpHandler) Exists(ctx context.Context, arg Argument) (bool, error)

Reader functions

func (*NoOpHandler) GetBool added in v0.11.0

func (n *NoOpHandler) GetBool(ctx context.Context, arg Argument) (bool, error)

func (*NoOpHandler) GetDirectory added in v0.11.0

func (n *NoOpHandler) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)

func (*NoOpHandler) GetDirectoryString added in v0.11.0

func (n *NoOpHandler) GetDirectoryString(ctx context.Context, arg Argument) (string, error)

func (*NoOpHandler) GetFile added in v0.11.0

func (n *NoOpHandler) GetFile(ctx context.Context, arg Argument) (*os.File, error)

func (*NoOpHandler) GetFloat64 added in v0.11.0

func (n *NoOpHandler) GetFloat64(ctx context.Context, arg Argument) (float64, error)

func (*NoOpHandler) GetInt64 added in v0.11.0

func (n *NoOpHandler) GetInt64(ctx context.Context, arg Argument) (int64, error)

func (*NoOpHandler) GetString added in v0.11.0

func (n *NoOpHandler) GetString(ctx context.Context, arg Argument) (string, error)

func (*NoOpHandler) SetBool added in v0.11.0

func (n *NoOpHandler) SetBool(ctx context.Context, arg Argument, val bool) error

func (*NoOpHandler) SetDirectory added in v0.11.0

func (n *NoOpHandler) SetDirectory(ctx context.Context, arg Argument, dir string) error

func (*NoOpHandler) SetFile added in v0.11.0

func (n *NoOpHandler) SetFile(ctx context.Context, arg Argument, path string) error

func (*NoOpHandler) SetFileReader added in v0.11.0

func (n *NoOpHandler) SetFileReader(ctx context.Context, arg Argument, r io.Reader) (string, error)

func (*NoOpHandler) SetFloat64 added in v0.11.0

func (n *NoOpHandler) SetFloat64(ctx context.Context, arg Argument, val float64) error

func (*NoOpHandler) SetInt64 added in v0.11.0

func (n *NoOpHandler) SetInt64(ctx context.Context, arg Argument, val int64) error

func (*NoOpHandler) SetString added in v0.11.0

func (n *NoOpHandler) SetString(ctx context.Context, arg Argument, val string) error

Writer functions

type ObjectStorage added in v0.12.0

type ObjectStorage interface {
	GetObject(ctx context.Context, bucket, key string) (*GetObjectResponse, error)
	PutObject(ctx context.Context, bucket, key string, body io.Reader) error
}

type ObjectStorageHandler added in v0.12.0

type ObjectStorageHandler struct {
	Storage  ObjectStorage
	Bucket   string
	BasePath string
	// contains filtered or unexported fields
}

func NewObjectStorageHandler added in v0.12.0

func NewObjectStorageHandler(storage ObjectStorage, bucket, base string) *ObjectStorageHandler

func (*ObjectStorageHandler) Exists added in v0.12.0

func (s *ObjectStorageHandler) Exists(ctx context.Context, arg Argument) (bool, error)

func (*ObjectStorageHandler) GetBool added in v0.12.0

func (s *ObjectStorageHandler) GetBool(ctx context.Context, arg Argument) (bool, error)

func (*ObjectStorageHandler) GetDirectory added in v0.12.0

func (s *ObjectStorageHandler) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)

func (*ObjectStorageHandler) GetDirectoryString added in v0.12.0

func (s *ObjectStorageHandler) GetDirectoryString(ctx context.Context, arg Argument) (string, error)

func (*ObjectStorageHandler) GetFile added in v0.12.0

func (s *ObjectStorageHandler) GetFile(ctx context.Context, arg Argument) (*os.File, error)

func (*ObjectStorageHandler) GetFloat64 added in v0.12.0

func (s *ObjectStorageHandler) GetFloat64(ctx context.Context, arg Argument) (float64, error)

func (*ObjectStorageHandler) GetInt64 added in v0.12.0

func (s *ObjectStorageHandler) GetInt64(ctx context.Context, arg Argument) (int64, error)

func (*ObjectStorageHandler) GetString added in v0.12.0

func (s *ObjectStorageHandler) GetString(ctx context.Context, arg Argument) (string, error)

func (*ObjectStorageHandler) SetBool added in v0.12.0

func (s *ObjectStorageHandler) SetBool(ctx context.Context, arg Argument, value bool) error

func (*ObjectStorageHandler) SetDirectory added in v0.12.0

func (s *ObjectStorageHandler) SetDirectory(ctx context.Context, arg Argument, path string) error

func (*ObjectStorageHandler) SetFile added in v0.12.0

func (s *ObjectStorageHandler) SetFile(ctx context.Context, arg Argument, path string) error

func (*ObjectStorageHandler) SetFileReader added in v0.12.0

func (s *ObjectStorageHandler) SetFileReader(ctx context.Context, arg Argument, r io.Reader) (string, error)

func (*ObjectStorageHandler) SetFloat64 added in v0.12.0

func (s *ObjectStorageHandler) SetFloat64(ctx context.Context, arg Argument, value float64) error

func (*ObjectStorageHandler) SetInt64 added in v0.12.0

func (s *ObjectStorageHandler) SetInt64(ctx context.Context, arg Argument, value int64) error

func (*ObjectStorageHandler) SetString added in v0.12.0

func (s *ObjectStorageHandler) SetString(ctx context.Context, arg Argument, value string) error

type Observer added in v0.11.0

type Observer struct {
	// contains filtered or unexported fields
}

func NewObserver added in v0.11.0

func NewObserver(h Handler) *Observer

func (*Observer) CondFor added in v0.11.0

func (o *Observer) CondFor(ctx context.Context, arg Argument) *sync.Cond

func (*Observer) Exists added in v0.11.0

func (o *Observer) Exists(ctx context.Context, arg Argument) (bool, error)

Reader functions

func (*Observer) GetBool added in v0.11.0

func (o *Observer) GetBool(ctx context.Context, arg Argument) (bool, error)

func (*Observer) GetDirectory added in v0.11.0

func (o *Observer) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)

func (*Observer) GetDirectoryString added in v0.11.0

func (o *Observer) GetDirectoryString(ctx context.Context, arg Argument) (string, error)

func (*Observer) GetFile added in v0.11.0

func (o *Observer) GetFile(ctx context.Context, arg Argument) (*os.File, error)

func (*Observer) GetFloat64 added in v0.11.0

func (o *Observer) GetFloat64(ctx context.Context, arg Argument) (float64, error)

func (*Observer) GetInt64 added in v0.11.0

func (o *Observer) GetInt64(ctx context.Context, arg Argument) (int64, error)

func (*Observer) GetString added in v0.11.0

func (o *Observer) GetString(ctx context.Context, arg Argument) (string, error)

func (*Observer) Notify added in v0.11.0

func (o *Observer) Notify(ctx context.Context, arg Argument)

func (*Observer) SetBool added in v0.11.0

func (o *Observer) SetBool(ctx context.Context, arg Argument, val bool) error

func (*Observer) SetDirectory added in v0.11.0

func (o *Observer) SetDirectory(ctx context.Context, arg Argument, dir string) error

func (*Observer) SetFile added in v0.11.0

func (o *Observer) SetFile(ctx context.Context, arg Argument, path string) error

func (*Observer) SetFileReader added in v0.11.0

func (o *Observer) SetFileReader(ctx context.Context, arg Argument, r io.Reader) (string, error)

func (*Observer) SetFloat64 added in v0.11.0

func (o *Observer) SetFloat64(ctx context.Context, arg Argument, val float64) error

func (*Observer) SetInt64 added in v0.11.0

func (o *Observer) SetInt64(ctx context.Context, arg Argument, val int64) error

func (*Observer) SetString added in v0.11.0

func (o *Observer) SetString(ctx context.Context, arg Argument, val string) error

Writer functions

type Reader added in v0.11.0

type Reader interface {
	Exists(context.Context, Argument) (bool, error)
	GetString(context.Context, Argument) (string, error)
	GetInt64(context.Context, Argument) (int64, error)
	GetFloat64(context.Context, Argument) (float64, error)
	GetBool(context.Context, Argument) (bool, error)
	GetFile(context.Context, Argument) (*os.File, error)
	GetDirectory(context.Context, Argument) (fs.FS, error)
	GetDirectoryString(context.Context, Argument) (string, error)
}

type ReaderLogWrapper added in v0.11.0

type ReaderLogWrapper struct {
	Reader
	Log logrus.FieldLogger
}

func ReaderWithLogs added in v0.11.0

func ReaderWithLogs(log logrus.FieldLogger, state Reader) *ReaderLogWrapper

func (*ReaderLogWrapper) Exists added in v0.11.0

func (s *ReaderLogWrapper) Exists(ctx context.Context, arg Argument) (bool, error)

func (*ReaderLogWrapper) GetDirectory added in v0.11.0

func (s *ReaderLogWrapper) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)

func (*ReaderLogWrapper) GetDirectoryString added in v0.11.0

func (s *ReaderLogWrapper) GetDirectoryString(ctx context.Context, arg Argument) (string, error)

func (*ReaderLogWrapper) GetFile added in v0.11.0

func (s *ReaderLogWrapper) GetFile(ctx context.Context, arg Argument) (*os.File, error)

func (*ReaderLogWrapper) GetFloat64 added in v0.11.0

func (s *ReaderLogWrapper) GetFloat64(ctx context.Context, arg Argument) (float64, error)

func (*ReaderLogWrapper) GetInt64 added in v0.11.0

func (s *ReaderLogWrapper) GetInt64(ctx context.Context, arg Argument) (int64, error)

func (*ReaderLogWrapper) GetString added in v0.11.0

func (s *ReaderLogWrapper) GetString(ctx context.Context, arg Argument) (string, error)

type S3Handler added in v0.12.0

type S3Handler struct {
	*ObjectStorageHandler
}

func NewS3Handler added in v0.12.0

func NewS3Handler(client *s3.Client, u *url.URL) (*S3Handler, error)

type S3ObjectStorage added in v0.12.0

type S3ObjectStorage struct {
	Client *s3.Client
}

func (*S3ObjectStorage) GetObject added in v0.12.0

func (s *S3ObjectStorage) GetObject(ctx context.Context, bucket, key string) (*GetObjectResponse, error)

func (*S3ObjectStorage) PutObject added in v0.12.0

func (s *S3ObjectStorage) PutObject(ctx context.Context, bucket, key string, body io.Reader) error

type State

type State struct {
	Handler  Handler
	Fallback []Reader
	Log      logrus.FieldLogger
}

func NewDefaultState added in v0.11.0

func NewDefaultState(ctx context.Context, log logrus.FieldLogger, pargs *args.PipelineArgs) (*State, error)

NewDefaultState creates a new default state given the arguments provided. The --no-stdin flag will prevent the State object from using the stdin to populate the state for ClientProvidedArguments. (See `pipeline/arguments_known.go` for those). The --state flag defines where the state JSON and state data will be stored. If the value for a key is not available in the primary state (defined by the --state flag), then the state object will attempt to retrieve it from the fallback. Currently, the fallback options are the `--arg` flags (--arg={key}={value}), or, if `--no-stdin` is not set, then from the stdin.

func (*State) Exists

func (s *State) Exists(ctx context.Context, arg Argument) (bool, error)

Exists checks the state to see if an argument exists in it. It can return an error in the event of a failure to check the state. An error will not be returned if the state could be read and the value was not in it. If a value for argument was not found, then false and a nil error is returned.

func (*State) GetBool

func (s *State) GetBool(ctx context.Context, arg Argument) (bool, error)

GetBool attempts to get the bool from the state. If there are Fallback readers and the state returned an error, then it will loop through each one, attempting to retrieve the value from the fallback state reader. If no fallback reader returns the value, then the original error is returned.

func (*State) GetDirectory

func (s *State) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)

GetDirectory attempts to get the directory from the state. If there are Fallback readers and the state returned an error, then it will loop through each one, attempting to retrieve the value from the fallback state reader. If no fallback reader returns the value, then the original error is returned.

func (*State) GetDirectoryString

func (s *State) GetDirectoryString(ctx context.Context, arg Argument) (string, error)

GetDirectory attempts to get the directory from the state. If there are Fallback readers and the state returned an error, then it will loop through each one, attempting to retrieve the value from the fallback state reader. If no fallback reader returns the value, then the original error is returned.

func (*State) GetFile

func (s *State) GetFile(ctx context.Context, arg Argument) (*os.File, error)

GetFile attempts to get the file from the state. If there are Fallback readers and the state returned an error, then it will loop through each one, attempting to retrieve the value from the fallback state reader. If no fallback reader returns the value, then the original error is returned.

func (*State) GetFloat64

func (s *State) GetFloat64(ctx context.Context, arg Argument) (float64, error)

GetFloat64 attempts to get the int64 from the state. If there are Fallback readers and the state returned an error, then it will loop through each one, attempting to retrieve the value from the fallback state reader. If no fallback reader returns the value, then the original error is returned.

func (*State) GetInt64

func (s *State) GetInt64(ctx context.Context, arg Argument) (int64, error)

GetInt64 attempts to get the int64 from the state. If there are Fallback readers and the state returned an error, then it will loop through each one, attempting to retrieve the value from the fallback state reader. If no fallback reader returns the value, then the original error is returned.

func (*State) GetString

func (s *State) GetString(ctx context.Context, arg Argument) (string, error)

GetString attempts to get the string from the state. If there are Fallback readers and the state returned an error, then it will loop through each one, attempting to retrieve the value from the fallback state reader. If no fallback reader returns the value, then the original error is returned.

func (*State) SetBool

func (s *State) SetBool(ctx context.Context, arg Argument, value bool) error

SetBool attempts to set the bool into the state.

func (*State) SetDirectory

func (s *State) SetDirectory(ctx context.Context, arg Argument, path string) error

SetDirectory attempts to set the directory into the state. The "path" argument should be the path to the directory to be stored.

func (*State) SetFile

func (s *State) SetFile(ctx context.Context, arg Argument, path string) error

SetFile attempts to set the file into the state. The "path" argument should be the path to the file to be stored.

func (*State) SetFileReader

func (s *State) SetFileReader(ctx context.Context, arg Argument, r io.Reader) (string, error)

SetFileReader attempts to set the reader into the state as a file. This is an easy way to go from downloading a file to setting it into the state without having to write it to disk first.

func (*State) SetFloat64

func (s *State) SetFloat64(ctx context.Context, arg Argument, value float64) error

SetFloat64 attempts to set the float64 into the state.

func (*State) SetInt64

func (s *State) SetInt64(ctx context.Context, arg Argument, value int64) error

SetInt64 attempts to set the int64 into the state.

func (*State) SetString

func (s *State) SetString(ctx context.Context, arg Argument, value string) error

SetString attempts to set the string into the state.

type StateValueJSON added in v0.11.0

type StateValueJSON struct {
	Argument Argument `json:"argument"`
	Value    any      `json:"value"`
}

type StdinReader

type StdinReader struct {
	// contains filtered or unexported fields
}

func NewStdinReader

func NewStdinReader(in io.Reader, out io.Writer) *StdinReader

func (*StdinReader) Exists

func (s *StdinReader) Exists(ctx context.Context, arg Argument) (bool, error)

Since the StdinReader can read any state value, it's better if we assume that if it's being used, then it wasn't found in other reasonable state managers.

func (*StdinReader) Get

func (s *StdinReader) Get(arg Argument) (string, error)

func (*StdinReader) GetBool

func (s *StdinReader) GetBool(ctx context.Context, arg Argument) (bool, error)

func (*StdinReader) GetDirectory

func (s *StdinReader) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)

func (*StdinReader) GetDirectoryString

func (s *StdinReader) GetDirectoryString(ctx context.Context, arg Argument) (string, error)

func (*StdinReader) GetFile

func (s *StdinReader) GetFile(ctx context.Context, arg Argument) (*os.File, error)

func (*StdinReader) GetFloat64

func (s *StdinReader) GetFloat64(ctx context.Context, arg Argument) (float64, error)

func (*StdinReader) GetInt64

func (s *StdinReader) GetInt64(ctx context.Context, arg Argument) (int64, error)

func (*StdinReader) GetString

func (s *StdinReader) GetString(ctx context.Context, arg Argument) (string, error)

type Writer added in v0.11.0

type Writer interface {
	SetString(context.Context, Argument, string) error
	SetInt64(context.Context, Argument, int64) error
	SetFloat64(context.Context, Argument, float64) error
	SetBool(context.Context, Argument, bool) error
	SetFile(context.Context, Argument, string) error
	SetFileReader(context.Context, Argument, io.Reader) (string, error)
	SetDirectory(context.Context, Argument, string) error
}

type WriterLogWrapper added in v0.11.0

type WriterLogWrapper struct {
	Writer
	Log logrus.FieldLogger
}

func WriterWithLogs added in v0.11.0

func WriterWithLogs(log logrus.FieldLogger, state Writer) *WriterLogWrapper

func (*WriterLogWrapper) SetDirectory added in v0.11.0

func (s *WriterLogWrapper) SetDirectory(ctx context.Context, arg Argument, val string) error

func (*WriterLogWrapper) SetFile added in v0.11.0

func (s *WriterLogWrapper) SetFile(ctx context.Context, arg Argument, val string) error

func (*WriterLogWrapper) SetFileReader added in v0.11.0

func (s *WriterLogWrapper) SetFileReader(ctx context.Context, arg Argument, val io.Reader) (string, error)

func (*WriterLogWrapper) SetFloat64 added in v0.11.0

func (s *WriterLogWrapper) SetFloat64(ctx context.Context, arg Argument, val float64) error

func (*WriterLogWrapper) SetInt64 added in v0.11.0

func (s *WriterLogWrapper) SetInt64(ctx context.Context, arg Argument, val int64) error

func (*WriterLogWrapper) SetString added in v0.11.0

func (s *WriterLogWrapper) SetString(ctx context.Context, arg Argument, val string) error

Jump to

Keyboard shortcuts

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