@@ -11,6 +11,7 @@ import (
1111 "strings"
1212
1313 "github.com/replicatedhq/replicated/pkg/tools"
14+ "gopkg.in/yaml.v3"
1415)
1516
1617// PreflightLintResult represents the JSON output from preflight lint
@@ -34,11 +35,13 @@ type PreflightLintIssue struct {
3435
3536// LintPreflight executes preflight lint on the given spec path and returns structured results.
3637// The preflight CLI tool handles template rendering and validation internally.
37- // For v1beta3 specs, we validate that HelmChart manifests exist before linting .
38+ // For v1beta3 specs, we validate that HelmChart manifests exist and extract builder values .
3839func LintPreflight (
3940 ctx context.Context ,
4041 specPath string ,
4142 valuesPath string ,
43+ chartName string ,
44+ chartVersion string ,
4245 helmChartManifests map [string ]* HelmChartManifest ,
4346 preflightVersion string ,
4447) (* LintResult , error ) {
@@ -72,11 +75,43 @@ func LintPreflight(
7275 // Build command arguments
7376 args := []string {"lint" , "--format" , "json" }
7477
75- // Add values file if provided
78+ // Add chart values file if provided from config
7679 if valuesPath != "" {
7780 args = append (args , "--values" , valuesPath )
7881 }
7982
83+ // Extract and add builder values if HelmChart manifest exists
84+ var builderValuesPath string
85+ if chartName != "" && chartVersion != "" {
86+ key := fmt .Sprintf ("%s:%s" , chartName , chartVersion )
87+ if helmChart , found := helmChartManifests [key ]; found && helmChart .BuilderValues != nil {
88+ // Create temp file for builder values
89+ builderFile , err := os .CreateTemp ("" , "replicated-builder-*.yaml" )
90+ if err != nil {
91+ return nil , fmt .Errorf ("failed to create temp file for builder values: %w" , err )
92+ }
93+ builderValuesPath = builderFile .Name ()
94+ defer func () {
95+ if err := os .Remove (builderValuesPath ); err != nil && ! os .IsNotExist (err ) {
96+ fmt .Fprintf (os .Stderr , "Warning: failed to cleanup builder values temp file %s: %v\n " , builderValuesPath , err )
97+ }
98+ }()
99+
100+ // Write builder values as YAML
101+ builderYAML , err := yaml .Marshal (helmChart .BuilderValues )
102+ if err != nil {
103+ return nil , fmt .Errorf ("failed to marshal builder values: %w" , err )
104+ }
105+ if _ , err := builderFile .Write (builderYAML ); err != nil {
106+ return nil , fmt .Errorf ("failed to write builder values: %w" , err )
107+ }
108+ builderFile .Close ()
109+
110+ // Add builder values to command
111+ args = append (args , "--values" , builderValuesPath )
112+ }
113+ }
114+
80115 args = append (args , specPath )
81116
82117 // Execute preflight lint
0 commit comments