container

package
v0.37.2 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: Apache-2.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeChecksum

func ComputeChecksum(data []byte) string

ComputeChecksum computes SHA256 checksum with memory optimizations Uses streaming approach and buffer pooling for better performance

func GetEnv

func GetEnv(key string) string

func Getenv

func Getenv(key string) string

func ParseImageTag

func ParseImageTag(imageTag string) (string, string)

func SumChecksum added in v0.5.1

func SumChecksum(sums ...[]byte) string

SumChecksum combines multiple checksums with memory optimization

func TarDir added in v0.5.1

func TarDir(src fs.ReadDirFS) (*bytes.Buffer, error)

TarDir creates a tar archive from a filesystem with memory optimizations and concurrent processing

func TarDirConcurrent added in v0.18.0

func TarDirConcurrent(src fs.ReadDirFS, fileCount int, totalSize int64) (*bytes.Buffer, error)

TarDirConcurrent creates a tar archive using concurrent processing for better performance

func TarDirSequential added in v0.18.0

func TarDirSequential(src fs.ReadDirFS) (*bytes.Buffer, error)

TarDirSequential creates a tar archive using sequential processing (original implementation)

Types

type Build

type Build struct {
	Leader             Leader
	Platform           types.Platform
	Custom             Custom
	Registries         map[string]*protos2.ContainerRegistry
	ContainerFiles     map[string]*protos2.ContainerFile
	Secret             map[string]string
	ContainifyRegistry string
	Runtime            utils.RuntimeType
	RuntimeClient      func() cri.ContainerManager `json:"-"`
	Image              string                      `json:"image"`
	ImageTag           string                      `json:"image_tag"`
	File               string
	Env                EnvType
	Folder             string
	Repository         string
	Organization       string
	App                string    `json:"app"`
	BuildType          BuildType `json:"build_type"`
	BuilderFunction    string
	Registry           string
	SourcePackages     []string
	SourceFiles        []string
	Verbose            bool
	// contains filtered or unexported fields
}

TODO: add target container platform Build struct optimized for memory alignment and cache performance

func NewBuild

func NewBuild(build *Build) *Build

func NewGoServiceBuild

func NewGoServiceBuild(appName string) Build

func NewMavenServiceBuild

func NewMavenServiceBuild(appName string) Build

func NewPythonServiceBuild

func NewPythonServiceBuild(appName string) Build

func NewServiceBuild

func NewServiceBuild(appName string, buildType BuildType) Build

func (*Build) AsFlags

func (b *Build) AsFlags() []string

AsFlags converts build configuration to command-line flags with memory optimization

func (*Build) CustomString added in v0.4.0

func (b *Build) CustomString(key string) string

func (*Build) Defaults

func (b *Build) Defaults() *Build

func (*Build) ImageURI

func (b *Build) ImageURI() string

ImageURI constructs the full image URI with optimized performance

func (*Build) VarName added in v0.30.0

func (b *Build) VarName() string

type BuildGroup added in v0.11.0

type BuildGroup struct {
	Builds []*Build
}

type BuildGroups added in v0.11.0

type BuildGroups []*BuildGroup

type BuildLoop added in v0.37.0

type BuildLoop string
const (
	BuildStop     BuildLoop = "stop"
	BuildContinue BuildLoop = "continue"
)

type BuildType

type BuildType string
const (
	GoLang     BuildType = "GoLang"
	Maven      BuildType = "Maven"
	Python     BuildType = "Python"
	NodeJS     BuildType = "NodeJS"
	Typescript BuildType = "Typescript"
	Zig        BuildType = "Zig"
	Rust       BuildType = "Rust"
	AI         BuildType = "AI"

	Generic BuildType = "Generic"
)

func (*BuildType) Set

func (e *BuildType) Set(v string) error

Set must have pointer receiver so it doesn't change the value of a copy

func (*BuildType) String

func (e *BuildType) String() string

String is used both by fmt.Print and by Cobra in help text

func (*BuildType) Type

func (e *BuildType) Type() string

Type is only used in help text

type Container

type Container struct {
	Source  fs.ReadDirFS
	Build   *Build
	Secret  map[string]string
	Env     EnvType
	Prefix  string
	Image   string
	Name    string
	ID      string
	Opts    types.ContainerConfig
	Verbose bool
	// contains filtered or unexported fields
}

