build

package
v3.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseImageSourceTypeRepo      = "repo"
	BaseImageSourceTypeSecondary = "secondary"
)

Variables

This section is empty.

Functions

func GenerateImageEnv

func GenerateImageEnv(werfImageName, imageName string) string

Types

type BasePhase

type BasePhase struct {
	Conveyor *Conveyor
}

func (*BasePhase) AfterImageStages

func (phase *BasePhase) AfterImageStages(ctx context.Context, img *image.Image) error

func (*BasePhase) AfterImages

func (phase *BasePhase) AfterImages(_ context.Context) error

func (*BasePhase) BeforeImageStages

func (phase *BasePhase) BeforeImageStages(ctx context.Context, img *image.Image) (deferFn func(), err error)

func (*BasePhase) BeforeImages

func (phase *BasePhase) BeforeImages(_ context.Context) error

func (*BasePhase) ImageProcessingShouldBeStopped

func (phase *BasePhase) ImageProcessingShouldBeStopped(_ context.Context, _ *image.Image) bool

func (*BasePhase) OnImageStage

func (phase *BasePhase) OnImageStage(_ context.Context, _ *image.Image, _ stage.Interface) error

type BuildOptions

type BuildOptions struct {
	ImageBuildOptions container_backend.BuildOptions
	IntrospectOptions

	ReportPath       string
	ReportFormat     ReportFormat
	ReportOperations bool

	SkipImageMetadataPublication bool
	SkipAddManagedImagesRecords  bool
	CustomTagFuncList            []imagePkg.CustomTagFunc
}

type BuildPhase

type BuildPhase struct {
	BasePhase
	BuildPhaseOptions

	StagesIterator *StagesIterator
	ImagesReport   *ImagesReport
	// contains filtered or unexported fields
}

func NewBuildPhase

func NewBuildPhase(c *Conveyor, opts BuildPhaseOptions) *BuildPhase

func (*BuildPhase) AfterImageStages

func (phase *BuildPhase) AfterImageStages(ctx context.Context, img *image.Image) error

func (*BuildPhase) AfterImages

func (phase *BuildPhase) AfterImages(ctx context.Context) error

func (*BuildPhase) BeforeImageStages

func (phase *BuildPhase) BeforeImageStages(ctx context.Context, img *image.Image) (deferFn func(), err error)

func (*BuildPhase) BeforeImages

func (phase *BuildPhase) BeforeImages(ctx context.Context) error

func (*BuildPhase) Clone

func (phase *BuildPhase) Clone() Phase

func (*BuildPhase) ImageProcessingShouldBeStopped

func (phase *BuildPhase) ImageProcessingShouldBeStopped(_ context.Context, _ *image.Image) bool

func (*BuildPhase) Name

func (phase *BuildPhase) Name() string

func (*BuildPhase) OnImageStage

func (phase *BuildPhase) OnImageStage(ctx context.Context, img *image.Image, stg stage.Interface) error

func (*BuildPhase) Report

func (phase *BuildPhase) Report() *ImagesReport

type BuildPhaseOptions

type BuildPhaseOptions struct {
	BuildOptions
	ShouldBeBuiltMode bool
}

type Conveyor

type Conveyor struct {
	ContainerBackend container_backend.ContainerBackend

	StorageLockManager lock_manager.Interface
	StorageManager     manager.StorageManagerInterface

	ConveyorOptions
	// contains filtered or unexported fields
}

func NewConveyor

func NewConveyor(werfConfig *config.WerfConfig, giterminismManager giterminism_manager.Interface, projectDir, baseTmpDir string, containerBackend container_backend.ContainerBackend, storageManager manager.StorageManagerInterface, storageLockManager lock_manager.Interface, opts ConveyorOptions) *Conveyor

func (*Conveyor) AppendOnTerminateFunc

func (c *Conveyor) AppendOnTerminateFunc(f ConveyorCleanupFunc)

func (*Conveyor) Build

func (c *Conveyor) Build(ctx context.Context, opts BuildOptions) ([]*ImagesReport, error)

func (*Conveyor) Export

func (c *Conveyor) Export(ctx context.Context, opts ExportOptions) error

func (*Conveyor) ExportFromReport

func (c *Conveyor) ExportFromReport(ctx context.Context, opts ExportOptions) error

func (*Conveyor) FetchLastImageStage

func (c *Conveyor) FetchLastImageStage(ctx context.Context, targetPlatform, imageName string) error

func (*Conveyor) FindImage

func (c *Conveyor) FindImage(targetPlatform, name string) (*image.Image, error)

func (*Conveyor) GetBaseImagesRepoErrCache

func (c *Conveyor) GetBaseImagesRepoErrCache(key string) error

func (*Conveyor) GetBaseImagesRepoIdsCache

