-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpackage.go
More file actions
41 lines (34 loc) · 801 Bytes
/
package.go
File metadata and controls
41 lines (34 loc) · 801 Bytes
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
package portal
import (
"fmt"
"time"
)
type Builds struct {
Builds []Build `json:"builds"`
}
type Build struct {
Version string `json:"version"`
Date time.Time `json:"date"`
Hash string `json:"hash"`
Artifacts []Artifact `json:"artifacts"`
Internal bool `json:"internal"`
}
type Artifact struct {
Md5Sum string `json:"md5sum"`
Filename string `json:"filename"`
Name string `json:"name"`
}
func (b *Build) GetBuildForDownload(filename string) (Build, error) {
for _, a := range b.Artifacts {
if a.Filename != filename {
continue
}
// Generate identical build but with only the matching artifact
build := *b
build.Artifacts = []Artifact{
a,
}
return build, nil
}
return Build{}, fmt.Errorf("artifact not found: %s", filename)
}