Documentation ¶
Overview ¶
Package dockerfile_hasher is a package that provides the ability to read a Dockerfile from disk, parse it into an Abstract Syntax Tree (AST), and then rewrite the lines in the Dockerfile with the SHA256 digest of the image.
Supports logging with the https://github.com/rs/zerolog package.
Index ¶
- func ModifyFromLines(dockerfile *parser.Result, rawParser wlParser.RawDockerfileParser, ...) ([]string, error)
- func ReadFile(fsPath string, logger ...zerolog.Logger) (*parser.Result, wlParser.RawDockerfileParser, []instructions.Stage, error)
- func WriteFile(lines []string, outputPath string, logger ...zerolog.Logger) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ModifyFromLines ¶
func ModifyFromLines( dockerfile *parser.Result, rawParser wlParser.RawDockerfileParser, stageList []instructions.Stage, logger ...zerolog.Logger, ) ([]string, error)
ModifyFromLines takes the raw parsed object of the Dockerfile and staging information, and performs a rewrite of the FROM lines in the Dockerfile to include the SHA256 digest of the image.
----
Arguments:
- dockerfile (*parser.Result): The raw parsed object of the Dockerfile.
- rawParser (wlParser.RawDockerfileParser): The raw parsed object of the Dockerfile.
- stageList ([]instructions.Stage): A list of stages parsed from the Dockerfile.
- logger (...zerolog.Logger): An optional logger object using zerolog.
----
Returns:
- []string: The rewritten lines of the Dockerfile.
- error: An error object if something went wrong.
func ReadFile ¶
func ReadFile( fsPath string, logger ...zerolog.Logger, ) (*parser.Result, wlParser.RawDockerfileParser, []instructions.Stage, error)
ReadFile reads the contents of the Dockerfile from disk and parses it into an Abstract Syntax Tree (AST).
----
Arguments:
- fsPath (string): The path to the Dockerfile on disk.
- logger (...zerolog.Logger): An optional logger object using zerolog.
----
Returns:
- *parser.Result: The raw parsed object of the Dockerfile.
- wlParser.RawDockerfileParser: The raw parsed object of the Dockerfile.
- []instructions.Stage: A list of stages parsed from the Dockerfile.
- error: An error object if something went wrong.
func WriteFile ¶
WriteFile takes the rewritten lines and writes them back to disk as a new Dockerfile.
----
Arguments:
- lines ([]string): The rewritten lines of the Dockerfile.
- outputPath (string): The path to the new Dockerfile on disk. If empty, will write to stdout.
- logger (...zerolog.Logger): An optional logger object using zerolog.
----
Returns:
- int: The number of bytes written to the new Dockerfile.
- error: An error object if something went wrong.
Types ¶
This section is empty.