zeaburpack

package
v0.0.0-...-d97b457 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 49 Imported by: 0

Documentation

Overview

Package zeaburpack is the library of zbpack.

Index

Constants

This section is empty.

Variables

View Source
var ServerlessTarPath = filepath.Join(
	lo.Must(os.MkdirTemp("", "zbpack-buildkit-artifact-*")),
	"serverless-output.tar",
)

ServerlessTarPath is the path to the serverless output tar file

Functions

func Build

func Build(opt *BuildOptions) error

Build will analyze the project, determine the plan and build the image.

func NewHandledWriter

func NewHandledWriter(w console.File, handler *func(log string)) console.File

NewHandledWriter creates a new HandledWriter.

func Plan

Plan returns the build plan and metadata.

func PlanAndOutputDockerfile

func PlanAndOutputDockerfile(opt PlanOptions) error

PlanAndOutputDockerfile output dockerfile.

func PrintPlanAndMeta

func PrintPlanAndMeta(plan types.PlanType, meta types.PlanMeta, printFunc func(log string))

PrintPlanAndMeta prints the build plan and meta in a table format.

func SupportedIdentifiers

func SupportedIdentifiers() []plan.Identifier

SupportedIdentifiers returns all supported identifiers note that they are in the order of priority

func SupportedPackers

func SupportedPackers() []packer.Packer

SupportedPackers returns all supported identifiers

func UpdateOptionsOnConfig

func UpdateOptionsOnConfig[T ZbpackOptions](options T, config plan.ImmutableProjectConfiguration)

UpdateOptionsOnConfig updates the undefined options (nil) with the value from project configuration.

Types

type BuildOptions

type BuildOptions struct {
	// SubmoduleName is the of the submodule to build.
	// For example, if directory is considered as a Go project,
	// submoduleName would be used to try file in `cmd` directory.
	// in Zeabur internal system, this is the name of the service.
	SubmoduleName *string

	// HandlePlanDetermined is a callback function that will be called when
	// the build plan is determined.
	HandlePlanDetermined *func(types.PlanType, types.PlanMeta)

	// HandleBuildFailed is a callback function that will be called when
	// the build failed.
	HandleBuildFailed *func(error)

	// HandleLog is a function that will be called when a log is emitted.
	HandleLog *func(string)

	// Path is the path to the project directory.
	Path *string

	// ResultImage is the name of the image that will be built.
	ResultImage *string

	// UserVars is a map of user variables that will be used in the Dockerfile.
	UserVars *map[string]string

	// Interactive is a flag to indicate if the build should be interactive.
	Interactive *bool

	// CustomBuildCommand is a custom build command that will be used instead of the default one.
	CustomBuildCommand *string

	// CustomStartCommand is a custom start command that will be used instead of the default one.
	CustomStartCommand *string

	// OutputDir is the directory where the build artifacts will be stored.
	// Once provided, the service will deploy as static files with nginx.
	OutputDir *string

	CacheFrom *string
	CacheTo   *string

	// ProxyRegistry is the registry to be used for the image.
	// See referenceConstructor for more details.
	ProxyRegistry *string

	// PushImage is a flag to indicate if the image should be pushed to the registry.
	PushImage bool
}

BuildOptions is the options for the Build function.

type FromStatement

type FromStatement struct {
	Source string
	Stage  mo.Option[string]
}

FromStatement represents a FROM statement in a Dockerfile.

func ParseFrom

func ParseFrom(line string) (FromStatement, bool)

ParseFrom parses a FROM statement from a Dockerfile line.

func (FromStatement) String

func (fs FromStatement) String() string

type HandledWriter

type HandledWriter struct {
	console.File
	// contains filtered or unexported fields
}

HandledWriter is a console-compatible writer that copies the output to the specified log and calls handler with the log.

func (HandledWriter) Write

func (h HandledWriter) Write(p []byte) (n int, err error)

type PlanOptions

type PlanOptions struct {
	// SubmoduleName is the of the submodule to build.
	// For example, if a directory is considered as a Go project,
	// submoduleName would be used to try file in `cmd` directory.
	// in Zeabur internal system, this is the name of the service.
	SubmoduleName *string

	// Path is the path to the project directory.
	Path *string

	// Access token for GitHub, only used when Path is a GitHub URL.
	AccessToken *string

	// CustomBuildCommand is a custom build command that will be used instead of the default one.
	CustomBuildCommand *string

	// CustomStartCommand is a custom start command that will be used instead of the default one.
	CustomStartCommand *string

	// OutputDir is the directory where the build artifacts will be stored.
	// Once provided, the service will deploy as static files with nginx.
	OutputDir *string
}

PlanOptions is the options for Plan function.

type ZbpackOptions

type ZbpackOptions interface {
	*PlanOptions | *BuildOptions
}

ZbpackOptions is the union type of the pointer to PlanOptions and BuildOptions.

Jump to

Keyboard shortcuts

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