From 5b8c08df3baeaf06805f0cb3f726785c975c3c38 Mon Sep 17 00:00:00 2001 From: Patrick Pacher Date: Tue, 5 Jan 2021 16:07:15 +0100 Subject: [PATCH] Fix dropin merging --- conf/dropin.go | 5 ++++- conf/{validation_errors.go => errors.go} | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) rename conf/{validation_errors.go => errors.go} (93%) diff --git a/conf/dropin.go b/conf/dropin.go index daa062d..9ea2d93 100644 --- a/conf/dropin.go +++ b/conf/dropin.go @@ -50,7 +50,7 @@ func ApplyDropIns(t *File, dropins []*DropIn, secReg SectionRegistry) error { } sectionSpec, ok := secReg.OptionsForSection(sn) - if s == nil || !ok { + if sectionSpec == nil || !ok { return fmt.Errorf("%s: %w", sn, ErrDropInSectionNotAllowed) } @@ -72,6 +72,9 @@ func ApplyDropIns(t *File, dropins []*DropIn, secReg SectionRegistry) error { } func mergeSections(s *Section, dropInSec Section, optReg OptionRegistry) error { + if optReg == nil { + return ErrNoOptions + } // build a lookup map for the option values in this // drop-in section olm := make(map[string][]Option) diff --git a/conf/validation_errors.go b/conf/errors.go similarity index 93% rename from conf/validation_errors.go rename to conf/errors.go index 95a417b..f93ef4f 100644 --- a/conf/validation_errors.go +++ b/conf/errors.go @@ -15,4 +15,5 @@ var ( ErrUnknownSection = errors.New("unknown section") ErrDropInSectionNotExists = errors.New("section defined in drop-in does not exist") ErrDropInSectionNotAllowed = errors.New("drop-ins not allowed for not-unique sections") + ErrNoOptions = errors.New("no options defined") )