func (c *Conveyor) GetBaseImagesRepoIdsCache(key string) string

func (*Conveyor) GetExportedImages

func (c *Conveyor) GetExportedImages() (res []*image.Image)

func (*Conveyor) GetForcedTargetPlatforms

func (c *Conveyor) GetForcedTargetPlatforms() []string

func (*Conveyor) GetFullImageName

func (c *Conveyor) GetFullImageName(imageName string) (string, error)

func (*Conveyor) GetFullImageNameFromReport

func (c *Conveyor) GetFullImageNameFromReport(ctx context.Context, imageName string) (string, error)

func (*Conveyor) GetImage

func (c *Conveyor) GetImage(targetPlatform, name string) *image.Image

func (*Conveyor) GetImageContentTagDigest

func (c *Conveyor) GetImageContentTagDigest(targetPlatform, imageName string) string

func (*Conveyor) GetImageContentTagName

func (c *Conveyor) GetImageContentTagName(targetPlatform, imageName string) string

func (*Conveyor) GetImageContentTagStageID

func (c *Conveyor) GetImageContentTagStageID(targetPlatform, imageName string) string

func (*Conveyor) GetImageInfoGetters

func (c *Conveyor) GetImageInfoGetters(opts imagePkg.InfoGetterOptions) ([]*imagePkg.InfoGetter, error)

func (*Conveyor) GetImageInfoGettersFromReport

func (c *Conveyor) GetImageInfoGettersFromReport(ctx context.Context, opts imagePkg.InfoGetterOptions) ([]*imagePkg.InfoGetter, error)

func (*Conveyor) GetImageInfoGettersWithOpts

func (c *Conveyor) GetImageInfoGettersWithOpts(opts imagePkg.InfoGetterOptions) ([]*imagePkg.InfoGetter, error)

func (*Conveyor) GetImageNameForLastImageStageFromReport

func (c *Conveyor) GetImageNameForLastImageStageFromReport(image ReportImageRecord) string

func (*Conveyor) GetImageTargetPlatforms

func (c *Conveyor) GetImageTargetPlatforms(targetImageName string) ([]string, error)

func (*Conveyor) GetImagesEnvArray

func (c *Conveyor) GetImagesEnvArray() []string

func (*Conveyor) GetImagesEnvArrayFromReport

func (c *Conveyor) GetImagesEnvArrayFromReport(ctx context.Context) ([]string, error)

func (*Conveyor) GetImportServer

func (c *Conveyor) GetImportServer(ctx context.Context, targetPlatform, imageName string, fromExternalImage bool) (import_server.ImportServer, error)

func (*Conveyor) GetOrCreateStageImage

func (c *Conveyor) GetOrCreateStageImage(name string, prevStageImage *stage.StageImage, stg stage.Interface, img *image.Image) *stage.StageImage

func (*Conveyor) GetRemoteGitRepo

func (c *Conveyor) GetRemoteGitRepo(key string) *git_repo.Remote

func (*Conveyor) GetServiceRWMutex

func (c *Conveyor) GetServiceRWMutex(service string) *sync.RWMutex

func (*Conveyor) GetStageDigestMutex

func (c *Conveyor) GetStageDigestMutex(stage string) *sync.Mutex

func (*Conveyor) GetStageImageByPlatform

func (c *Conveyor) GetStageImageByPlatform(name, targetPlatform string) *stage.StageImage

func (*Conveyor) GetTargetPlatforms

func (c *Conveyor) GetTargetPlatforms() ([]string, error)

func (*Conveyor) GiterminismManager

func (c *Conveyor) GiterminismManager() giterminism_manager.Interface

func (*Conveyor) IsBaseImagesRepoErrCacheExist

func (c *Conveyor) IsBaseImagesRepoErrCacheExist(key string) bool

func (*Conveyor) IsBaseImagesRepoIdsCacheExist

func (c *Conveyor) IsBaseImagesRepoIdsCacheExist(key string) bool

func (*Conveyor) ProjectName

func (c *Conveyor) ProjectName() string

func (*Conveyor) ResolveTargetPlatforms

func (c *Conveyor) ResolveTargetPlatforms(imageName string) ([]string, error)

func (*Conveyor) SetBaseImagesRepoErrCache

func (c *Conveyor) SetBaseImagesRepoErrCache(key string, err error)

func (*Conveyor) SetBaseImagesRepoIdsCache

func (c *Conveyor) SetBaseImagesRepoIdsCache(key, value string)

func (*Conveyor) SetRemoteGitRepo

func (c *Conveyor) SetRemoteGitRepo(key string, repo *git_repo.Remote)

func (*Conveyor) SetShouldAddManagedImagesRecords

