forked from konflux-ci/build-definitions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (29 loc) · 729 Bytes
/
main.go
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
package main
import (
"fmt"
"os"
"path"
"strings"
)
func main() {
if len(os.Args) != 2 {
fmt.Fprintf(os.Stderr, "Usage: %s path/to/recipe.yaml\n", os.Args[0])
os.Exit(1)
}
recipePath := os.Args[1]
recipe := expectValue(readRecipe(recipePath))
task := expectValue(loadTask(recipe.Base))
taDir := path.Dir(recipePath)
taTaskPath := path.Join(taDir, path.Base(path.Dir(taDir))+".yaml")
if _, err := os.Stat(taTaskPath); err == nil {
existing := expectValue(readTask(taTaskPath))
for _, step := range existing.Spec.Steps {
if strings.Contains(step.Image, "/build-trusted-artifacts:") {
image = step.Image
break
}
}
}
expect(perform(task, recipe))
expect(writeTask(task, os.Stdout))
}