Skip to content

Commit 17c4ed3

Browse files
authored
Merge pull request operator-framework#1 from oceanc80/schema-trim
Remove obsolete fields
2 parents ae6e246 + df64ae1 commit 17c4ed3

File tree

4 files changed

+45
-179
lines changed

4 files changed

+45
-179
lines changed

alpha/template/composite/builder.go

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,8 @@ const (
2727
CustomBuilderSchema = "olm.builder.custom"
2828
)
2929

30-
type ContainerConfig struct {
31-
ContainerTool string
32-
BaseImage string
33-
WorkingDir string
34-
}
35-
3630
type BuilderConfig struct {
37-
ContainerCfg ContainerConfig
31+
WorkingDir string
3832
OutputType string
3933
}
4034

@@ -95,13 +89,13 @@ func (bb *BasicBuilder) Build(ctx context.Context, reg image.Registry, dir strin
9589
return fmt.Errorf("error rendering basic template: %v", err)
9690
}
9791

98-
destPath := path.Join(bb.builderCfg.ContainerCfg.WorkingDir, dir, basicConfig.Output)
92+
destPath := path.Join(bb.builderCfg.WorkingDir, dir, basicConfig.Output)
9993

10094
return build(dcfg, destPath, bb.builderCfg.OutputType)
10195
}
10296

10397
func (bb *BasicBuilder) Validate(dir string) error {
104-
return validate(bb.builderCfg.ContainerCfg, dir)
98+
return validate(bb.builderCfg, dir)
10599
}
106100

107101
type SemverBuilder struct {
@@ -157,13 +151,13 @@ func (sb *SemverBuilder) Build(ctx context.Context, reg image.Registry, dir stri
157151
return fmt.Errorf("error rendering semver template: %v", err)
158152
}
159153

160-
destPath := path.Join(sb.builderCfg.ContainerCfg.WorkingDir, dir, semverConfig.Output)
154+
destPath := path.Join(sb.builderCfg.WorkingDir, dir, semverConfig.Output)
161155

162156
return build(dcfg, destPath, sb.builderCfg.OutputType)
163157
}
164158

165159
func (sb *SemverBuilder) Validate(dir string) error {
166-
return validate(sb.builderCfg.ContainerCfg, dir)
160+
return validate(sb.builderCfg, dir)
167161
}
168162

169163
type RawBuilder struct {
@@ -217,13 +211,13 @@ func (rb *RawBuilder) Build(ctx context.Context, _ image.Registry, dir string, t
217211
return fmt.Errorf("error parsing raw input file: %s, %v", rawConfig.Input, err)
218212
}
219213

220-
destPath := path.Join(rb.builderCfg.ContainerCfg.WorkingDir, dir, rawConfig.Output)
214+
destPath := path.Join(rb.builderCfg.WorkingDir, dir, rawConfig.Output)
221215

222216
return build(dcfg, destPath, rb.builderCfg.OutputType)
223217
}
224218

225219
func (rb *RawBuilder) Validate(dir string) error {
226-
return validate(rb.builderCfg.ContainerCfg, dir)
220+
return validate(rb.builderCfg, dir)
227221
}
228222

229223
type CustomBuilder struct {
@@ -284,15 +278,15 @@ func (cb *CustomBuilder) Build(ctx context.Context, reg image.Registry, dir stri
284278
return fmt.Errorf("error parsing custom command output: %s, %v", strings.Join(cmdString, "'"), err)
285279
}
286280

287-
destPath := path.Join(cb.builderCfg.ContainerCfg.WorkingDir, dir, customConfig.Output)
281+
destPath := path.Join(cb.builderCfg.WorkingDir, dir, customConfig.Output)
288282

289283
// custom template should output a valid FBC to STDOUT so we can
290284
// build the FBC just like all the other templates.
291285
return build(dcfg, destPath, cb.builderCfg.OutputType)
292286
}
293287

294288
func (cb *CustomBuilder) Validate(dir string) error {
295-
return validate(cb.builderCfg.ContainerCfg, dir)
289+
return validate(cb.builderCfg, dir)
296290
}
297291

298292
func writeDeclCfg(dcfg declcfg.DeclarativeConfig, w io.Writer, output string) error {
@@ -306,12 +300,12 @@ func writeDeclCfg(dcfg declcfg.DeclarativeConfig, w io.Writer, output string) er
306300
}
307301
}
308302

309-
func validate(containerCfg ContainerConfig, dir string) error {
303+
func validate(builderCfg BuilderConfig, dir string) error {
310304

311-
path := path.Join(containerCfg.WorkingDir, dir)
305+
path := path.Join(builderCfg.WorkingDir, dir)
312306
s, err := os.Stat(path)
313307
if err != nil {
314-
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)
315309
}
316310
if !s.IsDir() {
317311
return fmt.Errorf("%q is not a directory", path)

0 commit comments

Comments
 (0)