@@ -161,6 +161,25 @@ func BuilderWithLoggerProvider(loggerProvider LoggerProvider) BuilderOption {
161161// If the file does not exist, this is a no-op.
162162// The value should be a pointer to unmarshal into.
163163func ReadConfig (container NameContainer , value interface {}) error {
164+ configFilePath := filepath .Join (container .ConfigDirPath (), configFileName )
165+ data , err := os .ReadFile (configFilePath )
166+ if ! errors .Is (err , os .ErrNotExist ) {
167+ if err != nil {
168+ return fmt .Errorf ("could not read %s configuration file at %s: %w" , container .AppName (), configFilePath , err )
169+ }
170+ if err := encoding .UnmarshalYAMLStrict (data , value ); err != nil {
171+ return fmt .Errorf ("invalid %s configuration file: %w" , container .AppName (), err )
172+ }
173+ }
174+ return nil
175+ }
176+
177+ // ReadConfigNonStrict reads the configuration from the YAML configuration file config.yaml
178+ // in the configuration directory, ignoring any unknown properties.
179+ //
180+ // If the file does not exist, this is a no-op.
181+ // The value should be a pointer to unmarshal into.
182+ func ReadConfigNonStrict (container NameContainer , value interface {}) error {
164183 configFilePath := filepath .Join (container .ConfigDirPath (), configFileName )
165184 data , err := os .ReadFile (configFilePath )
166185 if ! errors .Is (err , os .ErrNotExist ) {
0 commit comments