@@ -68,18 +68,26 @@ func (o Output) MarshalJSON() ([]byte, error) {
6868 })
6969}
7070
71- // ValidatePresets will iterate over each preset, validate the inputs as a set,
72- // and attach any diagnostics to the preset if there are issues.
73- func ValidatePresets (ctx context.Context , input Input , preValid []types.Preset , dir fs.FS ) {
71+ // ValidatePrebuilds will iterate over each preset, validate the inputs as a set,
72+ // and attach any diagnostics to the preset if there are issues. This must be done
73+ // because prebuilds have to be valid without user input.
74+ //
75+ // This will only validate presets that have prebuilds configured and have no existing
76+ // error diagnostics.
77+ func ValidatePrebuilds (ctx context.Context , input Input , preValid []types.Preset , dir fs.FS ) []types.Preset {
7478 for i := range preValid {
7579 pre := & preValid [i ]
7680 if pre .Prebuild == nil || pre .Prebuild .Instances <= 0 {
7781 // No prebuilds, so presets do not need to be valid without user input
7882 continue
7983 }
8084
81- input .ParameterValues = pre .Parameters
85+ if hcl .Diagnostics (pre .Diagnostics ).HasErrors () {
86+ // Piling on diagnostics is not helpful, if an error exists, leave it at that.
87+ continue
88+ }
8289
90+ input .ParameterValues = pre .Parameters
8391 output , diagnostics := Preview (ctx , input , dir )
8492 if diagnostics .HasErrors () {
8593 pre .Diagnostics = append (pre .Diagnostics , diagnostics ... )
@@ -102,6 +110,7 @@ func ValidatePresets(ctx context.Context, input Input, preValid []types.Preset,
102110 }
103111 }
104112 }
113+ return preValid
105114}
106115
107116func Preview (ctx context.Context , input Input , dir fs.FS ) (output * Output , diagnostics hcl.Diagnostics ) {
0 commit comments