func New

func New(build Build) *Container

func NewWithManager added in v0.36.0

func NewWithManager(manager cri.ContainerManager) *Container

func (*Container) Apply

func (c *Container) Apply(opts *types.ContainerConfig)

func (*Container) BuildImage

func (c *Container) BuildImage(dockerfile []byte, imageName string) error

func (*Container) BuildImageByPlatform

func (c *Container) BuildImageByPlatform(dockerfile []byte, imageName string, platform string) error

func (*Container) BuildImageByPlatforms

func (c *Container) BuildImageByPlatforms(dockerfile []byte, dockerCtx *bytes.Buffer, imageName string, platforms []string) ([]string, error)

func (*Container) BuildIntermidiateContainer

func (c *Container) BuildIntermidiateContainer(image string, dockerFile []byte, platforms ...string) error

func (*Container) BuildingContainer

func (c *Container) BuildingContainer(opts types.ContainerConfig) error

func (*Container) Commit

func (c *Container) Commit(imageTag string, comment string, changes ...string) (string, error)

func (*Container) CopyContentTo

func (c *Container) CopyContentTo(content, dest string) error

func (*Container) CopyDirectoryTo

func (c *Container) CopyDirectoryTo(srcPath, dstPath string) error

TODO: ignore hidden folder and files maybe support .dockerignore file or more .dockerinclude file to include folder and files that are ignored by default

func (*Container) CopyFileFromContainer

func (c *Container) CopyFileFromContainer(srcPath string) (string, error)

CopyFileFromContainer reads a single file from a container and returns its content as a string.

func (*Container) CopyFileTo

func (c *Container) CopyFileTo(srcPath, destPath string) error

func (*Container) Create

func (c *Container) Create(opts types.ContainerConfig) error

func (*Container) Exec

func (c *Container) Exec(cmd ...string) error

func (*Container) GetBuild added in v0.11.0

func (c *Container) GetBuild() *Build

func (*Container) ImageExists

func (c *Container) ImageExists(imageName string, platforms ...string) (bool, error)

imageExists checks if the image with the specified tag exists.

func (*Container) Inspect

func (c *Container) Inspect() (*types.ContainerConfig, error)

func (*Container) InspectImage

func (c *Container) InspectImage(image string) (*types.ImageInfo, error)

func (*Container) Pull

func (c *Container) Pull(imageTags ...string) error

func (*Container) PullByPlatform

func (c *Container) PullByPlatform(platform string, imageTags ...string) error

func (*Container) PullDefault

func (c *Container) PullDefault(imageTags ...string) error

func (*Container) Push

func (c *Container) Push(source, target string, opts ...PushOption) error

TODO: find a better way to provide optional parameters like PushOption

func (*Container) Ready

func (c *Container) Ready() error

func (*Container) Start

func (c *Container) Start() error

func (*Container) Stop

func (c *Container) Stop() error

func (*Container) Tag

func (c *Container) Tag(source, target string) error

func (*Container) Wait

func (c *Container) Wait() error

type Custom added in v0.10.0

type Custom map[string][]string

func (Custom) Bool added in v0.10.0

func (c Custom) Bool(key string, value bool) bool

func (Custom) Int added in v0.37.0

func (c Custom) Int(key string) int

func (Custom) String added in v0.10.0

func (c Custom) String(key string) string

func (Custom) Strings added in v0.10.0

func (c Custom) Strings(key string) []string

func (Custom) UInt added in v0.10.0

func (c Custom) UInt(key string) uint

type EnvType

type EnvType string
const (
	LocalEnv EnvType = "local"
	BuildEnv EnvType = "build"
	ProdEnv  EnvType = "production"
)

func (*EnvType) Set

func (e *EnvType) Set(v string) error

Set must have pointer receiver so it doesn't change the value of a copy

func (*EnvType) String

func (e *EnvType) String() string

String is used both by fmt.Print and by Cobra in help text

func (*EnvType) Type

func (e *EnvType) Type() string

Type is only used in help text

type Leader added in v0.11.0

type Leader interface {
	Leader(id string, fnc func() error)
}

type PushOption

type PushOption struct {
	Remove bool
}

Jump to

Keyboard shortcuts

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