func (c *Conveyor) SetShouldAddManagedImagesRecords()

func (*Conveyor) SetStageImage

func (c *Conveyor) SetStageImage(stageImage *stage.StageImage)

func (*Conveyor) ShouldAddManagedImagesRecords

func (c *Conveyor) ShouldAddManagedImagesRecords() bool

func (*Conveyor) ShouldBeBuilt

func (c *Conveyor) ShouldBeBuilt(ctx context.Context, opts ShouldBeBuiltOptions) ([]*ImagesReport, error)

func (*Conveyor) Terminate

func (c *Conveyor) Terminate(ctx context.Context) error

func (*Conveyor) UnsetStageImage

func (c *Conveyor) UnsetStageImage(name string)

func (*Conveyor) UnsetStageImageByPlatform

func (c *Conveyor) UnsetStageImageByPlatform(name, targetPlatform string)

func (*Conveyor) UseLegacyStapelBuilder

func (c *Conveyor) UseLegacyStapelBuilder(cr container_backend.ContainerBackend) bool

type ConveyorCleanupFunc

type ConveyorCleanupFunc func(context.Context) error

type ConveyorOptions

type ConveyorOptions struct {
	Parallel           bool
	ParallelTasksLimit int64
	TargetPlatforms    []string
	DeferBuildLog      bool
	ImagesToProcess    config.ImagesToProcess
	UseBuildReport     bool
	BuildReportPath    string
}

type ConveyorWithRetryWrapper

type ConveyorWithRetryWrapper struct {
	WerfConfig         *config.WerfConfig
	GiterminismManager giterminism_manager.Interface
	ProjectDir         string
	BaseTmpDir         string
	ContainerBackend   container_backend.ContainerBackend
	StorageManager     *manager.StorageManager
	StorageLockManager lock_manager.Interface

	ConveyorOptions ConveyorOptions
}

func NewConveyorWithRetryWrapper

func NewConveyorWithRetryWrapper(werfConfig *config.WerfConfig, giterminismManager giterminism_manager.Interface, projectDir, baseTmpDir string, containerBackend container_backend.ContainerBackend, storageManager *manager.StorageManager, storageLockManager lock_manager.Interface, opts ConveyorOptions) *ConveyorWithRetryWrapper

func (*ConveyorWithRetryWrapper) Terminate

func (wrapper *ConveyorWithRetryWrapper) Terminate() error

func (*ConveyorWithRetryWrapper) WithRetryBlock

func (wrapper *ConveyorWithRetryWrapper) WithRetryBlock(ctx context.Context, f func(c *Conveyor) error) error

type ExportOptions

type ExportOptions struct {
	ExportImageNameList []string
	ExportTagFuncList   []image.ExportTagFunc
	MutateConfigFunc    func(config v1.Config) (v1.Config, error)
}

type Exporter

type Exporter struct {
	ExportOptions
	Conveyor *Conveyor
}

func NewExporter

func NewExporter(c *Conveyor, opts ExportOptions) *Exporter

func (*Exporter) Run

func (e *Exporter) Run(ctx context.Context) error

func (*Exporter) RunFromReport

func (e *Exporter) RunFromReport(ctx context.Context, reportPath string) error

type ImagesReport

type ImagesReport struct {
	Runtime          RuntimeInfo `json:"Runtime"`
	Images           map[string]ReportImageRecord
	ImagesByPlatform map[string]map[string]ReportImageRecord
	Operations       map[string]ReportOperationRecord                 `json:"Operations,omitempty"`
	CacheOperations  map[string]map[string]ReportCacheOperationRecord `json:"CacheOperations,omitempty"`
	StageCache       map[string]int                                   `json:"StageCache,omitempty"`
	RegistryCache    map[string]int                                   `json:"RegistryCache,omitempty"`
	Recovery         map[string]int                                   `json:"Recovery,omitempty"`
	// contains filtered or unexported fields
}

func LoadBuildReportFromFile

func LoadBuildReportFromFile(ctx context.Context, path string) (*ImagesReport, error)

func NewImagesReport

func NewImagesReport() *ImagesReport

func (*ImagesReport) SetCacheOperationsSummary added in v3.7.0

func (report *ImagesReport) SetCacheOperationsSummary(ctx context.Context, cache []opstats.CacheSummary)

SetCacheOperationsSummary fills the CacheOperations section from the cache counters of the collector, keyed by operation and then by the caching layer the lookup went through. It is additive to SetOperationsSummary: the legacy StageCache/RegistryCache event sections keep their existing meaning.

func (*ImagesReport) SetImageByPlatformRecord

func (report *ImagesReport) SetImageByPlatformRecord(targetPlatform, name string, imageRecord ReportImageRecord)

func (*ImagesReport) SetImageRecord

