aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-containers/oci-runtime-tools/files/0001-Revert-implement-add-set-function-for-hooks-items.patch
blob: abfd0dfb31e85491819ad268bf15a875bfe2e7e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
From 2911eaabab92ec2cdea2b173c3429db4a52bee2f Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@windriver.com>
Date: Wed, 20 Sep 2017 23:28:52 -0400
Subject: [PATCH] Revert "implement add/set function for hooks items"

This reverts commit df3a46feb971386f922c7c2c2822b88301f87cb0.

Upstream-Status: Inappropriate [embedded specific]

---
 cmd/oci-runtime-tool/generate.go | 12 ++++++------
 generate/generate.go             | 42 ++++++----------------------------------
 2 files changed, 12 insertions(+), 42 deletions(-)

diff --git a/src/import/cmd/oci-runtime-tool/generate.go b/src/import/cmd/oci-runtime-tool/generate.go
index ed11fe8f3729..7121ce5fe07e 100644
--- a/src/import/cmd/oci-runtime-tool/generate.go
+++ b/src/import/cmd/oci-runtime-tool/generate.go
@@ -354,7 +354,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
 		for _, postStartEnv := range postStartEnvs {
 			path, env, err := parseHookEnv(postStartEnv)
 			if err != nil {
-				return err
+				return nil
 			}
 			g.AddPostStartHookEnv(path, env)
 		}
@@ -387,7 +387,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
 		for _, postStopEnv := range postStopEnvs {
 			path, env, err := parseHookEnv(postStopEnv)
 			if err != nil {
-				return err
+				return nil
 			}
 			g.AddPostStopHookEnv(path, env)
 		}
@@ -398,7 +398,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
 		for _, postStopTimeout := range postStopTimeouts {
 			path, timeout, err := parseHookTimeout(postStopTimeout)
 			if err != nil {
-				return err
+				return nil
 			}
 			g.AddPostStopHookTimeout(path, timeout)
 		}
@@ -409,7 +409,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
 		for _, hook := range preStartHooks {
 			path, args, err := parseHook(hook)
 			if err != nil {
-				return err
+				return nil
 			}
 			g.AddPreStartHook(path, args)
 		}
@@ -420,7 +420,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
 		for _, preStartEnv := range preStartEnvs {
 			path, env, err := parseHookEnv(preStartEnv)
 			if err != nil {
-				return err
+				return nil
 			}
 			g.AddPreStartHookEnv(path, env)
 		}
@@ -431,7 +431,7 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
 		for _, preStartTimeout := range preStartTimeouts {
 			path, timeout, err := parseHookTimeout(preStartTimeout)
 			if err != nil {
-				return err
+				return nil
 			}
 			g.AddPreStartHookTimeout(path, timeout)
 		}
