launchpad

package
v0.0.0-...-2dfab7d Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 73 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppChartName     = "app"
	RuntimeChartName = "jetpack-runtime"

	ApiKeySecretName = "api-key-secret"
)
View Source
const (
	PortFwdTargetApp     = "app"
	PortFwdTargetRuntime = "runtime"
)

We could make this a pseudo-string-enum via: type PortFwdTarget string

Variables

View Source
var ErrPodContainerError = errorutil.NewUserError("deployment failed because of container error")
View Source
var MsgUsingProdTrialClusterWhenLoggedOut = "Your kubeconfig is using the trial cluster but you are not logged" +
	"-in. Please do `launchpad auth login` and try again."

Functions

func DockerCleanup

func DockerCleanup(ctx context.Context, labelIdentifier string) error

DockerCleanup deletes all docker images that are not the latest based on timestamp. This will only delete the images that belong to the current project.

func GetRuntimeSecretData

func GetRuntimeSecretData(
	ctx context.Context,
	kubeCtx string,
	ns string,
) (map[string][]byte, error)

func RESTConfigFromDefaults

func RESTConfigFromDefaults(currentCtx string) (*rest.Config, error)

Move out of launchpad into some sort of kubernetes package

Types

type BuildOptions

type BuildOptions struct {
	AppName string

	BuildArgs map[string]string

	LifecycleHook hook.LifecycleHook

	// Pre-built local image to use
	LocalImage string

	// ProjectDir is the absolute path to the module
	ProjectDir string

	ProjectId string

	// Platform informs docker which architecture to build for.
	// Examples: linux/arm64 (for M1 macs) linux/amd64 (for intel macs)
	Platform string

	Services map[string]jetconfig.Builder

	RemoteCache bool

	RepoConfig        provider.RepoConfig // required for remote cache feature
	ImageRepoForCache string

	TagPrefix string
}

func (*BuildOptions) GetBuilders

func (b *BuildOptions) GetBuilders() map[string]jetconfig.Builder

func (*BuildOptions) GetRepoHost

func (b *BuildOptions) GetRepoHost() string

type BuildOutput

type BuildOutput struct {
	Duration time.Duration
	Image    *LocalImage
}

func (*BuildOutput) DidBuildUsingDockerfile

func (o *BuildOutput) DidBuildUsingDockerfile() bool

func (*BuildOutput) SetDuration

func (o *BuildOutput) SetDuration(d time.Duration)

type BuildPlan

type BuildPlan struct {
	// contains filtered or unexported fields
}

type Builder

type Builder interface {
	Build(ctx context.Context, opts *BuildOptions) (*BuildOutput, error)
}

This file has the public interface to the launchpad package

type ChartConfig

type ChartConfig struct {
	Repo      string
	Name      string
	Namespace string
	Release   string // unique identifier for installation (can be same or different from display name)
	Timeout   gotime.Duration
	Wait      bool
	// contains filtered or unexported fields
}

func (*ChartConfig) HumanName

func (c *ChartConfig) HumanName() string

type DeployOptions

type DeployOptions struct {
	App *HelmOptions

	Environment string // api.Environment

	ExternalCharts []*ChartConfig

	IsLocalCluster bool

	// We should remove this jetconfig dependency. Pass in an interface. This will be easier to design
	// once we have a few service types implemented, and we understand the concrete
	// requirements. Leaving jetconfig in for now.
	JetCfg *jetconfig.Config

	KubeContext string

	LifecycleHook hook.LifecycleHook

	Namespace       string
	CreateNamespace bool

	RemoteEnvVars map[string]string
	Runtime       *HelmOptions

	SecretFilePaths []string

	ReinstallOnHelmUpgradeError bool
}

TODO: fix spacing in this struct

type DeployOutput

type DeployOutput struct {
	Duration     gotime.Duration
	InstanceName string
	Namespace    string
	Releases     map[string]*release.Release // keyed by unique chart name
}

func (*DeployOutput) AppPort

func (do *DeployOutput) AppPort() int

func (*DeployOutput) SetDuration

func (do *DeployOutput) SetDuration(d gotime.Duration)

type DeployPlan

type DeployPlan struct {
	DeployOptions *DeployOptions
	// contains filtered or unexported fields
}

func (*DeployPlan) Charts

func (dp *DeployPlan) Charts() []*ChartConfig

type Deployer

type Deployer interface {
	Deploy(ctx context.Context, opts *DeployOptions) (*DeployOutput, error)
}

type DownOptions

type DownOptions struct {
	ExternalCharts []*ChartConfig
	ReleaseName    string
	InstanceName   string
	Namespace      string
	KubeContext    string
}

type HelmOptions

type HelmOptions struct {
	ChartLocation string
	InstanceName  string // display name for helm install
	ReleaseName   string // app identifier for helm install
	Timeout       time.Duration
	Values        map[string]any
}

type ImageRegistry

type ImageRegistry struct {
	// contains filtered or unexported fields
}

func (*ImageRegistry) GetHost

func (ir *ImageRegistry) GetHost() registryHost

type LaunchPad

type LaunchPad interface {
	Builder
	Publisher
	Deployer
	Down(ctx context.Context, do *DownOptions) error
	PortForward(ctx context.Context, opts *PortForwardOptions) error
}

type LocalImage

type LocalImage string

func NewLocalImage

func NewLocalImage(n string) *LocalImage

func (*LocalImage) Name

func (l *LocalImage) Name() string

func (*LocalImage) String

func (l *LocalImage) String() string

func (*LocalImage) Tag

func (l *LocalImage) Tag() string

type LocalOptions

type LocalOptions struct {
	BuildOut            *BuildOutput
	SdkCmd              string
	ExecQualifiedSymbol string
	LocalEnvVars        map[string]string
	RemoteEnvVars       map[string]string
}

type Pad

type Pad struct {
	// contains filtered or unexported fields
}

Pad has the foundational elements on top of which the LaunchPad is constructed.

func NewPad

func NewPad(errorLogger provider.ErrorLogger) *Pad

func NewPadForTest

func NewPadForTest() *Pad

func (*Pad) Build

func (p *Pad) Build(
	ctx context.Context,
	opts *BuildOptions,
) (*BuildOutput, error)

Build uses the Dockerfile to build a docker image of the module

func (*Pad) CreateAndStartContainerInLocalMode

func (p *Pad) CreateAndStartContainerInLocalMode(ctx context.Context, opts *LocalOptions) (err error)

func (*Pad) Deploy

func (p *Pad) Deploy(
	ctx context.Context,
	opts *DeployOptions,
) (*DeployOutput, error)

Deploy creates kubernetes resources from the Manifest

func (*Pad) Down

func (p *Pad) Down(ctx context.Context, do *DownOptions) error

func (*Pad) PortForward

func (p *Pad) PortForward(ctx context.Context, opts *PortForwardOptions) error

func (*Pad) Publish

func (p *Pad) Publish(
	ctx context.Context,
	opts *PublishOptions,
) (*PublishOutput, error)

If an image-registry is specified, Publish will send the docker image built by Build() to a docker-registry TODO(Landau) rename to push so more closely resemble `docker push` and reduce ambiguity with publishing as a means to make something public.

func (*Pad) RunLocally

func (p *Pad) RunLocally(
	ctx context.Context,
	opts *LocalOptions,
) error

func (*Pad) TailLogs

func (p *Pad) TailLogs(ctx context.Context, kubeCtx string, do *DeployOutput) error

func (*Pad) TailLogsForAppExec

func (p *Pad) TailLogsForAppExec(ctx context.Context, kubeCtx string, do *DeployOutput) error

func (*Pad) TailLogsOnErr

func (p *Pad) TailLogsOnErr(ctx context.Context, kubeCtx string, do *DeployOutput) error

func (*Pad) ToManifest

func (p *Pad) ToManifest() error

ToManifest produces Helm Charts

type PortForwardOptions

type PortForwardOptions struct {
	AppOrRuntime string // 'app' or 'runtime'
	DeployOut    *DeployOutput
	KubeCtx      string
	PodPort      int
	Target       string
}

type PublishImagePlan

type PublishImagePlan struct {
	// contains filtered or unexported fields
}

type PublishOptions

type PublishOptions struct {
	AnalyticsProvider    provider.Analytics
	AWSCredentials       aws.CredentialsProvider // Required to create ECR repos
	ImageRepoCredentials string

	// ImageRegistryWithRepo is <registry-uri>/<repository-path>
	ImageRegistryWithRepo string
	LifecycleHook         hook.LifecycleHook
	LocalImages           []*LocalImage
	Region                string
	TagPrefix             string
}

type PublishOutput

type PublishOutput struct {
	Duration time.Duration
	// contains filtered or unexported fields
}

func (*PublishOutput) DidPublish

func (o *PublishOutput) DidPublish() bool

func (*PublishOutput) PublishedImages

func (o *PublishOutput) PublishedImages() map[string]string

func (*PublishOutput) RegistryHost

func (o *PublishOutput) RegistryHost() string

func (*PublishOutput) SetDuration

func (do *PublishOutput) SetDuration(d time.Duration)

type PublishPlan

type PublishPlan struct {
	// contains filtered or unexported fields
}

type Publisher

type Publisher interface {
	Publish(ctx context.Context, opts *PublishOptions) (*PublishOutput, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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