@@ -27,16 +27,9 @@ const (
27
27
CustomBuilderSchema = "olm.builder.custom"
28
28
)
29
29
30
- type ContainerConfig struct {
31
- ContainerTool string
32
- BaseImage string
33
- WorkingDir string
34
- }
35
-
36
30
type BuilderConfig struct {
37
- ContainerCfg ContainerConfig
38
- OutputType string
39
- InputDirectory string
31
+ WorkingDir string
32
+ OutputType string
40
33
}
41
34
42
35
type Builder interface {
@@ -96,13 +89,13 @@ func (bb *BasicBuilder) Build(ctx context.Context, reg image.Registry, dir strin
96
89
return fmt .Errorf ("error rendering basic template: %v" , err )
97
90
}
98
91
99
- destPath := path .Join (bb .builderCfg .ContainerCfg . WorkingDir , dir , basicConfig .Output )
92
+ destPath := path .Join (bb .builderCfg .WorkingDir , dir , basicConfig .Output )
100
93
101
94
return build (dcfg , destPath , bb .builderCfg .OutputType )
102
95
}
103
96
104
97
func (bb * BasicBuilder ) Validate (dir string ) error {
105
- return validate (bb .builderCfg . ContainerCfg , dir )
98
+ return validate (bb .builderCfg , dir )
106
99
}
107
100
108
101
type SemverBuilder struct {
@@ -158,13 +151,13 @@ func (sb *SemverBuilder) Build(ctx context.Context, reg image.Registry, dir stri
158
151
return fmt .Errorf ("error rendering semver template: %v" , err )
159
152
}
160
153
161
- destPath := path .Join (sb .builderCfg .ContainerCfg . WorkingDir , dir , semverConfig .Output )
154
+ destPath := path .Join (sb .builderCfg .WorkingDir , dir , semverConfig .Output )
162
155
163
156
return build (dcfg , destPath , sb .builderCfg .OutputType )
164
157
}
165
158
166
159
func (sb * SemverBuilder ) Validate (dir string ) error {
167
- return validate (sb .builderCfg . ContainerCfg , dir )
160
+ return validate (sb .builderCfg , dir )
168
161
}
169
162
170
163
type RawBuilder struct {
@@ -218,13 +211,13 @@ func (rb *RawBuilder) Build(ctx context.Context, _ image.Registry, dir string, t
218
211
return fmt .Errorf ("error parsing raw input file: %s, %v" , rawConfig .Input , err )
219
212
}
220
213
221
- destPath := path .Join (rb .builderCfg .ContainerCfg . WorkingDir , dir , rawConfig .Output )
214
+ destPath := path .Join (rb .builderCfg .WorkingDir , dir , rawConfig .Output )
222
215
223
216
return build (dcfg , destPath , rb .builderCfg .OutputType )
224
217
}
225
218
226
219
func (rb * RawBuilder ) Validate (dir string ) error {
227
- return validate (rb .builderCfg . ContainerCfg , dir )
220
+ return validate (rb .builderCfg , dir )
228
221
}
229
222
230
223
type CustomBuilder struct {
@@ -268,13 +261,12 @@ func (cb *CustomBuilder) Build(ctx context.Context, reg image.Registry, dir stri
268
261
}
269
262
// build the command to execute
270
263
cmd := exec .Command (customConfig .Command , customConfig .Args ... )
271
- cmd .Dir = cb .builderCfg .ContainerCfg .WorkingDir
272
264
273
265
// custom template should output a valid FBC to STDOUT so we can
274
266
// build the FBC just like all the other templates.
275
267
v , err := cmd .Output ()
276
268
if err != nil {
277
- return fmt .Errorf ("running command %q: %v" , cmd .String (), err )
269
+ return fmt .Errorf ("running command %q: %v: %v " , cmd .String (), err , v )
278
270
}
279
271
280
272
reader := bytes .NewReader (v )
@@ -286,15 +278,15 @@ func (cb *CustomBuilder) Build(ctx context.Context, reg image.Registry, dir stri
286
278
return fmt .Errorf ("error parsing custom command output: %s, %v" , strings .Join (cmdString , "'" ), err )
287
279
}
288
280
289
- destPath := path .Join (cb .builderCfg .ContainerCfg . WorkingDir , dir , customConfig .Output )
281
+ destPath := path .Join (cb .builderCfg .WorkingDir , dir , customConfig .Output )
290
282
291
283
// custom template should output a valid FBC to STDOUT so we can
292
284
// build the FBC just like all the other templates.
293
285
return build (dcfg , destPath , cb .builderCfg .OutputType )
294
286
}
295
287
296
288
func (cb * CustomBuilder ) Validate (dir string ) error {
297
- return validate (cb .builderCfg . ContainerCfg , dir )
289
+ return validate (cb .builderCfg , dir )
298
290
}
299
291
300
292
func writeDeclCfg (dcfg declcfg.DeclarativeConfig , w io.Writer , output string ) error {
@@ -308,12 +300,12 @@ func writeDeclCfg(dcfg declcfg.DeclarativeConfig, w io.Writer, output string) er
308
300
}
309
301
}
310
302
311
- func validate (containerCfg ContainerConfig , dir string ) error {
303
+ func validate (builderCfg BuilderConfig , dir string ) error {
312
304
313
- path := path .Join (containerCfg .WorkingDir , dir )
305
+ path := path .Join (builderCfg .WorkingDir , dir )
314
306
s , err := os .Stat (path )
315
307
if err != nil {
316
- return fmt .Errorf ("directory not found. validation path needs to be composed of ContainerConfig .WorkingDir+Component[].Destination.Path: %q: %v" , path , err )
308
+ return fmt .Errorf ("directory not found. validation path needs to be composed of BuilderConfig .WorkingDir+Component[].Destination.Path: %q: %v" , path , err )
317
309
}
318
310
if ! s .IsDir () {
319
311
return fmt .Errorf ("%q is not a directory" , path )
0 commit comments