Skip to content

Commit dc0f263

Browse files
committed
hooks: handle prestart as createRuntime
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
1 parent 8543328 commit dc0f263

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

pkg/hooks/hooks.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,8 @@ func (m *Manager) Hooks(config *rspec.Spec, annotations map[string]string, hasBi
122122
switch stage {
123123
case "createContainer":
124124
config.Hooks.CreateContainer = append(config.Hooks.CreateContainer, namedHook.hook.Hook)
125-
case "createRuntime":
125+
case "createRuntime", "prestart":
126126
config.Hooks.CreateRuntime = append(config.Hooks.CreateRuntime, namedHook.hook.Hook)
127-
case "prestart":
128-
config.Hooks.Prestart = append(config.Hooks.Prestart, namedHook.hook.Hook)
129127
case "poststart":
130128
config.Hooks.Poststart = append(config.Hooks.Poststart, namedHook.hook.Hook)
131129
case "poststop":

pkg/hooks/hooks_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestGoodNew(t *testing.T) {
5252
two := 2
5353
three := 3
5454
assert.Equal(t, &rspec.Hooks{
55-
Prestart: []rspec.Hook{
55+
CreateRuntime: []rspec.Hook{
5656
{
5757
Path: path,
5858
Timeout: &one,
@@ -183,7 +183,7 @@ func TestExtensionStage(t *testing.T) {
183183
}
184184

185185
assert.Equal(t, &rspec.Hooks{
186-
Prestart: []rspec.Hook{
186+
CreateRuntime: []rspec.Hook{
187187
{
188188
Path: "/a/b/c",
189189
},

pkg/hooks/monitor_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestMonitorOneDirGood(t *testing.T) {
4646
}
4747

4848
assert.Equal(t, &rspec.Hooks{
49-
Prestart: []rspec.Hook{
49+
CreateRuntime: []rspec.Hook{
5050
{
5151
Path: path,
5252
},
@@ -128,7 +128,7 @@ func TestMonitorTwoDirGood(t *testing.T) {
128128
fallbackPath := filepath.Join(fallbackDir, "a.json")
129129
fallbackJSON := []byte(fmt.Sprintf("{\"version\": \"1.0.0\", \"hook\": {\"path\": \"%s\"}, \"when\": {\"always\": true}, \"stages\": [\"prestart\"]}", path))
130130
fallbackInjected := &rspec.Hooks{
131-
Prestart: []rspec.Hook{
131+
CreateRuntime: []rspec.Hook{
132132
{
133133
Path: path,
134134
},
@@ -156,7 +156,7 @@ func TestMonitorTwoDirGood(t *testing.T) {
156156
primaryJSON := []byte(fmt.Sprintf("{\"version\": \"1.0.0\", \"hook\": {\"path\": \"%s\", \"timeout\": 1}, \"when\": {\"always\": true}, \"stages\": [\"prestart\"]}", path))
157157
one := 1
158158
primaryInjected := &rspec.Hooks{
159-
Prestart: []rspec.Hook{
159+
CreateRuntime: []rspec.Hook{
160160
{
161161
Path: path,
162162
Timeout: &one,

0 commit comments

Comments
 (0)