diff --git a/internals/plan/extensions_test.go b/internals/plan/extensions_test.go index 9885bf20..0be9d051 100644 --- a/internals/plan/extensions_test.go +++ b/internals/plan/extensions_test.go @@ -353,7 +353,7 @@ func (s *S) TestPlanExtensions(c *C) { defer func() { // Remove remaining registered extensions. for _, field := range registeredExtensions { - plan.UnregisterExtension(field) + plan.UnregisterSectionExtension(field) } }() @@ -363,7 +363,7 @@ nexttest: // Unregister extensions from previous test iteraton. for _, field := range registeredExtensions { - plan.UnregisterExtension(field) + plan.UnregisterSectionExtension(field) } registeredExtensions = []string{} @@ -380,7 +380,7 @@ nexttest: err = fmt.Errorf("%v", r) } }() - plan.RegisterExtension(e.field, e.ext) + plan.RegisterSectionExtension(e.field, e.ext) registeredExtensions = append(registeredExtensions, e.field) return nil }() @@ -430,11 +430,11 @@ nexttest: // registration and follows the built-in sections which are ordered // the same way they are defined in the Plan struct. func (s *S) TestSectionOrderExt(c *C) { - plan.RegisterExtension("x-field", &xExtension{}) - plan.RegisterExtension("y-field", &yExtension{}) + plan.RegisterSectionExtension("x-field", &xExtension{}) + plan.RegisterSectionExtension("y-field", &yExtension{}) defer func() { - plan.UnregisterExtension("x-field") - plan.UnregisterExtension("y-field") + plan.UnregisterSectionExtension("x-field") + plan.UnregisterSectionExtension("y-field") }() layer, err := plan.ParseLayer(1, "label", reindent(` diff --git a/internals/plan/plan.go b/internals/plan/plan.go index 3d8dc663..d75146b7 100644 --- a/internals/plan/plan.go +++ b/internals/plan/plan.go @@ -81,11 +81,11 @@ var ( // the YAML fields exposed in the Layer type, to catch inconsistencies. var builtinSections = []string{"summary", "description", "services", "checks", "log-targets"} -// RegisterExtension adds a plan schema extension. All registrations must be +// RegisterSectionExtension adds a plan schema extension. All registrations must be // done before the plan library is used. The order in which extensions are // registered determines the order in which the sections are marshalled. // Extension sections are marshalled after the built-in sections. -func RegisterExtension(field string, ext SectionExtension) { +func RegisterSectionExtension(field string, ext SectionExtension) { if slices.Contains(builtinSections, field) { panic(fmt.Sprintf("internal error: extension %q already used as built-in field", field)) } @@ -96,9 +96,9 @@ func RegisterExtension(field string, ext SectionExtension) { sectionExtensionsOrder = append(sectionExtensionsOrder, field) } -// UnregisterExtension removes a plan schema extension. This is only +// UnregisterSectionExtension removes a plan schema extension. This is only // intended for use by tests during cleanup. -func UnregisterExtension(field string) { +func UnregisterSectionExtension(field string) { delete(sectionExtensions, field) sectionExtensionsOrder = slices.DeleteFunc(sectionExtensionsOrder, func(n string) bool { return n == field