generate

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package generate provides functions to generate a Lockfile.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseImage

type BaseImage struct {
	Image *Image
	// contains filtered or unexported fields
}

BaseImage represents an image in a Dockerfile's FROM instruction or a docker-compose file's image key.

type ComposefileFlags

type ComposefileFlags struct {
	*SpecificFlags
}

ComposefileFlags are flags that determine how docker-compose files are processed.

type ComposefileImage

type ComposefileImage struct {
	*Image
	ServiceName    string `json:"serviceName"`
	DockerfilePath string `json:"dockerfile"`
	// contains filtered or unexported fields
}

ComposefileImage contains an Image along with metadata used to generate a Lockfile.

type DockerfileFlags

type DockerfileFlags struct {
	*SpecificFlags
	UseEnvAsBuildArgs bool
}

DockerfileFlags are flags that determine how Dockerfiles are processed.

type DockerfileImage

type DockerfileImage struct {
	*Image
	// contains filtered or unexported fields
}

DockerfileImage contains an Image along with metadata used to generate a Lockfile.

type Flags

type Flags struct {
	*SharedFlags
	DockerfileFlags  *DockerfileFlags
	ComposefileFlags *ComposefileFlags
}

Flags consist of SharedFlags, DockerfileFlags, and ComposefileFlags.

func NewFlags

func NewFlags(
	bDir, lName, configFile, envFile string,
	dfiles, cfiles, dGlobs, cGlobs []string,
	dRecursive, cRecursive, dfileEnvBuildArgs, verbose bool,
) (*Flags, error)

NewFlags preprocesses and validates flags for Dockerfiles and docker-compose files.

type Generator

type Generator struct {
	DockerfilePaths        []string
	ComposefilePaths       []string
	DockerfileEnvBuildArgs bool
	LockfileName           string
}

Generator generates Lockfiles. DockerfileEnvBuildArgs determines whether environment variables should be used as build args in Dockerfiles.

func NewGenerator

func NewGenerator(flags *Flags) (*Generator, error)

NewGenerator creates a Generator from command line flags. If no Dockerfiles or docker-compose files are specified as flags, files that match "Dockerfile", "docker-compose.yml", and "docker-compose.yaml" will be used. If files are specified in command line flags, only those files will be used.

func (*Generator) GenerateLockfile

func (g *Generator) GenerateLockfile(
	wm *registry.WrapperManager,
	w io.Writer,
) error

GenerateLockfile creates a Lockfile and writes its bytes to an io.Writer.

type Image

type Image struct {
	Name   string `json:"name"`
	Tag    string `json:"tag"`
	Digest string `json:"digest"`
}

Image contains information extracted from 'FROM' instructions in Dockerfiles or 'image:' keys in docker-compose files. For instance, FROM busybox:latest@sha256:dd97a3f... could be represented as: Image{Name: busybox, Tag: latest, Digest: dd97a3f...}.

func (*Image) String

func (i *Image) String() string

String formats an Image as json.

type Lockfile

type Lockfile struct {
	DockerfileImages  map[string][]*DockerfileImage  `json:"dockerfiles"`
	ComposefileImages map[string][]*ComposefileImage `json:"composefiles"`
}

Lockfile contains DockerfileImages and ComposefileImages identified by their filepaths.

func NewLockfile

func NewLockfile(
	dIms map[string][]*DockerfileImage,
	cIms map[string][]*ComposefileImage,
) *Lockfile

NewLockfile creates a Lockfile, first sorting DockerfileImages and ComposefileImages.

func (*Lockfile) Write

func (l *Lockfile) Write(w io.Writer) error

Write writes a Lockfile to an io.Writer, formatted as indented json.

type SharedFlags

type SharedFlags struct {
	BaseDir      string
	LockfileName string
	ConfigFile   string
	EnvFile      string
	Verbose      bool
}

SharedFlags are flags that do not differ between Dockerfiles and docker-compose files.

func NewSharedFlags

func NewSharedFlags(
	bDir string,
	lName string,
	configFile string,
	envFile string,
	verbose bool,
) (*SharedFlags, error)

NewSharedFlags preprocesses and validates the fields of SharedFlags.

type SpecificFlags

type SpecificFlags struct {
	Paths     []string
	Globs     []string
	Recursive bool
}

SpecificFlags are flags whose values differ between Dockerfiles and docker-compose files.

func NewSpecificFlags

func NewSpecificFlags(
	bDir string,
	paths []string,
	globs []string,
	recursive bool,
) (*SpecificFlags, error)

NewSpecificFlags preprocesses and validates the fields of SpecificFlags.

Jump to

Keyboard shortcuts

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