forked from ribice/glice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
override.go
37 lines (31 loc) · 968 Bytes
/
override.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
package glice
type OverridesLicenseIDMap map[string][]string
type Overrides []*Override
type OverrideMap map[string]*Override
type Override struct {
editor *Editor
Import string `yaml:"import"`
LicenseIDs []string `yaml:"licenses"`
VerifiedBy string `yaml:"verifier"`
LastVerified string `yaml:"verified"`
Notes string `yaml:"notes,omitempty"`
}
type MarshallableOverride Override
func NewOverride(dep *Dependency, ed *Editor) *Override {
return &Override{
Import: dep.Import,
LicenseIDs: []string{dep.LicenseID},
VerifiedBy: ed.ID,
LastVerified: Timestamp()[:10],
Notes: "Your dependency-specific notes go here,\n" +
"e.g. links where you read the license you verified, etc.",
}
}
// ToMap creates a map of Overrides indexed by Dependency Import
func (ors Overrides) ToMap() OverrideMap {
newOrs := make(OverrideMap, len(ors))
for _, or := range ors {
newOrs[or.Import] = or
}
return newOrs
}