result

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package result provides types for tracking bundle generation results.

This package defines structures for capturing generation results and aggregating them into a final output report with deployment instructions.

Core Types

Result: Individual bundle generation result

type Result struct {
    Type         types.BundleType   // Bundle type (e.g., "helm-bundle")
    Success      bool               // Whether generation succeeded
    Files        []string           // Generated file paths
    Size         int64              // Total size in bytes
    Duration     time.Duration      // Generation time
    Checksum     string             // SHA256 checksum
    Errors       []string           // Non-fatal errors
    OCIDigest    string             // OCI digest (if pushed)
    OCIReference string             // OCI reference (if pushed)
    Pushed       bool               // Whether pushed to OCI registry
}

Output: Aggregated results with deployment instructions

type Output struct {
    Results       []*Result          // Bundle results
    TotalSize     int64              // Total bytes generated
    TotalFiles    int                // Total files generated
    TotalDuration time.Duration      // Total generation time
    Errors        []BundleError      // Errors from failed bundlers
    OutputDir     string             // Output directory path
    Deployment    *DeploymentInfo    // Deployment instructions
}

Usage

Results are created by the bundler and returned from Make:

b, _ := bundler.New()
output, err := b.Make(ctx, recipeResult, "./bundle")

if output.HasErrors() {
    // handle errors
}

Deployment Instructions

Output includes structured deployment steps from the deployer:

if output.Deployment != nil {
    fmt.Println(output.Deployment.Type) // "Helm per-component bundle"
    for _, step := range output.Deployment.Steps {
        fmt.Println(step)
    }
}

Thread Safety

Individual Result instances are not thread-safe. However, Output can safely aggregate results since each Result is independent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BundleError

type BundleError struct {
	BundlerType types.BundleType `json:"bundler_type" yaml:"bundler_type"`
	Error       string           `json:"error" yaml:"error"`
}

BundleError represents an error from a specific bundler.

type DeploymentInfo

type DeploymentInfo struct {
	// Type describes the deployment method (e.g., "Helm per-component bundle", "ArgoCD applications").
	Type string `json:"type" yaml:"type"`

	// Steps contains ordered deployment instructions (e.g., ["cd ./bundle", "helm install ..."]).
	Steps []string `json:"steps" yaml:"steps"`

	// Notes contains optional warnings or additional information.
	Notes []string `json:"notes,omitempty" yaml:"notes,omitempty"`
}

DeploymentInfo contains structured deployment instructions. Deployers populate this to provide user-facing guidance.

type Output

type Output struct {
	// Results contains individual bundler results.
	Results []*Result `json:"results" yaml:"results"`

	// TotalSize is the total size in bytes of all generated files.
	TotalSize int64 `json:"total_size_bytes" yaml:"total_size_bytes"`

	// TotalFiles is the total count of generated files.
	TotalFiles int `json:"total_files" yaml:"total_files"`

	// TotalDuration is the total time taken for all bundlers.
	TotalDuration time.Duration `json:"total_duration" yaml:"total_duration"`

	// Errors contains errors from failed bundlers.
	Errors []BundleError `json:"errors,omitempty" yaml:"errors,omitempty"`

	// OutputDir is the directory where bundles were generated.
	OutputDir string `json:"output_dir" yaml:"output_dir"`

	// Deployment contains structured deployment instructions from the deployer.
	Deployment *DeploymentInfo `json:"deployment,omitempty" yaml:"deployment,omitempty"`
}

Output contains the aggregated results of all bundler executions.

func (*Output) HasErrors

func (o *Output) HasErrors() bool

HasErrors returns true if any bundler failed.

type Result

type Result struct {
	// Type is the bundler type that generated this result.
	Type types.BundleType `json:"type" yaml:"type"`

	// Files is the list of files generated by this bundler.
	Files []string `json:"files" yaml:"files"`

	// Duration is the time taken to generate the bundle.
	Duration time.Duration `json:"duration" yaml:"duration"`

	// Size is the total size in bytes of all generated files.
	Size int64 `json:"size_bytes" yaml:"size_bytes"`

	// Checksum is the SHA256 checksum of the bundle contents.
	Checksum string `json:"checksum" yaml:"checksum"`

	// Errors contains non-fatal errors encountered during generation.
	Errors []string `json:"errors,omitempty" yaml:"errors,omitempty"`

	// Success indicates whether the bundler completed successfully.
	Success bool `json:"success" yaml:"success"`

	// OCIDigest is the SHA256 digest of the pushed OCI artifact.
	OCIDigest string `json:"oci_digest,omitempty" yaml:"oci_digest,omitempty"`

	// OCIReference is the full image reference (registry/repository:tag).
	OCIReference string `json:"oci_reference,omitempty" yaml:"oci_reference,omitempty"`

	// Pushed indicates whether the bundle was pushed to an OCI registry.
	Pushed bool `json:"pushed,omitempty" yaml:"pushed,omitempty"`
}

Result contains the result of a single bundler execution.

func New

func New(bundlerType types.BundleType) *Result

New creates a new Result with the given type.

func (*Result) AddError

func (r *Result) AddError(err error)

AddError adds a non-fatal error to the result.

func (*Result) AddFile

func (r *Result) AddFile(path string, size int64)

AddFile adds a file to the result and updates size.

func (*Result) MarkSuccess

func (r *Result) MarkSuccess()

MarkSuccess marks the bundle generation as successful.

func (*Result) SetOCIMetadata

func (r *Result) SetOCIMetadata(digest, reference string, pushed bool)

SetOCIMetadata sets the OCI metadata on the result. The pushed parameter indicates whether the artifact was pushed to a remote registry.

Jump to

Keyboard shortcuts

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