bridgr

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2020 License: MIT Imports: 43 Imported by: 0

Documentation

Overview

Package bridgr downloads artifacts based on a configuration file

Index

Constants

This section is empty.

Variables

View Source
var (
	// Verbose determines whether debug logging is printed
	Verbose = false

	// Version is the built version of Bridgr
	Version = "development"

	// DryRun holds whether workers should actually retrieve artifacts, or just do setup
	DryRun = false

	// FileTimeout is the duration used for HTTP/s file download overall timeout. Used in the transport object
	FileTimeout = time.Second * 20
)

Functions

func BaseDir

func BaseDir(repo string) string

BaseDir gives the runtime absolute directory of the base "packages" directory See the individual repo type struct for the type-specific path

func PullImage

func PullImage(cli ImagePuller, image reference.Named) error

PullImage is a helper function that Pulls a docker image to the local docker daemon

func Serve

func Serve(addr string, root http.FileSystem) error

Serve starts and runs the static web server for Bridgr

Types

type Configuration

type Configuration interface {
	Name() string
	Image() reference.Named
	Hook() mapstructure.DecodeHookFunc
	Setup() error
	Run() error
}

Configuration is a type that unifies all of the sub-types of repository configurations It has a Hook function that returns a list of functions used for parsing its types with mapstructure decoding. Image is a configuration that can return a reference to a docker image that should be used for running its worker. This is a type that must be "batch" run in a docker image to create its repository

type Credential

type Credential struct {
	Username string
	Password string
}

Credential encapsulates a username/password pair

func (*Credential) Base64

func (c *Credential) Base64() string

Base64 returns a string with the provided Credential content base64 encoded after being joined by ':' (colon character)

func (*Credential) Conjoin

func (c *Credential) Conjoin() string

Conjoin returns a string with the Credential content joined by a ':' (colon character)

func (*Credential) IsValid added in v1.5.1

func (c *Credential) IsValid() bool

IsValid returns a boolean to indicate that the Credential has at least a Username or a Password

type CredentialReader

type CredentialReader interface {
	Read(*url.URL) (Credential, bool)
}

CredentialReader is the interface that wraps a Credential Read method The Reader should get credential information from somewhere (usually the runtime environment), and returns a Credential struct as well as a boolean that indicates whether the reading of credential pieces (ie, Username, Password and/or Token) was successful. Success is not strictly whether the pieces of information were found, but whether they existed in the environment to be read. A Credential struct with empty strings for its fields is still a valid Credential

type CredentialReaderWriter

type CredentialReaderWriter interface {
	CredentialReader
	CredentialWriter
}

CredentialReaderWriter is an interface that combines both the CredentialReader and CredentialWriter

type CredentialWriter

type CredentialWriter interface {
	Write(Credential) error
}

CredentialWriter is the interface wrapping the Write method for Credentials Write may write a credential to any form (string, another struct), and any medium (memory, file, etc).

type Docker

type Docker struct {
	Destination string `mapstructure:"repository,omitempty"`
	Images      []reference.Named
}

Docker struct is the configuration holder for the Docker worker type

func (*Docker) Hook

Hook implements the Parser interface, returns a function for use by mapstructure when parsing config files

func (Docker) Image

func (d Docker) Image() reference.Named

Image implements the Imager interface

func (Docker) Name

func (d Docker) Name() string

Name returns the name of this Configuration

func (*Docker) Run

func (d *Docker) Run() error

Run executes the Docker worker to fetch artifacts

func (*Docker) Setup

func (d *Docker) Setup() error

Setup gets the environment ready to run the Docker worker

type DockerCredential

type DockerCredential struct {
	types.AuthConfig
	WorkerCredentialReader
}

DockerCredential implements the CredentialReader and CredentialWriter interface for the Docker "login" format

func (*DockerCredential) String

func (credWriter *DockerCredential) String() string

func (*DockerCredential) Write

func (credWriter *DockerCredential) Write(c Credential) error

type File

type File []*FileItem

File is the implementation for static File repositories

func (*File) Hook

func (f *File) Hook() mapstructure.DecodeHookFunc

Hook implements the Parser interface, returns a function for use by mapstructure when parsing config files

func (File) Image

func (f File) Image() reference.Named

Image returns the Named image for executing

func (File) Name

func (f File) Name() string

Name returns the name of this Configuration

func (File) Run

func (f File) Run() error

Run sets up, creates and fetches static files based on the settings from the config file

func (File) Setup

func (f File) Setup() error

Setup only does the setup step of the Files worker

type FileItem

type FileItem struct {
	Source *url.URL
	Target string
	// contains filtered or unexported fields
}

FileItem is a discreet file definition object

func (*FileItem) Normalize

func (fi *FileItem) Normalize(basedir string) string

