3030// Loads and resolves the project configuration files located at the given path. Referenced include files
3131// are recursively loaded and appropriately merged. If multiple file paths are provided, they are each
3232// fully loaded and merged in specified order, with later files overriding earlier ones.
33- func loadAndResolveProjectConfig (fs opctx.FS , configFilePaths ... string ) (* ProjectConfig , error ) {
33+ func loadAndResolveProjectConfig (
34+ fs opctx.FS , permissiveConfigParsing bool , configFilePaths ... string ,
35+ ) (* ProjectConfig , error ) {
3436 resolvedCfg := & ProjectConfig {
3537 ComponentGroups : make (map [string ]ComponentGroupConfig ),
3638 Components : make (map [string ]ComponentConfig ),
@@ -40,7 +42,7 @@ func loadAndResolveProjectConfig(fs opctx.FS, configFilePaths ...string) (*Proje
4042
4143 for _ , configFilePath := range configFilePaths {
4244 // Load the project config file and all transitive includes.
43- err := loadAndMergeConfigWithIncludes (resolvedCfg , fs , configFilePath )
45+ err := loadAndMergeConfigWithIncludes (resolvedCfg , fs , configFilePath , permissiveConfigParsing )
4446 if err != nil {
4547 return nil , err
4648 }
@@ -55,9 +57,12 @@ func loadAndResolveProjectConfig(fs opctx.FS, configFilePaths ...string) (*Proje
5557 return resolvedCfg , nil
5658}
5759
58- func loadAndMergeConfigWithIncludes (configToUpdate * ProjectConfig , fs opctx.FS , filePath string ) error {
60+ func loadAndMergeConfigWithIncludes (
61+ configToUpdate * ProjectConfig , fs opctx.FS , filePath string ,
62+ permissiveConfigParsing bool ,
63+ ) error {
5964 // Load the project config file and all transitive includes.
60- loadedCfgs , err := loadProjectConfigWithIncludes (fs , filePath )
65+ loadedCfgs , err := loadProjectConfigWithIncludes (fs , filePath , permissiveConfigParsing )
6166 if err != nil {
6267 return err
6368 }
@@ -154,9 +159,11 @@ func mergeConfigFile(resolvedCfg *ProjectConfig, loadedCfg *ConfigFile) error {
154159 return nil
155160}
156161
157- func loadProjectConfigWithIncludes (fs opctx.FS , filePath string ) ([]* ConfigFile , error ) {
162+ func loadProjectConfigWithIncludes (
163+ fs opctx.FS , filePath string , permissiveConfigParsing bool ,
164+ ) ([]* ConfigFile , error ) {
158165 // Load the immediate config file.
159- cfg , err := loadProjectConfigFile (fs , filePath )
166+ cfg , err := loadProjectConfigFile (fs , filePath , permissiveConfigParsing )
160167 if err != nil {
161168 return nil , err
162169 }
@@ -188,7 +195,9 @@ func loadProjectConfigWithIncludes(fs opctx.FS, filePath string) ([]*ConfigFile,
188195 for _ , includePath := range matches {
189196 absIncludePath := makeAbsolute (cfg .dir , includePath )
190197
191- includeCfgs , err := loadProjectConfigWithIncludes (fs , absIncludePath )
198+ includeCfgs , err := loadProjectConfigWithIncludes (
199+ fs , absIncludePath , permissiveConfigParsing ,
200+ )
192201 if err != nil {
193202 return nil , err
194203 }
@@ -200,7 +209,9 @@ func loadProjectConfigWithIncludes(fs opctx.FS, filePath string) ([]*ConfigFile,
200209 return allCfgs , nil
201210}
202211
203- func loadProjectConfigFile (fs opctx.FS , filePath string ) (* ConfigFile , error ) {
212+ func loadProjectConfigFile (
213+ fs opctx.FS , filePath string , permissiveConfigParsing bool ,
214+ ) (* ConfigFile , error ) {
204215 slog .Debug ("Loading project config" , "filePath" , filePath )
205216
206217 absFilePath , err := filepath .Abs (filePath )
@@ -214,7 +225,10 @@ func loadProjectConfigFile(fs opctx.FS, filePath string) (*ConfigFile, error) {
214225 }
215226
216227 decoder := toml .NewDecoder (projectFile )
217- decoder .DisallowUnknownFields ()
228+
229+ if ! permissiveConfigParsing {
230+ decoder .DisallowUnknownFields ()
231+ }
218232
219233 cfg := & ConfigFile {}
220234
0 commit comments