infra

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigFilePath = "/config.json"

ConfigFilePath is the path to proxy config file.

View Source
const ProxyImageName = "ghcr.io/github/dependabot-update-job-proxy/dependabot-update-job-proxy:latest"

ProxyImageName is the default Docker image used by the proxy

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 ErrInvalidVolume = fmt.Errorf("invalid volume syntax")
View Source
var (
	ErrWriteAccess = fmt.Errorf("for security, credentials used in update are not allowed to have write access to GitHub API")
)

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

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 []model.Credential   `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 {
	// 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 {
	// Input file
	Input string
	// 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 []model.Credential
	// 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
	// ExtraHosts adds /etc/hosts entries to the proxy for testing.
	ExtraHosts []string
	// UpdaterImage is the image to use for the updater
	UpdaterImage string
	// ProxyImage is the image to use for the proxy
	ProxyImage string
	// Writer is where API calls will be written to
	Writer    io.Writer
	InputName string
	InputRaw  []byte
}

type Updater

type Updater struct {
	// 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) 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