diff --git a/src/import/generate/generate.go b/src/import/generate/generate.go
index 84762c3cbd05..ef5d2cc95b3c 100644
--- a/src/import/generate/generate.go
+++ b/src/import/generate/generate.go
@@ -744,39 +744,29 @@ func (g *Generator) ClearPreStartHooks() {
 func (g *Generator) AddPreStartHook(path string, args []string) {
 	g.initSpecHooks()
 	hook := rspec.Hook{Path: path, Args: args}
-	for i, hook := range g.spec.Hooks.Prestart {
-		if hook.Path == path {
-			g.spec.Hooks.Prestart[i] = hook
-			return
-		}
-	}
 	g.spec.Hooks.Prestart = append(g.spec.Hooks.Prestart, hook)
 }
 
 // AddPreStartHookEnv adds envs of a prestart hook into g.spec.Hooks.Prestart.
 func (g *Generator) AddPreStartHookEnv(path string, envs []string) {
-	g.initSpecHooks()
+	g.initSpec()
 	for i, hook := range g.spec.Hooks.Prestart {
 		if hook.Path == path {
 			g.spec.Hooks.Prestart[i].Env = envs
 			return
 		}
 	}
-	hook := rspec.Hook{Path: path, Env: envs}
-	g.spec.Hooks.Prestart = append(g.spec.Hooks.Prestart, hook)
 }
 
 // AddPreStartHookTimeout adds timeout of a prestart hook into g.spec.Hooks.Prestart.
 func (g *Generator) AddPreStartHookTimeout(path string, timeout int) {
-	g.initSpecHooks()
+	g.initSpec()
 	for i, hook := range g.spec.Hooks.Prestart {
 		if hook.Path == path {
 			g.spec.Hooks.Prestart[i].Timeout = &timeout
 			return
 		}
 	}
-	hook := rspec.Hook{Path: path, Timeout: &timeout}
-	g.spec.Hooks.Prestart = append(g.spec.Hooks.Prestart, hook)
 }
 
 // ClearPostStopHooks clear g.spec.Hooks.Poststop.
@@ -794,39 +784,29 @@ func (g *Generator) ClearPostStopHooks() {
 func (g *Generator) AddPostStopHook(path string, args []string) {
 	g.initSpecHooks()
 	hook := rspec.Hook{Path: path, Args: args}
-	for i, hook := range g.spec.Hooks.Poststop {
-		if hook.Path == path {
-			g.spec.Hooks.Poststop[i] = hook
-			return
-		}
-	}
 	g.spec.Hooks.Poststop = append(g.spec.Hooks.Poststop, hook)
 }
 
 // AddPostStopHookEnv adds envs of a poststop hook into g.spec.Hooks.Poststop.
 func (g *Generator) AddPostStopHookEnv(path string, envs []string) {
-	g.initSpecHooks()
+	g.initSpec()
 	for i, hook := range g.spec.Hooks.Poststop {
 		if hook.Path == path {
 			g.spec.Hooks.Poststop[i].Env = envs
 			return
 		}
 	}
-	hook := rspec.Hook{Path: path, Env: envs}
-	g.spec.Hooks.Poststop = append(g.spec.Hooks.Poststop, hook)
 }
 
 // AddPostStopHookTimeout adds timeout of a poststop hook into g.spec.Hooks.Poststop.
 func (g *Generator) AddPostStopHookTimeout(path string, timeout int) {
-	g.initSpecHooks()
+	g.initSpec()
 	for i, hook := range g.spec.Hooks.Poststop {
 		if hook.Path == path {
 			g.spec.Hooks.Poststop[i].Timeout = &timeout
 			return
 		}
 	}
-	hook := rspec.Hook{Path: path, Timeout: &timeout}
-	g.spec.Hooks.Poststop = append(g.spec.Hooks.Poststop, hook)
 }
 
 // ClearPostStartHooks clear g.spec.Hooks.Poststart.
@@ -844,39 +824,29 @@ func (g *Generator) ClearPostStartHooks() {
 func (g *Generator) AddPostStartHook(path string, args []string) {
 	g.initSpecHooks()
 	hook := rspec.Hook{Path: path, Args: args}
-	for i, hook := range g.spec.Hooks.Poststart {
-		if hook.Path == path {
-			g.spec.Hooks.Poststart[i] = hook
-			return
-		}
-	}
 	g.spec.Hooks.Poststart = append(g.spec.Hooks.Poststart, hook)
 }
 
 // AddPostStartHookEnv adds envs of a poststart hook into g.spec.Hooks.Poststart.
 func (g *Generator) AddPostStartHookEnv(path string, envs []string) {
-	g.initSpecHooks()
+	g.initSpec()
 	for i, hook := range g.spec.Hooks.Poststart {
 		if hook.Path == path {
 			g.spec.Hooks.Poststart[i].Env = envs
 			return
 		}
 	}
-	hook := rspec.Hook{Path: path, Env: envs}
-	g.spec.Hooks.Poststart = append(g.spec.Hooks.Poststart, hook)
 }
 
 // AddPostStartHookTimeout adds timeout of a poststart hook into g.spec.Hooks.Poststart.
 func (g *Generator) AddPostStartHookTimeout(path string, timeout int) {
-	g.initSpecHooks()
+	g.initSpec()
 	for i, hook := range g.spec.Hooks.Poststart {
 		if hook.Path == path {
 			g.spec.Hooks.Poststart[i].Timeout = &timeout
 			return
 		}
 	}
-	hook := rspec.Hook{Path: path, Timeout: &timeout}
-	g.spec.Hooks.Poststart = append(g.spec.Hooks.Poststart, hook)
 }
 
 // AddTmpfsMount adds a tmpfs mount into g.spec.Mounts.
-- 
2.4.0.53.g8440f74