Documentation
¶
Index ¶
- Variables
- func ArgListContains(args Arguments, arg Argument) bool
- func ArgumentTypesEqual(arg Argument, argTypes ...ArgumentType) bool
- func BucketAndPath(u *url.URL) (string, string)
- func EqualArgs(a []Argument, b []Argument) bool
- func GetValueAsString(ctx context.Context, r Reader, arg Argument) (string, error)
- func MustGetBool(s Handler, ctx context.Context, arg Argument) bool
- func MustGetDirectory(s Handler, ctx context.Context, arg Argument) fs.FS
- func MustGetDirectoryString(s Handler, ctx context.Context, arg Argument) string
- func MustGetFile(s Handler, ctx context.Context, arg Argument) *os.File
- func MustGetFloat64(s Handler, ctx context.Context, arg Argument) float64
- func MustGetInt64(s Handler, ctx context.Context, arg Argument) int64
- func MustGetString(s Handler, ctx context.Context, arg Argument) string
- func SetValueFromJSON(ctx context.Context, w Writer, value StateValueJSON) error
- type ArgMapReader
- func (s *ArgMapReader) Exists(ctx context.Context, arg Argument) (bool, error)
- func (s *ArgMapReader) GetBool(ctx context.Context, arg Argument) (bool, error)
- func (s *ArgMapReader) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)
- func (s *ArgMapReader) GetDirectoryString(ctx context.Context, arg Argument) (string, error)
- func (s *ArgMapReader) GetFile(ctx context.Context, arg Argument) (*os.File, error)
- func (s *ArgMapReader) GetFloat64(ctx context.Context, arg Argument) (float64, error)
- func (s *ArgMapReader) GetInt64(ctx context.Context, arg Argument) (int64, error)
- func (s *ArgMapReader) GetString(ctx context.Context, arg Argument) (string, error)
- type Argument
- func NewBoolArgument(key string) Argument
- func NewDirectoryArgument(key string) Argument
- func NewFileArgument(key string) Argument
- func NewFloat64Argument(key string) Argument
- func NewInt64Argument(key string) Argument
- func NewSecretArgument(key string) Argument
- func NewStringArgument(key string) Argument
- func NewUnpackagedDirectoryArgument(key string) Argument
- func Without(args []Argument, exclude []Argument) []Argument
- type ArgumentType
- type Arguments
- type FilesystemState
- func (f *FilesystemState) Exists(ctx context.Context, arg Argument) (bool, error)
- func (f *FilesystemState) GetBool(ctx context.Context, arg Argument) (bool, error)
- func (f *FilesystemState) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)
- func (f *FilesystemState) GetDirectoryString(ctx context.Context, arg Argument) (string, error)
- func (f *FilesystemState) GetFile(ctx context.Context, arg Argument) (*os.File, error)
- func (f *FilesystemState) GetFloat64(ctx context.Context, arg Argument) (float64, error)
- func (f *FilesystemState) GetInt64(ctx context.Context, arg Argument) (int64, error)
- func (f *FilesystemState) GetString(ctx context.Context, arg Argument) (string, error)
- func (f *FilesystemState) SetBool(ctx context.Context, arg Argument, value bool) error
- func (f *FilesystemState) SetDirectory(ctx context.Context, arg Argument, value string) error
- func (f *FilesystemState) SetFile(ctx context.Context, arg Argument, value string) error
- func (f *FilesystemState) SetFileReader(ctx context.Context, arg Argument, value io.Reader) (string, error)
- func (f *FilesystemState) SetFloat64(ctx context.Context, arg Argument, value float64) error
- func (f *FilesystemState) SetInt64(ctx context.Context, arg Argument, value int64) error
- func (f *FilesystemState) SetString(ctx context.Context, arg Argument, value string) error
- type GCSHandler
- type GCSObjectStorage
- type GetObjectResponse
- type Handler
- type HandlerLogWrapper
- type JSONState
- type NoOpHandler
- func (n *NoOpHandler) Exists(ctx context.Context, arg Argument) (bool, error)
- func (n *NoOpHandler) GetBool(ctx context.Context, arg Argument) (bool, error)
- func (n *NoOpHandler) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)
- func (n *NoOpHandler) GetDirectoryString(ctx context.Context, arg Argument) (string, error)
- func (n *NoOpHandler) GetFile(ctx context.Context, arg Argument) (*os.File, error)
- func (n *NoOpHandler) GetFloat64(ctx context.Context, arg Argument) (float64, error)
- func (n *NoOpHandler) GetInt64(ctx context.Context, arg Argument) (int64, error)
- func (n *NoOpHandler) GetString(ctx context.Context, arg Argument) (string, error)
- func (n *NoOpHandler) SetBool(ctx context.Context, arg Argument, val bool) error
- func (n *NoOpHandler) SetDirectory(ctx context.Context, arg Argument, dir string) error
- func (n *NoOpHandler) SetFile(ctx context.Context, arg Argument, path string) error
- func (n *NoOpHandler) SetFileReader(ctx context.Context, arg Argument, r io.Reader) (string, error)
- func (n *NoOpHandler) SetFloat64(ctx context.Context, arg Argument, val float64) error
- func (n *NoOpHandler) SetInt64(ctx context.Context, arg Argument, val int64) error
- func (n *NoOpHandler) SetString(ctx context.Context, arg Argument, val string) error
- type ObjectStorage
- type ObjectStorageHandler
- func (s *ObjectStorageHandler) Exists(ctx context.Context, arg Argument) (bool, error)
- func (s *ObjectStorageHandler) GetBool(ctx context.Context, arg Argument) (bool, error)
- func (s *ObjectStorageHandler) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)
- func (s *ObjectStorageHandler) GetDirectoryString(ctx context.Context, arg Argument) (string, error)
- func (s *ObjectStorageHandler) GetFile(ctx context.Context, arg Argument) (*os.File, error)
- func (s *ObjectStorageHandler) GetFloat64(ctx context.Context, arg Argument) (float64, error)
- func (s *ObjectStorageHandler) GetInt64(ctx context.Context, arg Argument) (int64, error)
- func (s *ObjectStorageHandler) GetString(ctx context.Context, arg Argument) (string, error)
- func (s *ObjectStorageHandler) SetBool(ctx context.Context, arg Argument, value bool) error
- func (s *ObjectStorageHandler) SetDirectory(ctx context.Context, arg Argument, path string) error
- func (s *ObjectStorageHandler) SetFile(ctx context.Context, arg Argument, path string) error
- func (s *ObjectStorageHandler) SetFileReader(ctx context.Context, arg Argument, r io.Reader) (string, error)
- func (s *ObjectStorageHandler) SetFloat64(ctx context.Context, arg Argument, value float64) error
- func (s *ObjectStorageHandler) SetInt64(ctx context.Context, arg Argument, value int64) error
- func (s *ObjectStorageHandler) SetString(ctx context.Context, arg Argument, value string) error
- type Observer
- func (o *Observer) CondFor(ctx context.Context, arg Argument) *sync.Cond
- func (o *Observer) Exists(ctx context.Context, arg Argument) (bool, error)
- func (o *Observer) GetBool(ctx context.Context, arg Argument) (bool, error)
- func (o *Observer) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)
- func (o *Observer) GetDirectoryString(ctx context.Context, arg Argument) (string, error)
- func (o *Observer) GetFile(ctx context.Context, arg Argument) (*os.File, error)
- func (o *Observer) GetFloat64(ctx context.Context, arg Argument) (float64, error)
- func (o *Observer) GetInt64(ctx context.Context, arg Argument) (int64, error)
- func (o *Observer) GetString(ctx context.Context, arg Argument) (string, error)
- func (o *Observer) Notify(ctx context.Context, arg Argument)
- func (o *Observer) SetBool(ctx context.Context, arg Argument, val bool) error
- func (o *Observer) SetDirectory(ctx context.Context, arg Argument, dir string) error
- func (o *Observer) SetFile(ctx context.Context, arg Argument, path string) error
- func (o *Observer) SetFileReader(ctx context.Context, arg Argument, r io.Reader) (string, error)
- func (o *Observer) SetFloat64(ctx context.Context, arg Argument, val float64) error
- func (o *Observer) SetInt64(ctx context.Context, arg Argument, val int64) error
- func (o *Observer) SetString(ctx context.Context, arg Argument, val string) error
- type Reader
- type ReaderLogWrapper
- func (s *ReaderLogWrapper) Exists(ctx context.Context, arg Argument) (bool, error)
- func (s *ReaderLogWrapper) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)
- func (s *ReaderLogWrapper) GetDirectoryString(ctx context.Context, arg Argument) (string, error)
- func (s *ReaderLogWrapper) GetFile(ctx context.Context, arg Argument) (*os.File, error)
- func (s *ReaderLogWrapper) GetFloat64(ctx context.Context, arg Argument) (float64, error)
- func (s *ReaderLogWrapper) GetInt64(ctx context.Context, arg Argument) (int64, error)
- func (s *ReaderLogWrapper) GetString(ctx context.Context, arg Argument) (string, error)
- type S3Handler
- type S3ObjectStorage
- type State
- func (s *State) Exists(ctx context.Context, arg Argument) (bool, error)
- func (s *State) GetBool(ctx context.Context, arg Argument) (bool, error)
- func (s *State) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)
- func (s *State) GetDirectoryString(ctx context.Context, arg Argument) (string, error)
- func (s *State) GetFile(ctx context.Context, arg Argument) (*os.File, error)
- func (s *State) GetFloat64(ctx context.Context, arg Argument) (float64, error)
- func (s *State) GetInt64(ctx context.Context, arg Argument) (int64, error)
- func (s *State) GetString(ctx context.Context, arg Argument) (string, error)
- func (s *State) SetBool(ctx context.Context, arg Argument, value bool) error
- func (s *State) SetDirectory(ctx context.Context, arg Argument, path string) error
- func (s *State) SetFile(ctx context.Context, arg Argument, path string) error
- func (s *State) SetFileReader(ctx context.Context, arg Argument, r io.Reader) (string, error)
- func (s *State) SetFloat64(ctx context.Context, arg Argument, value float64) error
- func (s *State) SetInt64(ctx context.Context, arg Argument, value int64) error
- func (s *State) SetString(ctx context.Context, arg Argument, value string) error
- type StateValueJSON
- type StdinReader
- func (s *StdinReader) Exists(ctx context.Context, arg Argument) (bool, error)
- func (s *StdinReader) Get(arg Argument) (string, error)
- func (s *StdinReader) GetBool(ctx context.Context, arg Argument) (bool, error)
- func (s *StdinReader) GetDirectory(ctx context.Context, arg Argument) (fs.FS, error)
- func (s *StdinReader) GetDirectoryString(ctx context.Context, arg Argument) (string, error)
- func (s *StdinReader) GetFile(ctx context.Context, arg Argument) (*os.File, error)
- func (s *StdinReader) GetFloat64(ctx context.Context, arg Argument) (float64, error)
- func (s *StdinReader) GetInt64(ctx context.Context, arg Argument) (int64, error)
- func (s *StdinReader) GetString(ctx context.Context, arg Argument) (string, error)
- type Writer
- type WriterLogWrapper
- func (s *WriterLogWrapper) SetDirectory(ctx context.Context, arg Argument, val string) error
- func (s *WriterLogWrapper) SetFile(ctx context.Context, arg Argument, val string) error
- func (s *WriterLogWrapper) SetFileReader(ctx context.Context, arg Argument, val io.Reader) (string, error)
- func (s *WriterLogWrapper) SetFloat64(ctx context.Context, arg Argument, val float64) error
- func (s *WriterLogWrapper) SetInt64(ctx context.Context, arg Argument, val int64) error
- func (s *WriterLogWrapper) SetString(ctx context.Context, arg Argument, val string) error
Constants ¶
This section is empty.
Variables ¶
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") )
var (
ErrorFileNotFound = errors.New("not found")
)
Functions ¶
func ArgListContains ¶
func ArgumentTypesEqual ¶
func ArgumentTypesEqual(arg Argument, argTypes ...ArgumentType) bool
func EqualArgs ¶
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 ¶
func MustGetDirectoryString ¶
func SetValueFromJSON ¶
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) GetDirectory ¶
func (*ArgMapReader) GetDirectoryString ¶
func (*ArgMapReader) GetFloat64 ¶
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 flow 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 NewDirectoryArgument ¶
func NewFileArgument ¶
func NewFloat64Argument ¶
func NewInt64Argument ¶
func NewSecretArgument ¶
func NewStringArgument ¶
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 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) GetDirectory ¶
func (*FilesystemState) GetDirectoryString ¶
GetDirectoryString retrieves the original directory path. This can be particularly useful for things stored within the source filesystem.
func (*FilesystemState) GetFloat64 ¶
func (*FilesystemState) SetDirectory ¶
func (*FilesystemState) SetFileReader ¶
func (*FilesystemState) SetFloat64 ¶
type GCSHandler ¶
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 ¶
type GCSObjectStorage ¶
func (*GCSObjectStorage) GetObject ¶
func (s *GCSObjectStorage) GetObject(ctx context.Context, bucket, key string) (*GetObjectResponse, error)
type GetObjectResponse ¶
type GetObjectResponse struct {
Body io.ReadCloser
}
type HandlerLogWrapper ¶
type HandlerLogWrapper struct { *ReaderLogWrapper *WriterLogWrapper }
func HandlerWithLogs ¶
func HandlerWithLogs(log logrus.FieldLogger, state Handler) *HandlerLogWrapper
type JSONState ¶
type JSONState map[string]StateValueJSON
type NoOpHandler ¶
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 ¶
func NewNoOpHandler() *NoOpHandler
func (*NoOpHandler) GetDirectory ¶
func (*NoOpHandler) GetDirectoryString ¶
func (*NoOpHandler) GetFloat64 ¶
func (*NoOpHandler) SetDirectory ¶
func (*NoOpHandler) SetFileReader ¶
func (*NoOpHandler) SetFloat64 ¶
type ObjectStorage ¶
type ObjectStorageHandler ¶
type ObjectStorageHandler struct { Storage ObjectStorage Bucket string BasePath string // contains filtered or unexported fields }
func NewObjectStorageHandler ¶
func NewObjectStorageHandler(storage ObjectStorage, bucket, base string) *ObjectStorageHandler
func (*ObjectStorageHandler) GetDirectory ¶
func (*ObjectStorageHandler) GetDirectoryString ¶
func (*ObjectStorageHandler) GetFloat64 ¶
func (*ObjectStorageHandler) SetDirectory ¶
func (*ObjectStorageHandler) SetFileReader ¶
func (*ObjectStorageHandler) SetFloat64 ¶
type Observer ¶
type Observer struct {
// contains filtered or unexported fields
}
func NewObserver ¶
func (*Observer) GetDirectory ¶
func (*Observer) GetDirectoryString ¶
func (*Observer) GetFloat64 ¶
func (*Observer) SetDirectory ¶
func (*Observer) SetFileReader ¶
func (*Observer) SetFloat64 ¶
type Reader ¶
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 ¶
type ReaderLogWrapper struct { Reader Log logrus.FieldLogger }
func ReaderWithLogs ¶
func ReaderWithLogs(log logrus.FieldLogger, state Reader) *ReaderLogWrapper
func (*ReaderLogWrapper) GetDirectory ¶
func (*ReaderLogWrapper) GetDirectoryString ¶
func (*ReaderLogWrapper) GetFloat64 ¶
type S3Handler ¶
type S3Handler struct {
*ObjectStorageHandler
}
type S3ObjectStorage ¶
func (*S3ObjectStorage) GetObject ¶
func (s *S3ObjectStorage) GetObject(ctx context.Context, bucket, key string) (*GetObjectResponse, error)
type State ¶
type State struct { Handler Handler Fallback []Reader Log logrus.FieldLogger }
func NewDefaultState ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) SetDirectory ¶
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 ¶
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 ¶
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 ¶
SetFloat64 attempts to set the float64 into the state.
type StateValueJSON ¶
type StdinReader ¶
type StdinReader struct {
// contains filtered or unexported fields
}
func NewStdinReader ¶
func NewStdinReader(in io.Reader, out io.Writer) *StdinReader
func (*StdinReader) Exists ¶
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) GetDirectory ¶
func (*StdinReader) GetDirectoryString ¶
func (*StdinReader) GetFloat64 ¶
type Writer ¶
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 ¶
type WriterLogWrapper struct { Writer Log logrus.FieldLogger }
func WriterWithLogs ¶
func WriterWithLogs(log logrus.FieldLogger, state Writer) *WriterLogWrapper