Skip to content

Commit

Permalink
naming tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
flotter committed Aug 30, 2024
1 parent f665085 commit ede4849
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions internals/plan/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()

Expand All @@ -363,7 +363,7 @@ nexttest:

// Unregister extensions from previous test iteraton.
for _, field := range registeredExtensions {
plan.UnregisterExtension(field)
plan.UnregisterSectionExtension(field)
}
registeredExtensions = []string{}

Expand All @@ -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
}()
Expand Down Expand Up @@ -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(`
Expand Down
8 changes: 4 additions & 4 deletions internals/plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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
Expand Down

0 comments on commit ede4849

Please sign in to comment.