-
Notifications
You must be signed in to change notification settings - Fork 288
/
buildmodule.go
64 lines (52 loc) · 2.06 KB
/
buildmodule.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
56
57
58
59
60
61
62
63
64
package dist
import (
"github.com/pkg/errors"
"github.com/buildpacks/pack/internal/style"
)
const AssumedBuildpackAPIVersion = "0.1"
const BuildpacksDir = "/cnb/buildpacks"
const ExtensionsDir = "/cnb/extensions"
type ModuleInfo struct {
ID string `toml:"id,omitempty" json:"id,omitempty" yaml:"id,omitempty"`
Name string `toml:"name,omitempty" json:"name,omitempty" yaml:"name,omitempty"`
Version string `toml:"version,omitempty" json:"version,omitempty" yaml:"version,omitempty"`
Description string `toml:"description,omitempty" json:"description,omitempty" yaml:"description,omitempty"`
Homepage string `toml:"homepage,omitempty" json:"homepage,omitempty" yaml:"homepage,omitempty"`
Keywords []string `toml:"keywords,omitempty" json:"keywords,omitempty" yaml:"keywords,omitempty"`
Licenses []License `toml:"licenses,omitempty" json:"licenses,omitempty" yaml:"licenses,omitempty"`
}
func (b ModuleInfo) FullName() string {
if b.Version != "" {
return b.ID + "@" + b.Version
}
return b.ID
}
func (b ModuleInfo) FullNameWithVersion() (string, error) {
if b.Version == "" {
return b.ID, errors.Errorf("buildpack %s does not have a version defined", style.Symbol(b.ID))
}
return b.ID + "@" + b.Version, nil
}
// Satisfy stringer
func (b ModuleInfo) String() string { return b.FullName() }
// Match compares two buildpacks by ID and Version
func (b ModuleInfo) Match(o ModuleInfo) bool {
return b.ID == o.ID && b.Version == o.Version
}
type License struct {
Type string `toml:"type"`
URI string `toml:"uri"`
}
type Stack struct {
ID string `json:"id" toml:"id"`
Mixins []string `json:"mixins,omitempty" toml:"mixins,omitempty"`
}
type Target struct {
OS string `json:"os" toml:"os"`
Arch string `json:"arch" toml:"arch"`
Distributions []Distribution `json:"distributions,omitempty" toml:"distributions,omitempty"`
}
type Distribution struct {
Name string `json:"name,omitempty" toml:"name,omitempty"`
Versions []string `json:"versions,omitempty" toml:"versions,omitempty"`
}