Documentation ¶
Index ¶
- Constants
- Variables
- func IsSanitizeError(err Error) bool
- func IsSanitizeFileNotExist(err Error) bool
- func SanitizeTrustedFilePath(trustedFilePath *TrustedFilePath) (*TrustedFilePath, Error)
- type BuildRelatedError
- type Builder
- type Error
- type ParserRelatedError
- type SanitizeError
- type TrustedFilePath
Constants ¶
const ( // DotDotSanitizeErrorMessage is the error message used in errors that occur // because a provided Bobfile path contains ".." DotDotSanitizeErrorMessage = "file path must not contain .." // InvalidPathSanitizeErrorMessage is the error message used in errors that // occur because a provided Bobfile path is invalid InvalidPathSanitizeErrorMessage = "file path is invalid" // SymlinkSanitizeErrorMessage is the error message used in errors that // occur because a provided Bobfile path contains symlinks SymlinkSanitizeErrorMessage = "file path must not contain symlinks" // DoesNotExistSanitizeErrorMessage is the error message used in cases // where the error results in the requested file not existing DoesNotExistSanitizeErrorMessage = "file requested does not exist" )
Variables ¶
var ( // SkipPush will, when set to true, override any behavior set by a Bobfile and // will cause builders *NOT* to run `docker push` commands. SkipPush is also set // by the `--skip-push` option when used on the command line. SkipPush bool )
Functions ¶
func IsSanitizeError ¶ added in v0.7.2
IsSanitizeError returns true if the error provided is of the type SanitizeError
func IsSanitizeFileNotExist ¶ added in v0.7.2
IsSanitizeFileNotExist returns true if the error provided is a SanitizeError resulting from an "os" IsNotExist PathError
func SanitizeTrustedFilePath ¶ added in v0.7.2
func SanitizeTrustedFilePath(trustedFilePath *TrustedFilePath) (*TrustedFilePath, Error)
SanitizeTrustedFilePath checks for disallowed entries in the provided file path and returns either a sanitized version of the path or an error
Types ¶
type BuildRelatedError ¶ added in v0.7.1
BuildRelatedError is used for build-related errors produced by the builder package that are encountered during the build process
func (*BuildRelatedError) Error ¶ added in v0.7.1
func (err *BuildRelatedError) Error() string
Error returns the error message for a build-related error. It is expected to be set at the time that the struct instance is created
func (*BuildRelatedError) ExitCode ¶ added in v0.7.1
func (err *BuildRelatedError) ExitCode() int
ExitCode returns the exit code for errors related to the build process. It is expected to be set during the time that struct instance is created
type Builder ¶
type Builder struct { *logrus.Logger Stderr io.Writer Stdout io.Writer Builderfile string // contains filtered or unexported fields }
A Builder is the struct that actually does the work of moving files around and executing the commands that do the docker build.
func NewBuilder ¶
NewBuilder returns an instance of a Builder struct. The function exists in case we want to initialize our Builders with something.
func (*Builder) Build ¶
func (bob *Builder) Build(tfp *TrustedFilePath) Error
Build does the building!
func (*Builder) CleanWorkdir ¶
CleanWorkdir effectively does a rm -rf and mkdir -p on bob's workdir. Intended to be used before using the workdir (i.e. before new command groups).
func (*Builder) SetNextSubSequence ¶
func (bob *Builder) SetNextSubSequence(subSeq *parser.SubSequence)
SetNextSubSequence sets the next subsequence within bob to be processed. This function is exported because it is used explicitly in tests, but in Build(), it is intended to be used as a helper function.
type Error ¶ added in v0.7.1
type Error interface { // Error returns the error message to satisfy the error interface Error() string // ExitCode returns the code that should be used when exiting as a result // of this error ExitCode() int }
Error is an interface for any error types returned by the builder package / during the building process
type ParserRelatedError ¶ added in v0.7.1
ParserRelatedError is used for errors encounted during the building process that are related to parsing the Bobfile
func (*ParserRelatedError) Error ¶ added in v0.7.1
func (err *ParserRelatedError) Error() string
Error returns the error message for a ParserRelatedError. It is expected to be set at the time that the struct instance is created
func (*ParserRelatedError) ExitCode ¶ added in v0.7.1
func (err *ParserRelatedError) ExitCode() int
ExitCode returns the exit code for errors related to parsing the Bobfile path. It is expected to be set during the time that struct instance is created
type SanitizeError ¶ added in v0.7.1
type SanitizeError struct { Message string Filename string // contains filtered or unexported fields }
SanitizeError is used for errors related to sanitizing a given Bobfile path
func (*SanitizeError) Error ¶ added in v0.7.1
func (err *SanitizeError) Error() string
Error returns the error message for a SanitizeError. It is expected to be set at the time that the struct instance is created
func (*SanitizeError) ExitCode ¶ added in v0.7.1
func (err *SanitizeError) ExitCode() int
ExitCode returns the exit code for errors related to sanitizing the Bobfile path. It is the same value for all sanitize errors.
type TrustedFilePath ¶ added in v0.7.2
type TrustedFilePath struct {
// contains filtered or unexported fields
}
TrustedFilePath contains the fields of a path to a file including "top", the top level directory containing the file, and "file", the relative path from top to the file. Top, if not provided will default to "."
func NewTrustedFilePath ¶ added in v0.7.2
func NewTrustedFilePath(file, top string) (*TrustedFilePath, error)
NewTrustedFilePath returns struct representation of the path to a file. If top is not provided (an empty string), it is defaulted to ".". The top is sanitized by evaluating all symlinks so that it can be properly sanitized by the builder when the time comes. This treats "top" as trusted (i.e. relative paths and symlinks can be evaluated safely).
func (*TrustedFilePath) File ¶ added in v0.7.2
func (b *TrustedFilePath) File() string
File returns the file component of the trusted file path
func (*TrustedFilePath) Top ¶ added in v0.7.2
func (b *TrustedFilePath) Top() string
Top returns the top level directory containing the file. The path to the top level directory as provided by Top() is considered to be trusted.