infra

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigFilePath = "/config.json"

ConfigFilePath is the path to proxy config file.

Variables

View Source
var CertSubject = pkix.Name{
	CommonName:         "Dependabot Internal CA",
	OrganizationalUnit: []string{"Dependabot"},
	Organization:       []string{"GitHub Inc."},
	Locality:           []string{"San Francisco"},
	Province:           []string{"California"},
	Country:            []string{"US"},
}
View Source
var ProxyImageName = "ghcr.io/github/dependabot-update-job-proxy/dependabot-update-job-proxy:latest"

ProxyImageName is the docker image used by the proxy

View Source
var UpdaterImageName = "ghcr.io/dependabot/dependabot-updater:latest"

UpdaterImageName is the docker image used by the updater

Functions

func MonitorTtySize

func MonitorTtySize(ctx context.Context, out *streams.Out, cli *client.Client, id string, isExec bool) error

MonitorTtySize updates the container tty size when the terminal tty changes size

func Run

func Run(params RunParams) error

func SetupOutputDir

func SetupOutputDir(tempDir string) (string, error)

func StoreProxyConfig

func StoreProxyConfig(tmpPath string, config *Config) (string, error)

StoreProxyConfig saves the config to a temporary file, returning the path

func TempDir

func TempDir(tmpPath string) string

TempDir centralizes where the temporary directory is created.

func WriteContainerInput

func WriteContainerInput(tempDir string, input interface{}) (string, error)

Types

type BasicAuthCredentials

type BasicAuthCredentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

BasicAuthCredentials represents credentials required for HTTP basic auth

type CertificateAuthority

type CertificateAuthority struct {
	Cert string `json:"cert"`
	Key  string `json:"key"`
}

CertificateAuthority includes the MITM CA certificate and private key

func GenerateCertificateAuthority

func GenerateCertificateAuthority() (CertificateAuthority, error)

GenerateCertificateAuthority generates a new proxy keypair CA

type Config

type Config struct {
	Credentials []map[string]string  `json:"all_credentials"`
	CA          CertificateAuthority `json:"ca"`
}

Config is the structure of the proxy's config file

type FileFetcherJobFile

type FileFetcherJobFile struct {
	Job model.Job `json:"job"`
}

FileFetcherJobFile is the payload passed to file updater containers.

type Networks

type Networks struct {
	NoInternet types.NetworkCreateResponse
	Internet   types.NetworkCreateResponse
	// contains filtered or unexported fields
}

func NewNetworks

func NewNetworks(ctx context.Context, cli *client.Client) (*Networks, error)

func (*Networks) Close

func (n *Networks) Close() error

type Proxy

type Proxy struct {
	CertPath string
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(ctx context.Context, cli *client.Client, params *RunParams, nets ...types.NetworkCreateResponse) (*Proxy, error)

func (*Proxy) Close

func (p *Proxy) Close() error

func (*Proxy) TailLogs

func (p *Proxy) TailLogs(ctx context.Context, cli *client.Client)

type RunParams

type RunParams struct {
	// job definition passed to the updater
	Job *model.Job
	// expectations asserted at the end of a test
	Expected []model.Output
	// credentials passed to the proxy
	Creds []map[string]string
	// local directory used for caching
	CacheDir string
	// write output to a file
	Output string
	// ProxyCertPath is the path to a cert for the proxy to trust
	ProxyCertPath string
	// attempt to pull images if they aren't local?
	PullImages bool
	// run an interactive shell?
	Debug bool
	// Volumes are used to mount directories in Docker
	Volumes []string
	// Timeout specifies an optional maximum duration the CLI will run an update.
	// If Timeout is <= 0 it will never time out.
	Timeout time.Duration
	// TempDir is the path to use as the temporary directory.
	TempDir string
	// ExtraHosts adds /etc/hosts entries to the proxy for testing.
	ExtraHosts []string
}

type Updater

type Updater struct {
	RepoDir string
	// contains filtered or unexported fields
}

func NewUpdater

func NewUpdater(ctx context.Context, cli *client.Client, net *Networks, params *RunParams, prox *Proxy) (*Updater, error)

NewUpdater starts the update container interactively running /bin/sh, so it does not stop.

func (*Updater) Close

func (u *Updater) Close() error

Close kills and deletes the container and deletes updater mount paths related to the run.

func (*Updater) InstallCertificates

func (u *Updater) InstallCertificates(ctx context.Context) error

InstallCertificates runs update-ca-certificates as root, blocks until complete.

func (*Updater) RunShell

func (u *Updater) RunShell(ctx context.Context, proxyURL string, apiPort int) error

RunShell executes an interactive shell, blocks until complete.

func (*Updater) RunUpdate

func (u *Updater) RunUpdate(ctx context.Context, proxyURL string, apiPort int) error

RunUpdate executes the update scripts as the dependabot user, blocks until complete.

func (*Updater) Wait

func (u *Updater) Wait(ctx context.Context, condition container.WaitCondition) error

Wait blocks until the condition is true.

Jump to

Keyboard shortcuts

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