dockerfile_hasher

package
v0.0.0-...-df9c948 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

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

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

func WriteFile(lines []string, outputPath string, logger ...zerolog.Logger) (int, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL