builder

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationBuilder

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

ApplicationBuilder builds an application image

func NewApplicationBuilder

func NewApplicationBuilder(config Config) (*ApplicationBuilder, error)

NewApplicationBuilder returns a builder that produces application images.

func (*ApplicationBuilder) Build

Build builds an application image according to the provided parameters.

func (*ApplicationBuilder) Close

func (b *ApplicationBuilder) Close() error

Close closes the builder

type ApplicationRequest

type ApplicationRequest struct {
	// ChartPath is path to a Helm chart to build an image from.
	ChartPath string
	// OutputPath is the resulting cluster image output file path.
	OutputPath string
	// Overwrite is whether to overwrite existing output file.
	Overwrite bool
	// Vendor combines vendoring parameters.
	Vendor service.VendorRequest
}

ApplicationRequest combines parameters for building an application image.

type ClusterBuilder

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

func NewClusterBuilder

func NewClusterBuilder(config Config) (*ClusterBuilder, error)

NewClusterBuilder returns a builder that produces cluster images.

func (*ClusterBuilder) Build

func (b *ClusterBuilder) Build(ctx context.Context, req ClusterRequest) error

Build builds a cluster image according to the provided parameters.

func (*ClusterBuilder) Close

func (b *ClusterBuilder) Close() error

Close closes the builder

type ClusterImageSource

type ClusterImageSource interface {
	// Dir is the directory where cluster image source is located.
	Dir() string
	// Manifest returns an appropriate cluster image manifest for this source.
	Manifest() (*schema.Manifest, error)
	// Type returns the source type.
	Type() string
}

ClusterImageSource defines a source a cluster image can be built from.

It can be either a manifest file or a Helm chart.

func GetClusterImageSource

func GetClusterImageSource(path string) (ClusterImageSource, error)

GetClusterImageSource returns appropriate cluster image source for the path.

The path is expected to be one of the following: * Cluster image manifest file. * Directory with cluster imge manifest file (app.yaml). * Helm chart directory.

type ClusterRequest

type ClusterRequest struct {
	// SourcePath specifies the path to build the cluster image out of.
	SourcePath string
	// OutputPath is the resulting cluster image output file path.
	OutputPath string
	// Overwrite is whether to overwrite existing output file.
	Overwrite bool
	// Vendor combines vendoring parameters.
	Vendor service.VendorRequest
	// BaseImage is optional base image provided on the command line.
	BaseImage string
}

ClusterRequest combines parameters for building a cluster image.

type Config

type Config struct {
	// StateDir is the configured builder state directory
	StateDir string
	// Insecure disables client verification of the server TLS certificate chain
	Insecure bool
	// Repository represents the source package repository
	Repository string
	// SkipVersionCheck allows to skip tele/runtime compatibility check
	SkipVersionCheck bool
	// Parallel is the builder's parallelism level
	Parallel int
	// Generator is used to generate installer
	Generator Generator
	// NewSyncer is used to initialize package cache syncer for the builder
	NewSyncer NewSyncerFunc
	// GetRepository is a function that returns package source repository
	GetRepository GetRepositoryFunc
	// CredentialsService provides access to user credentials
	CredentialsService credentials.Service
	// Credentials is the credentials set on the CLI
	Credentials *credentials.Credentials
	// Level is the level at which the progress should be reported
	Level utils.ProgressLevel
	// Progress allows builder to report build progress
	utils.Progress
}

Config is the builder configuration

func (*Config) CheckAndSetDefaults

func (c *Config) CheckAndSetDefaults() error

CheckAndSetDefaults validates builder config and fills in defaults

type Engine

type Engine struct {
	// Config is the builder Engine configuration.
	Config
	// Env is the local build environment.
	Env *localenv.LocalEnvironment
	// Dir is the directory where build-related data is stored.
	Dir string
	// Backend is the local backend.
	Backend storage.Backend
	// Packages is the layered package service with the local cache
	// directory serving as a 'read' layer and the temporary directory
	// as a 'read-write' layer.
	Packages pack.PackageService
	// Apps is the application service based on the layered package service.
	Apps app.Applications
}

Engine is the builder engine that provides common functionality for building cluster and application images.

func (*Engine) Close

func (b *Engine) Close() error

Close cleans up build environment

func (*Engine) CreateApplication

func (b *Engine) CreateApplication(data io.ReadCloser) (*app.Application, error)

CreateApplication creates a Gravity application from the provided data in the local database

func (*Engine) GenerateInstaller

func (b *Engine) GenerateInstaller(manifest *schema.Manifest, application app.Application) (io.ReadCloser, error)

GenerateInstaller generates an installer tarball for the specified application and returns its data as a stream

func (*Engine) SelectRuntime

func (b *Engine) SelectRuntime(manifest *schema.Manifest) (*semver.Version, error)

SelectRuntime picks an appropriate base image version for the cluster image that's being built

func (*Engine) SyncPackageCache

func (b *Engine) SyncPackageCache(manifest *schema.Manifest, runtimeVersion *semver.Version) error

SyncPackageCache ensures that all system dependencies are present in the local cache directory

func (*Engine) Vendor

func (b *Engine) Vendor(ctx context.Context, req VendorRequest) (io.ReadCloser, error)

Vendor vendors the application images in the provided directory and returns the compressed data stream with the application data

func (*Engine) WriteInstaller

func (b *Engine) WriteInstaller(data io.ReadCloser, outPath string) error

WriteInstaller writes the provided installer tarball data to disk

type Generator

type Generator interface {
	// Generate generates an installer tarball for the specified application
	// using the provided builder and returns its data as a stream
	Generate(*Engine, *schema.Manifest, app.Application) (io.ReadCloser, error)
}

Generator defines a method for generating standalone installers

type GetRepositoryFunc

type GetRepositoryFunc func(*Engine) (string, error)

GetRepositoryFunc defines function that returns package source repository

type NewSyncerFunc

type NewSyncerFunc func(*Engine) (Syncer, error)

NewSyncerFunc defines function that creates syncer for a builder

type PackSyncer

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

PackSyncer synchronizes local package cache with pack/apps services

func NewPackSyncer

func NewPackSyncer(pack pack.PackageService, apps app.Applications, repo string) *PackSyncer

NewPackSyncer creates a new syncer from provided pack and apps services

func (*PackSyncer) Sync

func (s *PackSyncer) Sync(engine *Engine, manifest *schema.Manifest, runtimeVersion *semver.Version) error

Sync pulls dependencies from the package/app service not available locally

type Syncer

type Syncer interface {
	// Sync makes sure that local cache has all required dependencies for the
	// selected runtime
	Sync(*Engine, *schema.Manifest, *semver.Version) error
}

Syncer synchronizes the local package cache from a (remote) repository

func NewSyncer

func NewSyncer(b *Engine) (Syncer, error)

NewSyncer returns a new syncer instance for the provided builder

Satisfies NewSyncerFunc type.

type VendorRequest

type VendorRequest struct {
	// SourceDir is the cluster or application image source directory.
	SourceDir string
	// VendorDir is the directory to perform vendoring in.
	VendorDir string
	// Manifest is the image manifest.
	Manifest *schema.Manifest
	// Vendor is parameters of the vendorer.
	Vendor service.VendorRequest
}

VendorRequest combines vendoring parameters.

Jump to

Keyboard shortcuts

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