summaryrefslogtreecommitdiff
path: root/pkg/hooks/hooks.go
diff options
context:
space:
mode:
authorW. Trevor King <wking@tremily.us>2018-05-30 14:02:20 -0700
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-31 14:11:52 +0000
commit4dfe0d60f3593360b9d43d8dd38981e971c9b642 (patch)
treeb8e2f70c9df7b8bb5613b16df296b26daf417fe8 /pkg/hooks/hooks.go
parent7c1434c2f7fd4e8922f3feb1e5babe2b9804cce9 (diff)
downloadpodman-4dfe0d60f3593360b9d43d8dd38981e971c9b642.tar.gz
podman-4dfe0d60f3593360b9d43d8dd38981e971c9b642.tar.bz2
podman-4dfe0d60f3593360b9d43d8dd38981e971c9b642.zip
hooks: Rename Hooks() output to extensionStageHooks
To more clearly distinguish between the extensionStages input to New() (a slice of strings) and the map output from Hooks(). Signed-off-by: W. Trevor King <wking@tremily.us> Closes: #855 Approved by: rhatdan
Diffstat (limited to 'pkg/hooks/hooks.go')
-rw-r--r--pkg/hooks/hooks.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/pkg/hooks/hooks.go b/pkg/hooks/hooks.go
index b78ede38b..d18cc1195 100644
--- a/pkg/hooks/hooks.go
+++ b/pkg/hooks/hooks.go
@@ -88,28 +88,28 @@ func (m *Manager) namedHooks() (hooks []*namedHook) {
// Hooks injects OCI runtime hooks for a given container configuration.
//
-// If the extensionStages slice was set when initializing the Manager,
-// matching hooks requesting those stages will be returned in the
-// extensionStages map. This takes precedence over their inclusion in
+// If extensionStages was set when initializing the Manager,
+// matching hooks requesting those stages will be returned in
+// extensionStageHooks. This takes precedence over their inclusion in
// the OCI configuration. For example:
//
// manager, err := New(ctx, []string{DefaultDir}, []string{"poststop"}, lang)
-// extensionStages, err := manager.Hooks(config, annotations, hasBindMounts)
+// extensionStageHooks, err := manager.Hooks(config, annotations, hasBindMounts)
//
-// will have any matching post-stop hooks in extensionStages and will
-// not insert them into config.Hooks.Poststop.
-func (m *Manager) Hooks(config *rspec.Spec, annotations map[string]string, hasBindMounts bool) (extensionStages map[string][]rspec.Hook, err error) {
+// will have any matching post-stop hooks in extensionStageHooks and
+// will not insert them into config.Hooks.Poststop.
+func (m *Manager) Hooks(config *rspec.Spec, annotations map[string]string, hasBindMounts bool) (extensionStageHooks map[string][]rspec.Hook, err error) {
hooks := m.namedHooks()
collator := collate.New(m.language, collate.IgnoreCase, collate.IgnoreWidth)
collator.Sort(namedHooks(hooks))
- localStages := map[string]bool{} // stages destined for extensionStages
+ localStages := map[string]bool{} // stages destined for extensionStageHooks
for _, stage := range m.extensionStages {
localStages[stage] = true
}
for _, namedHook := range hooks {
match, err := namedHook.hook.When.Match(config, annotations, hasBindMounts)
if err != nil {
- return extensionStages, errors.Wrapf(err, "matching hook %q", namedHook.name)
+ return extensionStageHooks, errors.Wrapf(err, "matching hook %q", namedHook.name)
}
if match {
if config.Hooks == nil {
@@ -117,10 +117,10 @@ func (m *Manager) Hooks(config *rspec.Spec, annotations map[string]string, hasBi
}
for _, stage := range namedHook.hook.Stages {
if _, ok := localStages[stage]; ok {
- if extensionStages == nil {
- extensionStages = map[string][]rspec.Hook{}
+ if extensionStageHooks == nil {
+ extensionStageHooks = map[string][]rspec.Hook{}
}
- extensionStages[stage] = append(extensionStages[stage], namedHook.hook.Hook)
+ extensionStageHooks[stage] = append(extensionStageHooks[stage], namedHook.hook.Hook)
} else {
switch stage {
case "prestart":
@@ -130,14 +130,14 @@ func (m *Manager) Hooks(config *rspec.Spec, annotations map[string]string, hasBi
case "poststop":
config.Hooks.Poststop = append(config.Hooks.Poststop, namedHook.hook.Hook)
default:
- return extensionStages, fmt.Errorf("hook %q: unknown stage %q", namedHook.name, stage)
+ return extensionStageHooks, fmt.Errorf("hook %q: unknown stage %q", namedHook.name, stage)
}
}
}
}
}
- return extensionStages, nil
+ return extensionStageHooks, nil
}
// remove remove a hook by name.