Documentation
¶
Index ¶
- Constants
- func BuildImage(ctx context.Context, cli dockerclient.DockerClient, ...) (string, error)
- func BuilderCacheDir() (string, error)
- func BuilderReposCacheDir() (string, error)
- func BuilderURLToPath(url string) (string, error)
- func BuilderWorktreesDir() (string, error)
- func CacheDir() (string, error)
- func CleanCache() error
- func CloneOrUpdate(ctx context.Context, url, ref string, auth transport.AuthMethod, ...) (string, error)
- func CreateTarFromDir(dir string) (io.ReadCloser, error)
- func EnsureBuilderReposCacheDir() error
- func EnsureCacheDir() error
- func EnsureReposCacheDir() error
- func GenerateImageTag(stack, server, pin, buildDigest string) string
- func GeneratePythonDockerfile(ctx context.Context, spec PythonBuildSpec) (string, error)
- func ReposCacheDir() (string, error)
- func ResolveConsoleCommand(explicit []string, projectName string, scripts []string) ([]string, error)
- func SelectPythonVersion(requiresPython, explicit string) (string, error)
- func URLToPath(url string) (string, error)
- type BuildOptions
- type BuildProvenance
- type BuildResult
- type Builder
- func (b *Builder) Build(ctx context.Context, opts BuildOptions) (*BuildResult, error)
- func (b *Builder) Plan(ctx context.Context, opts BuildOptions) (*ResolvedBuildPlan, error)
- func (b *Builder) Resolve(ctx context.Context, opts BuildOptions) (*ResolvedBuildPlan, error)
- func (b *Builder) Versions(ctx context.Context, project string) (*PyPIVersions, error)
- type PyPIArtifact
- type PyPIRelease
- type PyPIResolver
- type PyPIVersions
- type PythonBuildSpec
- type PythonPackageMetadata
- type PythonProjectMetadata
- type PythonTemplateConfig
- type ResolvedBuildPlan
- type SourceIdentity
Constants ¶
const ( LabelBuildInputDigest = "io.gridctl.build-input-digest" LabelGeneratorVersion = "io.gridctl.generator-version" LabelSourceDigest = "io.gridctl.source-digest" LabelBaseImage = "io.gridctl.base-image" LabelUVImage = "io.gridctl.uv-image" LabelSourcePackage = "io.gridctl.source-package" LabelSourceVersion = "io.gridctl.source-version" LabelSourceArtifact = "io.gridctl.source-artifact" )
const PythonTemplateVersion = "python-uv-v1"
Variables ¶
This section is empty.
Functions ¶
func BuildImage ¶
func BuildImage(ctx context.Context, cli dockerclient.DockerClient, contextPath, dockerfile, tag string, buildArgs map[string]string, noCache bool, logger *slog.Logger) (string, error)
BuildImage builds a Docker image from a context directory.
func BuilderCacheDir ¶
BuilderCacheDir returns the cache namespace reserved for source image builds.
func BuilderReposCacheDir ¶
BuilderReposCacheDir returns the builder-only repository cache directory.
func BuilderURLToPath ¶
BuilderURLToPath converts a git URL to a builder repository cache path.
func BuilderWorktreesDir ¶
BuilderWorktreesDir returns the parent for isolated build worktrees.
func CloneOrUpdate ¶
func CloneOrUpdate(ctx context.Context, url, ref string, auth transport.AuthMethod, logger *slog.Logger) (string, error)
CloneOrUpdate clones a git repository or updates it if it already exists. Returns the path to the cloned repository. A nil auth means unauthenticated.
func CreateTarFromDir ¶
func CreateTarFromDir(dir string) (io.ReadCloser, error)
CreateTarFromDir creates a tar archive from a directory.
func EnsureBuilderReposCacheDir ¶
func EnsureBuilderReposCacheDir() error
EnsureBuilderReposCacheDir creates the builder repository cache directory.
func EnsureCacheDir ¶
func EnsureCacheDir() error
EnsureCacheDir creates the cache directory if it doesn't exist.
func EnsureReposCacheDir ¶
func EnsureReposCacheDir() error
EnsureReposCacheDir creates the repos cache directory if it doesn't exist.
func GenerateImageTag ¶
GenerateImageTag creates an OCI-compatible tag that cannot alias distinct build inputs.
func GeneratePythonDockerfile ¶
func GeneratePythonDockerfile(ctx context.Context, spec PythonBuildSpec) (string, error)
GeneratePythonDockerfile returns the exact deterministic Dockerfile used by later planning and build stages.
func ReposCacheDir ¶
ReposCacheDir returns the directory for cached git repositories.
func ResolveConsoleCommand ¶
func ResolveConsoleCommand(explicit []string, projectName string, scripts []string) ([]string, error)
ResolveConsoleCommand applies the deterministic Python console-script selection contract. An explicit command always wins.
func SelectPythonVersion ¶
SelectPythonVersion chooses a supported interpreter that satisfies a requires-python specifier. An explicit selection is validated rather than replaced.
Types ¶
type BuildOptions ¶
type BuildOptions struct {
Stack string // Stack name used in image identity
ServerName string // Logical MCP server name used in image identity
// Source configuration
SourceType string // "git" or "local"
URL string // Git URL (for git source)
Ref string // Git ref/branch (for git source)
Path string // Local path (for local source)
ProjectPath string // Python project subdirectory below a local root
Runtime string // Empty for Dockerfile builds, "python" for generated builds
Package string // Public PyPI project name
Python string // Explicit Python minor version
Extras []string
With []string
Packages []string
// Build configuration
Dockerfile string // Path to Dockerfile within context
BuildArgs map[string]string // Build arguments
Command []string // Runtime command that affects the image plan
Platform string // Target OCI platform, empty means runtime default
// Cache control
NoCache bool // Force rebuild, ignore cache
// Auth carries an already-resolved git auth method for private repository
// clones. Nil means an unauthenticated clone (the public-repo default).
// Resolution from a declarative SourceAuth happens upstream so that this
// package never has to know about vaults or credential references.
Auth transport.AuthMethod
// Logger for build operations (optional, defaults to discard)
Logger *slog.Logger
}
BuildOptions contains options for building an image.
type BuildProvenance ¶
type BuildProvenance struct {
SourceContentDigest string `json:"sourceContentDigest"`
TargetPlatform string `json:"targetPlatform,omitempty"`
GeneratorVersion string `json:"generatorVersion,omitempty"`
BaseImage string `json:"baseImage,omitempty"`
UVImage string `json:"uvImage,omitempty"`
}
BuildProvenance identifies the inputs used to produce a resolved build plan.
type BuildResult ¶
type BuildResult struct {
ImageID string // Docker image ID
ImageTag string // Image tag
Cached bool // Whether the build was cached
}
BuildResult contains the result of a build operation.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder handles building images from source.
func (*Builder) Build ¶
func (b *Builder) Build(ctx context.Context, opts BuildOptions) (*BuildResult, error)
Build builds an image from the given options.
func (*Builder) Plan ¶
func (b *Builder) Plan(ctx context.Context, opts BuildOptions) (*ResolvedBuildPlan, error)
Plan resolves build inputs and checks whether the resulting image is already cached. A nil Docker client leaves Cached false, allowing callers to preview resolution on hosts without a running container runtime.
func (*Builder) Resolve ¶
func (b *Builder) Resolve(ctx context.Context, opts BuildOptions) (*ResolvedBuildPlan, error)
Resolve converts mutable source declaration into an immutable build plan.
type PyPIArtifact ¶
type PyPIArtifact struct {
Filename string `json:"filename"`
URL string `json:"url"`
Packagetype string `json:"packageType"`
SHA256 string `json:"sha256"`
Size int64 `json:"size"`
RequiresPython string `json:"requiresPython,omitempty"`
}
PyPIArtifact records the immutable release file selected for safe metadata inspection. uv remains free to choose its compatible install artifact.
type PyPIRelease ¶
type PyPIRelease struct {
Package string `json:"package"`
Version string `json:"version"`
RequiresPython string `json:"requiresPython,omitempty"`
Python string `json:"python"`
Artifact PyPIArtifact `json:"artifact"`
Metadata PythonPackageMetadata `json:"metadata"`
}
PyPIRelease is an exact, public release resolved through official PyPI.
type PyPIResolver ¶
type PyPIResolver struct {
// contains filtered or unexported fields
}
PyPIResolver performs bounded requests against the public PyPI JSON API.
func NewPyPIResolver ¶
func NewPyPIResolver(client *http.Client) *PyPIResolver
NewPyPIResolver creates a resolver. A nil client uses a bounded default.
func (*PyPIResolver) Resolve ¶
func (r *PyPIResolver) Resolve(ctx context.Context, project, version, explicitPython string) (*PyPIRelease, error)
Resolve resolves and inspects one exact public PyPI release.
func (*PyPIResolver) Versions ¶
func (r *PyPIResolver) Versions(ctx context.Context, project string) (*PyPIVersions, error)
Versions returns exact, non-yanked releases for a public PyPI project.
type PyPIVersions ¶
type PyPIVersions struct {
Package string `json:"package"`
Latest string `json:"latest"`
Versions []string `json:"versions"`
}
PyPIVersions is the selectable, non-yanked release inventory for a public PyPI project. Latest is the highest stable release.
type PythonBuildSpec ¶
type PythonBuildSpec struct {
Python string
Package string
Version string
Extras []string
With []string
Packages []string
Command []string
Local bool
Locked bool
}
PythonBuildSpec contains validated output-affecting inputs for generation.
type PythonPackageMetadata ¶
type PythonPackageMetadata struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
RequiresPython string `json:"requiresPython,omitempty"`
ConsoleScripts []string `json:"consoleScripts,omitempty"`
}
PythonPackageMetadata contains package metadata read without importing code.
func InspectWheelMetadata ¶
func InspectWheelMetadata(ctx context.Context, data []byte) (PythonPackageMetadata, error)
InspectWheelMetadata reads standards metadata from a wheel without importing or executing package code.
type PythonProjectMetadata ¶
type PythonProjectMetadata struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
RequiresPython string `json:"requiresPython,omitempty"`
ConsoleScripts []string `json:"consoleScripts,omitempty"`
HasUVLock bool `json:"hasUVLock"`
SourceFile string `json:"sourceFile"`
}
PythonProjectMetadata describes static project metadata needed to generate a build. Dynamic metadata is deliberately not evaluated on the host.
func ParsePythonProject ¶
func ParsePythonProject(ctx context.Context, projectRoot string) (*PythonProjectMetadata, error)
ParsePythonProject reads pyproject.toml or setup.py as data without invoking Python, a build backend, or project code.
type PythonTemplateConfig ¶
type PythonTemplateConfig struct {
Version string `json:"version"`
PythonImages map[string]string `json:"pythonImages"`
UVImage string `json:"uvImage"`
RuntimeUID int `json:"runtimeUid"`
RuntimeGID int `json:"runtimeGid"`
}
PythonTemplateConfig pins every external image used by generated builds.
func DefaultPythonTemplate ¶
func DefaultPythonTemplate() PythonTemplateConfig
DefaultPythonTemplate returns a copy of the pinned template configuration.
type ResolvedBuildPlan ¶
type ResolvedBuildPlan struct {
DeclaredIdentity SourceIdentity `json:"declaredIdentity"`
ResolvedIdentity SourceIdentity `json:"resolvedIdentity"`
EffectiveProjectRoot string `json:"effectiveProjectRoot"`
Python string `json:"python,omitempty"`
Command []string `json:"command,omitempty"`
Dockerfile string `json:"dockerfile"`
GeneratedDockerfile string `json:"generatedDockerfile,omitempty"`
BuildInputDigest string `json:"buildInputDigest"`
ImageTag string `json:"imageTag"`
Cached bool `json:"cached"`
MutableRef bool `json:"mutableRef"`
Provenance BuildProvenance `json:"provenance"`
// contains filtered or unexported fields
}
ResolvedBuildPlan is the immutable input to an image build.
func (*ResolvedBuildPlan) Close ¶
func (p *ResolvedBuildPlan) Close() error
Close releases temporary source material owned by the plan.
func (*ResolvedBuildPlan) ImageLabels ¶
func (p *ResolvedBuildPlan) ImageLabels() map[string]string
ImageLabels returns the non-secret provenance labels for the built image.
type SourceIdentity ¶
type SourceIdentity struct {
Type string `json:"type"`
URL string `json:"url,omitempty"`
Ref string `json:"ref,omitempty"`
Path string `json:"path,omitempty"`
ProjectPath string `json:"projectPath,omitempty"`
Dockerfile string `json:"dockerfile,omitempty"`
Commit string `json:"commit,omitempty"`
Package string `json:"package,omitempty"`
Version string `json:"version,omitempty"`
Artifact string `json:"artifact,omitempty"`
ArtifactSHA256 string `json:"artifactSha256,omitempty"`
}
SourceIdentity records the declared and immutable identities of a build source.