Documentation ¶
Overview ¶
Package parser package help parse various strings into meaningful - bash commands or chains of bash commands.
Index ¶
- func HasPackageUpdateCommand(packageManager string, bashCommand BashCommand) bool
- func IsApkPackageInstall(bashCommand BashCommand) bool
- func IsApkPackageManager(bin string) bool
- func IsArchPackageManager(bin string) bool
- func IsDebPackageInstall(bashCommand BashCommand) bool
- func IsDebPackageManager(bin string) bool
- func IsDnfPackageManager(bin string) bool
- func IsFedoraPackageInstall(bashCommand BashCommand) bool
- func IsNpmPackageInstall(bashCommand BashCommand) bool
- func IsNpmPackageManager(bin string) bool
- func IsPythonPackageInstall(bashCommand BashCommand) bool
- func IsPythonPackageManager(bin string) bool
- func IsRpmPackageInstall(bashCommand BashCommand) bool
- func IsRpmPackageManager(bin string) bool
- func IsRubyPackageInstall(bashCommand BashCommand) bool
- func IsRubyPackageManager(bin string) bool
- func IsSusePackageInstall(bashCommand BashCommand) bool
- func IsZyppPackageManager(bin string) bool
- func SplitBashChainLex(strList []string) ([][]string, []string)
- type BashCommand
- func (bashCommand *BashCommand) ArgMap() map[string]string
- func (bashCommand *BashCommand) Bin() string
- func (bashCommand *BashCommand) EnvVars() map[string]string
- func (bashCommand *BashCommand) HasSudo() bool
- func (bashCommand *BashCommand) OptionKeyList() []string
- func (bashCommand *BashCommand) OptionList() map[string]string
- func (bashCommand *BashCommand) String() string
- func (bashCommand *BashCommand) SubCommand() string
- type BashCommandChain
- type RawDockerfileParser
- func (r *RawDockerfileParser) IsInitialized() bool
- func (r *RawDockerfileParser) ParseDockerfile(filePath string) error
- func (r *RawDockerfileParser) ParseRawLineRange(p []parser.Range) []string
- func (r *RawDockerfileParser) StringLocation(str string, window []parser.Range) [4]int
- func (r *RawDockerfileParser) StringSliceLocation(strSlice []string, window []parser.Range) [][4]int
- func (r *RawDockerfileParser) UpdateRawStr(str string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasPackageUpdateCommand ¶
func HasPackageUpdateCommand(packageManager string, bashCommand BashCommand) bool
func IsApkPackageInstall ¶
func IsApkPackageInstall(bashCommand BashCommand) bool
func IsApkPackageManager ¶
func IsArchPackageManager ¶
func IsDebPackageInstall ¶
func IsDebPackageInstall(bashCommand BashCommand) bool
func IsDebPackageManager ¶
func IsDnfPackageManager ¶
func IsFedoraPackageInstall ¶
func IsFedoraPackageInstall(bashCommand BashCommand) bool
func IsNpmPackageInstall ¶
func IsNpmPackageInstall(bashCommand BashCommand) bool
func IsNpmPackageManager ¶
func IsPythonPackageInstall ¶
func IsPythonPackageInstall(bashCommand BashCommand) bool
func IsPythonPackageManager ¶
func IsRpmPackageInstall ¶
func IsRpmPackageInstall(bashCommand BashCommand) bool
func IsRpmPackageManager ¶
func IsRubyPackageInstall ¶
func IsRubyPackageInstall(bashCommand BashCommand) bool
func IsRubyPackageManager ¶
func IsSusePackageInstall ¶
func IsSusePackageInstall(bashCommand BashCommand) bool
func IsZyppPackageManager ¶
func SplitBashChainLex ¶
splitBashChainLex splits a bash command lex chain on a set of delimiters. It returns the list of bash commands lexes in the chain and the delimiters between them.
Types ¶
type BashCommand ¶
type BashCommand struct {
// contains filtered or unexported fields
}
BashCommand represents a single bash command in a semantically mostly parsed form. It includes - any environment variables defined before, the - binary, - sub-command optionally - only for selected binaries for which a rule exits, like apt-get, - options, e.g. --yes, - rest of the argument list, - raw string of the bash command, - sudo modifier.
func NewBashCommand ¶
func ParseBashCommand ¶
func ParseBashCommand(bashCommandLex []string) BashCommand
ParseBashCommand parses a bash command from a []string format. The latter is currently obtained by github.com/google/shlex::Split. nolint:funlen
func ParseBashCommandList ¶
func ParseBashCommandList(command interface{}) []BashCommand
ParseBashCommandList parses a list of bash commands, either from a raw string or buildkit::*instructions.RunCommand.
func (*BashCommand) ArgMap ¶
func (bashCommand *BashCommand) ArgMap() map[string]string
ArgMap returns the argument list of the bash command.
func (*BashCommand) Bin ¶
func (bashCommand *BashCommand) Bin() string
Bin returns the binary of the command.
func (*BashCommand) EnvVars ¶
func (bashCommand *BashCommand) EnvVars() map[string]string
EnvVars returns the environment variables defined before the binary on the same line.
func (*BashCommand) HasSudo ¶
func (bashCommand *BashCommand) HasSudo() bool
HasSudo tells whether the command has a sudo modifier in front of it.
func (*BashCommand) OptionKeyList ¶
func (bashCommand *BashCommand) OptionKeyList() []string
OptionKeyList returns the options passed to the binary and/or the subcommand as a slice, but not the values.
func (*BashCommand) OptionList ¶
func (bashCommand *BashCommand) OptionList() map[string]string
OptionList returns the options passed to the binary and/or the subcommand, like --yes.
func (*BashCommand) String ¶
func (bashCommand *BashCommand) String() string
String returns the raw string of the bash command, that served as the basis of the parsing.
func (*BashCommand) SubCommand ¶
func (bashCommand *BashCommand) SubCommand() string
SubCommand returns the optional subcommand for the selected set of pre-known binaries.
type BashCommandChain ¶
type BashCommandChain struct { BashCommandList []BashCommand OperatorList []string }
BashCommandChain represents a chain of bash commands. e.g. "date; mkdir /test && ls test || echo "test" BashCommandList holds the individual bash commands, while OperatorList the operators - "&", "&&", "|", "||", ";".
func ParseBashCommandChain ¶
func ParseBashCommandChain(command interface{}) BashCommandChain
ParseBashCommandChain parses a chain of bash commands separated by bash operators [&, &&, |, ||, ;, etc.]. Currently it can digest either a raw string or a buildkit::*instructions.RunCommand.
type RawDockerfileParser ¶
type RawDockerfileParser struct {
// contains filtered or unexported fields
}
var RawParser RawDockerfileParser = RawDockerfileParser{/* contains filtered or unexported fields */} // nolint:gochecknoglobals
func (*RawDockerfileParser) IsInitialized ¶
func (r *RawDockerfileParser) IsInitialized() bool
func (*RawDockerfileParser) ParseDockerfile ¶
func (r *RawDockerfileParser) ParseDockerfile(filePath string) error
func (*RawDockerfileParser) ParseRawLineRange ¶
func (r *RawDockerfileParser) ParseRawLineRange(p []parser.Range) []string
func (*RawDockerfileParser) StringLocation ¶
func (r *RawDockerfileParser) StringLocation(str string, window []parser.Range) [4]int
func (*RawDockerfileParser) StringSliceLocation ¶
func (r *RawDockerfileParser) StringSliceLocation(strSlice []string, window []parser.Range) [][4]int
func (*RawDockerfileParser) UpdateRawStr ¶
func (r *RawDockerfileParser) UpdateRawStr(str string)