forked from buildpacks/pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metadata.go
55 lines (45 loc) · 1.26 KB
/
metadata.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package builder
const MetadataLabel = "io.buildpacks.builder.metadata"
const StackLabel = "io.buildpacks.stack.metadata"
// TODO: Come up with better name
type StackInfo struct {
ID string `json:"id"`
Mixins []string `json:"mixins"`
}
type Metadata struct {
Description string `json:"description"`
Buildpacks []BuildpackMetadata `json:"buildpacks"`
Groups V1Order `json:"groups"` // deprecated
Stack StackMetadata `json:"stack"`
Lifecycle LifecycleMetadata `json:"lifecycle"`
}
type BuildpackMetadata struct {
BuildpackInfo
Latest bool `json:"latest"` // deprecated
}
type LifecycleMetadata struct {
LifecycleInfo
API LifecycleAPI `json:"api"`
}
type StackMetadata struct {
RunImage RunImageMetadata `json:"runImage" toml:"run-image"`
}
type RunImageMetadata struct {
Image string `json:"image" toml:"image"`
Mirrors []string `json:"mirrors" toml:"mirrors"`
Mixins []string `json:mixins`
}
func processMetadata(md *Metadata) error {
for i, bp := range md.Buildpacks {
var matchingBps []BuildpackInfo
for _, bp2 := range md.Buildpacks {
if bp.ID == bp2.ID {
matchingBps = append(matchingBps, bp.BuildpackInfo)
}
}
if len(matchingBps) == 1 {
md.Buildpacks[i].Latest = true
}
}
return nil
}