Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ require (
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20250313105119-ba97887b0a25 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/sasha-s/go-deadlock v0.3.5 // indirect
Expand Down
13 changes: 11 additions & 2 deletions pkg/artifact/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ func (a *ArtifactBuilder) Pull(ociRefs []string) (map[string][]byte, error) {
// GetTemplateData extracts and returns template data from an OCI artifact reference.
// Downloads and caches the OCI artifact, decompresses the tar.gz payload, and returns a map
// with forward-slash file paths as keys and file contents as values. The returned map always includes
// "ociUrl" (the original OCI reference) and "name" (from metadata.yaml if present). Only .jsonnet files
// are included as template data. Returns an error on invalid reference, download failure, or extraction error.
// "ociUrl" (the original OCI reference), "name" (from metadata.yaml if present), and "values" (from values.yaml if present).
// Only .jsonnet files are included as template data. Returns an error on invalid reference, download failure, or extraction error.
func (a *ArtifactBuilder) GetTemplateData(ociRef string) (map[string][]byte, error) {
if !strings.HasPrefix(ociRef, "oci://") {
return nil, fmt.Errorf("invalid OCI reference: %s", ociRef)
Expand Down Expand Up @@ -374,6 +374,7 @@ func (a *ArtifactBuilder) GetTemplateData(ociRef string) (map[string][]byte, err
var metadataName string
jsonnetFiles := make(map[string][]byte)
var hasMetadata, hasBlueprintJsonnet bool
var valuesContent []byte

for {
header, err := tarReader.Next()
Expand All @@ -399,6 +400,11 @@ func (a *ArtifactBuilder) GetTemplateData(ociRef string) (map[string][]byte, err
return nil, fmt.Errorf("failed to parse metadata.yaml: %w", err)
}
metadataName = metadata.Name
case name == "_template/values.yaml":
valuesContent, err = io.ReadAll(tarReader)
if err != nil {
return nil, fmt.Errorf("failed to read _template/values.yaml: %w", err)
}
case strings.HasSuffix(name, ".jsonnet"):
normalized := strings.TrimPrefix(name, "_template/")
if normalized == "blueprint.jsonnet" {
Expand All @@ -420,6 +426,9 @@ func (a *ArtifactBuilder) GetTemplateData(ociRef string) (map[string][]byte, err
}

templateData["name"] = []byte(metadataName)
if valuesContent != nil {
templateData["values"] = valuesContent
}
maps.Copy(templateData, jsonnetFiles)

return templateData, nil
Expand Down
Loading
Loading