func (report *ImagesReport) SetImageRecord(name string, imageRecord ReportImageRecord)

func (*ImagesReport) SetOperationsSummary

func (report *ImagesReport) SetOperationsSummary(ctx context.Context, operations []opstats.OperationSummary, events []opstats.EventSummary)

func (*ImagesReport) ToEnvFileData

func (report *ImagesReport) ToEnvFileData() []byte

func (*ImagesReport) ToImageInfoGetters

func (report *ImagesReport) ToImageInfoGetters(opts imagePkg.InfoGetterOptions) []*imagePkg.InfoGetter

func (*ImagesReport) ToJsonData

func (report *ImagesReport) ToJsonData() ([]byte, error)

type IntrospectOptions

type IntrospectOptions struct {
	Targets []IntrospectTarget
}

func (*IntrospectOptions) ImageStageShouldBeIntrospected

func (opts *IntrospectOptions) ImageStageShouldBeIntrospected(imageName, stageName string) bool

type IntrospectTarget

type IntrospectTarget struct {
	ImageName string
	StageName string
}

type Phase

type Phase interface {
	Name() string
	BeforeImages(ctx context.Context) error
	AfterImages(ctx context.Context) error
	BeforeImageStages(ctx context.Context, img *image.Image) (deferFn func(), err error)
	OnImageStage(ctx context.Context, img *image.Image, stg stage.Interface) error
	AfterImageStages(ctx context.Context, img *image.Image) error
	ImageProcessingShouldBeStopped(ctx context.Context, img *image.Image) bool
	Clone() Phase
	Report() *ImagesReport
}

type ReportCacheOperationRecord added in v3.7.0

type ReportCacheOperationRecord struct {
	Lookups int
	Hit     int
	Miss    int
	Bypass  int
	Shared  int
}

ReportCacheOperationRecord counts the completed calls through one caching layer of one operation. Lookups is the sum of the three outcomes; the hit rate is derivable from Hit and Miss and is therefore not serialized.

type ReportFormat

type ReportFormat string
const (
	ReportJSON    ReportFormat = "json"
	ReportEnvFile ReportFormat = "envfile"
)

type ReportImageRecord

type ReportImageRecord struct {
	WerfImageName     string
	ConfigType        string
	DockerRepo        string
	DockerTag         string
	DockerImageID     string
	DockerImageDigest string
	DockerImageName   string
	TargetPlatform    string
	Rebuilt           bool
	Final             bool
	Size              int64
	BuildTime         string
	Commit            string
	Stages            []ReportStageRecord `json:"Stages,omitempty"`
	StagesSkipped     bool                `json:"StagesSkipped,omitempty"`
}

type ReportOperationRecord

type ReportOperationRecord struct {
	Count            int
	TotalTimeSeconds float64
	WallTimeSeconds  float64
	AvgTimeSeconds   float64
	MaxTimeSeconds   float64
}

type ReportStageRecord

type ReportStageRecord struct {
	Name              string
	DockerImageName   string
	DockerTag         string
	DockerImageID     string
	DockerImageDigest string
	CreatedAt         int64
	Size              int64
	SourceType        string
	BaseImagePulled   bool
	Rebuilt           bool
	BuildTime         string
	Commit            string
}

type RuntimeInfo

type RuntimeInfo struct {
	WerfVersion string `json:"WerfVersion"`
	Backend     string `json:"Backend"`
	InContainer bool   `json:"InContainer"`
}

type ShouldBeBuiltOptions

type ShouldBeBuiltOptions struct {
	SkipImageMetadataPublication bool
	SkipAddManagedImagesRecords  bool
	CustomTagFuncList            []imagePkg.CustomTagFunc
	ReportPath                   string
	ReportFormat                 ReportFormat
	ReportOperations             bool
}

type StagesIterator

type StagesIterator struct {
	Conveyor *Conveyor

	PrevStage                  stage.Interface
	PrevNonEmptyStage          stage.Interface
	PrevBuiltStage             stage.Interface
	PrevNonEmptyStageImageSize int64
}

func NewStagesIterator

func NewStagesIterator(conveyor *Conveyor) *StagesIterator

func (*StagesIterator) GetPrevBuiltImage

func (iterator *StagesIterator) GetPrevBuiltImage(img *build_image.Image, stg stage.Interface) *stage.StageImage

func (*StagesIterator) GetPrevImage

func (iterator *StagesIterator) GetPrevImage(img *build_image.Image, stg stage.Interface) *stage.StageImage

func (*StagesIterator) OnImageStage

func (iterator *StagesIterator) OnImageStage(ctx context.Context, img *build_image.Image, stg stage.Interface, onImageStageFunc func(img *build_image.Image, stg stage.Interface, isEmpty bool) error) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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