Normalize sets the FileItems' Target field to the proper destination string

func (FileItem) String

func (fi FileItem) String() string

type Git

type Git []GitItem

Git is the struct for holding a Git configuration in Bridgr

func (*Git) Hook

func (g *Git) Hook() mapstructure.DecodeHookFunc

Hook implements the Parser interface, returns a function for use by mapstructure when parsing config files

func (Git) Image

func (g Git) Image() reference.Named

Image implements the Imager interface

func (Git) Name

func (g Git) Name() string

Name returns the name of this Configuration

func (*Git) Run

func (g *Git) Run() error

Run executes the Git worker to fetch artifacts

func (*Git) Setup

func (g *Git) Setup() error

Setup does any initial setup for the Git worker

type GitItem

type GitItem struct {
	URL    *url.URL
	Bare   bool
	Branch plumbing.ReferenceName
	Tag    plumbing.ReferenceName
}

GitItem is the sub-struct of items in a Git struct

func NewGitItem

func NewGitItem(repo string) GitItem

NewGitItem creates a new, default GitItem struct

func (GitItem) String

func (gi GitItem) String() string

type Helm added in v1.5.1

type Helm []*FileItem

Helm is a list of files that represent Helm charts, and have both a source and target

func (*Helm) Hook added in v1.5.1

func (h *Helm) Hook() mapstructure.DecodeHookFunc

Hook returns a list of DecodeHookFunc objects that are needed to decode a generic object into a Helm struct. It is used with mapstructure library.

func (Helm) Image added in v1.5.1

func (h Helm) Image() reference.Named

Image returns the docker image used for collecting Helm charts in this worker. It is always nil, as the Helm worker doesn't use docker.

func (Helm) Name added in v1.5.1

func (h Helm) Name() string

Name returns the name string of this Helm worker

func (Helm) Run added in v1.5.1

func (h Helm) Run() error

Run downloads the requested Helm charts, and creates an index for statically hosting them

func (Helm) Setup added in v1.5.1

func (h Helm) Setup() error

Setup prepares the Helm charts for fetching and indexing.

type ImagePuller

type ImagePuller interface {
	ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error)
}

ImagePuller is a simplified interface to docker ImageAPIClient, that only defines the ImagePull function

type Python

type Python struct {
	Packages []pythonPackage
	Version  pythonVersion
	Sources  []string
}

Python is the configuration object specifically for the Python section of the config file

func (*Python) Hook

Hook implements the Parser interface, returns a function for use by mapstructure when parsing config files

func (Python) Image

func (p Python) Image() reference.Named

Image implements the Imager interface

func (Python) Name

func (p Python) Name() string

Name returns the name of this Configuration

func (Python) Run

func (p Python) Run() error

Run fetches all artifacts for the Python configuration

func (Python) Setup

func (p Python) Setup() error

Setup creates the items that are needed to fetch artifacts for the Python worker. It does not actually fetch artifacts.

type Ruby

type Ruby struct {
	Gems    []rubyItem
	Version rubyVersion
	Sources []string
}

Ruby struct is the configuration object specifically for the Ruby section of the config file

func (Ruby) Hook

func (r Ruby) Hook() mapstructure.DecodeHookFunc

Hook implements the Parser interface, returns a function for use by mapstructure when parsing config files

func (*Ruby) Image

func (r *Ruby) Image() reference.Named

Image implements the Imager interface

func (Ruby) Name

func (r Ruby) Name() string

Name returns the name of this Configuration

func (*Ruby) Run

func (r *Ruby) Run() error

Run fetches all artifacts for the Python configuration

func (*Ruby) Setup

func (r *Ruby) Setup() error

Setup creates the items that are needed to fetch artifacts for the Python worker. It does not actually fetch artifacts.

type WorkerCredentialReader

type WorkerCredentialReader struct{}

WorkerCredentialReader reads a credential for a URL from the environment variables

func (*WorkerCredentialReader) Read

func (w *WorkerCredentialReader) Read(url *url.URL) (Credential, bool)

type Yum

type Yum struct {
	Repos    []string
	Packages []string
	Version  yumVersion
}

Yum sets up and creates an YUM repository based on user configuration

func (*Yum) Hook

func (y *Yum) Hook() mapstructure.DecodeHookFunc

Hook implements the Parser interface, returns a function for use by mapstructure when parsing config files

func (Yum) Image

func (y Yum) Image() reference.Named

Image returns the docker image that will be used for the batch execution

func (Yum) Name

func (y Yum) Name() string

Name returns the name of this Configuration

func (Yum) Run

func (y Yum) Run() error

Run sets up, creates and fetches a YUM repository based on the settings from the config file

func (Yum) Setup

func (y Yum) Setup() error

Setup only does the setup step of the YUM worker

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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