@@ -74,7 +74,7 @@ func (o Output) MarshalJSON() ([]byte, error) {
7474//
7575// This will only validate presets that have prebuilds configured and have no existing
7676// error diagnostics.
77- func ValidatePrebuilds (ctx context.Context , input Input , preValid []types.Preset , dir fs.FS ) []types. Preset {
77+ func ValidatePrebuilds (ctx context.Context , input Input , preValid []types.Preset , dir fs.FS ) {
7878 for i := range preValid {
7979 pre := & preValid [i ]
8080 if pre .Prebuild == nil || pre .Prebuild .Instances <= 0 {
@@ -87,16 +87,21 @@ func ValidatePrebuilds(ctx context.Context, input Input, preValid []types.Preset
8787 continue
8888 }
8989
90+ // Diagnostics are added to the existing preset.
9091 input .ParameterValues = pre .Parameters
9192 output , diagnostics := Preview (ctx , input , dir )
9293 if diagnostics .HasErrors () {
9394 pre .Diagnostics = append (pre .Diagnostics , diagnostics ... )
95+ // Do not pile on more diagnostics for individual params, it already failed
96+ continue
9497 }
9598
9699 if output == nil {
97100 continue
98101 }
99102
103+ // If any parameter is invalid, then the preset is invalid.
104+ // A value must be specified for this failing parameter.
100105 for _ , param := range output .Parameters {
101106 if hcl .Diagnostics (param .Diagnostics ).HasErrors () {
102107 for _ , paramDiag := range param .Diagnostics {
@@ -110,7 +115,6 @@ func ValidatePrebuilds(ctx context.Context, input Input, preValid []types.Preset
110115 }
111116 }
112117 }
113- return preValid
114118}
115119
116120func Preview (ctx context.Context , input Input , dir fs.FS ) (output * Output , diagnostics hcl.Diagnostics ) {
0 commit comments