Documentation ¶
Index ¶
- Variables
- func ArgumentTypesEqual(arg Argument, argTypes ...ArgumentType) bool
- type ArgMapReader
- func (s *ArgMapReader) Exists(arg Argument) (bool, error)
- func (s *ArgMapReader) GetBool(arg Argument) (bool, error)
- func (s *ArgMapReader) GetDirectory(arg Argument) (fs.FS, error)
- func (s *ArgMapReader) GetDirectoryString(arg Argument) (string, error)
- func (s *ArgMapReader) GetFile(arg Argument) (*os.File, error)
- func (s *ArgMapReader) GetFloat64(arg Argument) (float64, error)
- func (s *ArgMapReader) GetInt64(arg Argument) (int64, error)
- func (s *ArgMapReader) GetString(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
- type ArgumentType
- type FilesystemState
- func (f *FilesystemState) Exists(arg Argument) (bool, error)
- func (f *FilesystemState) GetBool(arg Argument) (bool, error)
- func (f *FilesystemState) GetDirectory(arg Argument) (fs.FS, error)
- func (f *FilesystemState) GetDirectoryString(arg Argument) (string, error)
- func (f *FilesystemState) GetFile(arg Argument) (*os.File, error)
- func (f *FilesystemState) GetFloat64(arg Argument) (float64, error)
- func (f *FilesystemState) GetInt64(arg Argument) (int64, error)
- func (f *FilesystemState) GetString(arg Argument) (string, error)
- func (f *FilesystemState) SetBool(arg Argument, value bool) error
- func (f *FilesystemState) SetDirectory(arg Argument, value string) error
- func (f *FilesystemState) SetFile(arg Argument, value string) error
- func (f *FilesystemState) SetFileReader(arg Argument, value io.Reader) error
- func (f *FilesystemState) SetFloat64(arg Argument, value float64) error
- func (f *FilesystemState) SetInt64(arg Argument, value int64) error
- func (f *FilesystemState) SetString(arg Argument, value string) error
- type State
- func (s *State) Exists(arg Argument) (bool, error)
- func (s *State) GetBool(arg Argument) (bool, error)
- func (s *State) GetDirectory(arg Argument) (fs.FS, error)
- func (s *State) GetDirectoryString(arg Argument) (string, error)
- func (s *State) GetFile(arg Argument) (*os.File, error)
- func (s *State) GetFloat64(arg Argument) (float64, error)
- func (s *State) GetInt64(arg Argument) (int64, error)
- func (s *State) GetString(arg Argument) (string, error)
- func (s *State) MustGetBool(arg Argument) bool
- func (s *State) MustGetDirectory(arg Argument) fs.FS
- func (s *State) MustGetDirectoryString(arg Argument) string
- func (s *State) MustGetFile(arg Argument) *os.File
- func (s *State) MustGetFloat64(arg Argument) float64
- func (s *State) MustGetInt64(arg Argument) int64
- func (s *State) MustGetString(arg Argument) string
- func (s *State) SetBool(arg Argument, value bool) error
- func (s *State) SetDirectory(arg Argument, path string) error
- func (s *State) SetFile(arg Argument, path string) error
- func (s *State) SetFileReader(arg Argument, r io.Reader) error
- func (s *State) SetFloat64(arg Argument, value float64) error
- func (s *State) SetInt64(arg Argument, value int64) error
- func (s *State) SetString(arg Argument, value string) error
- type StateHandler
- type StateHandlerLogWrapper
- type StateReader
- type StateReaderLogWrapper
- func (s *StateReaderLogWrapper) Exists(arg Argument) (bool, error)
- func (s *StateReaderLogWrapper) GetDirectory(arg Argument) (fs.FS, error)
- func (s *StateReaderLogWrapper) GetDirectoryString(arg Argument) (string, error)
- func (s *StateReaderLogWrapper) GetFile(arg Argument) (*os.File, error)
- func (s *StateReaderLogWrapper) GetFloat64(arg Argument) (float64, error)
- func (s *StateReaderLogWrapper) GetInt64(arg Argument) (int64, error)
- func (s *StateReaderLogWrapper) GetString(arg Argument) (string, error)
- type StateWriter
- type StateWriterLogWrapper
- func (s *StateWriterLogWrapper) SetDirectory(arg Argument, val string) error
- func (s *StateWriterLogWrapper) SetFile(arg Argument, val string) error
- func (s *StateWriterLogWrapper) SetFileReader(arg Argument, val io.Reader) error
- func (s *StateWriterLogWrapper) SetFloat64(arg Argument, val float64) error
- func (s *StateWriterLogWrapper) SetInt64(arg Argument, val int64) error
- func (s *StateWriterLogWrapper) SetString(arg Argument, val string) error
- type StdinReader
- func (s *StdinReader) Exists(arg Argument) (bool, error)
- func (s *StdinReader) Get(arg Argument) (string, error)
- func (s *StdinReader) GetBool(arg Argument) (bool, error)
- func (s *StdinReader) GetDirectory(arg Argument) (fs.FS, error)
- func (s *StdinReader) GetDirectoryString(arg Argument) (string, error)
- func (s *StdinReader) GetFile(arg Argument) (*os.File, error)
- func (s *StdinReader) GetFloat64(arg Argument) (float64, error)
- func (s *StdinReader) GetInt64(arg Argument) (int64, error)
- func (s *StdinReader) GetString(arg Argument) (string, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ArgumentTypesEqual ¶
func ArgumentTypesEqual(arg Argument, argTypes ...ArgumentType) bool
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 (s *ArgMapReader) GetDirectory(arg Argument) (fs.FS, error)
func (*ArgMapReader) GetDirectoryString ¶
func (s *ArgMapReader) GetDirectoryString(arg Argument) (string, error)
func (*ArgMapReader) GetFloat64 ¶
func (s *ArgMapReader) GetFloat64(arg Argument) (float64, 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 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 (f *FilesystemState) GetDirectory(arg Argument) (fs.FS, error)
func (*FilesystemState) GetDirectoryString ¶
func (f *FilesystemState) GetDirectoryString(arg Argument) (string, error)
GetDirectoryString retrieves the original directory path. This can be particularly useful for things stored within the source filesystem.
func (*FilesystemState) GetFloat64 ¶
func (f *FilesystemState) GetFloat64(arg Argument) (float64, error)
func (*FilesystemState) GetString ¶
func (f *FilesystemState) GetString(arg Argument) (string, error)
func (*FilesystemState) SetDirectory ¶
func (f *FilesystemState) SetDirectory(arg Argument, value string) error
func (*FilesystemState) SetFile ¶
func (f *FilesystemState) SetFile(arg Argument, value string) error
func (*FilesystemState) SetFileReader ¶
func (f *FilesystemState) SetFileReader(arg Argument, value io.Reader) error
func (*FilesystemState) SetFloat64 ¶
func (f *FilesystemState) SetFloat64(arg Argument, value float64) error
type State ¶
type State struct { Handler StateHandler Fallback []StateReader Log logrus.FieldLogger }
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) MustGetBool ¶
func (*State) MustGetDirectoryString ¶
func (*State) MustGetFloat64 ¶
func (*State) MustGetInt64 ¶
func (*State) MustGetString ¶
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 StateHandler ¶
type StateHandler interface { StateReader StateWriter }
type StateHandlerLogWrapper ¶
type StateHandlerLogWrapper struct { *StateReaderLogWrapper *StateWriterLogWrapper }
func StateHandlerWithLogs ¶
func StateHandlerWithLogs(log logrus.FieldLogger, state StateHandler) *StateHandlerLogWrapper
type StateReader ¶
type StateReader interface { Exists(Argument) (bool, error) GetString(Argument) (string, error) GetInt64(Argument) (int64, error) GetFloat64(Argument) (float64, error) GetBool(Argument) (bool, error) GetFile(Argument) (*os.File, error) GetDirectory(Argument) (fs.FS, error) GetDirectoryString(Argument) (string, error) }
type StateReaderLogWrapper ¶
type StateReaderLogWrapper struct { StateReader Log logrus.FieldLogger }
func StateReaderWithLogs ¶
func StateReaderWithLogs(log logrus.FieldLogger, state StateReader) *StateReaderLogWrapper
func (*StateReaderLogWrapper) Exists ¶
func (s *StateReaderLogWrapper) Exists(arg Argument) (bool, error)
func (*StateReaderLogWrapper) GetDirectory ¶
func (s *StateReaderLogWrapper) GetDirectory(arg Argument) (fs.FS, error)
func (*StateReaderLogWrapper) GetDirectoryString ¶
func (s *StateReaderLogWrapper) GetDirectoryString(arg Argument) (string, error)
func (*StateReaderLogWrapper) GetFile ¶
func (s *StateReaderLogWrapper) GetFile(arg Argument) (*os.File, error)
func (*StateReaderLogWrapper) GetFloat64 ¶
func (s *StateReaderLogWrapper) GetFloat64(arg Argument) (float64, error)
type StateWriter ¶
type StateWriterLogWrapper ¶
type StateWriterLogWrapper struct { StateWriter Log logrus.FieldLogger }
func StateWriterWithLogs ¶
func StateWriterWithLogs(log logrus.FieldLogger, state StateWriter) *StateWriterLogWrapper
func (*StateWriterLogWrapper) SetDirectory ¶
func (s *StateWriterLogWrapper) SetDirectory(arg Argument, val string) error
func (*StateWriterLogWrapper) SetFile ¶
func (s *StateWriterLogWrapper) SetFile(arg Argument, val string) error
func (*StateWriterLogWrapper) SetFileReader ¶
func (s *StateWriterLogWrapper) SetFileReader(arg Argument, val io.Reader) error
func (*StateWriterLogWrapper) SetFloat64 ¶
func (s *StateWriterLogWrapper) SetFloat64(arg Argument, val float64) error
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(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) GetDirectory ¶
func (s *StdinReader) GetDirectory(arg Argument) (fs.FS, error)
func (*StdinReader) GetDirectoryString ¶
func (s *StdinReader) GetDirectoryString(arg Argument) (string, error)
func (*StdinReader) GetFloat64 ¶
func (s *StdinReader) GetFloat64(arg Argument) (float64, error)