-
Notifications
You must be signed in to change notification settings - Fork 58
/
metadata.go
64 lines (53 loc) · 1.15 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
56
57
58
59
60
61
62
63
64
package resource
import "github.com/google/go-github/v66/github"
func metadataFromRelease(release *github.RepositoryRelease, commitSHA string) []MetadataPair {
metadata := []MetadataPair{}
if release.Name != nil {
nameMeta := MetadataPair{
Name: "name",
Value: *release.Name,
}
if release.HTMLURL != nil {
nameMeta.URL = *release.HTMLURL
}
metadata = append(metadata, nameMeta)
}
if release.HTMLURL != nil {
metadata = append(metadata, MetadataPair{
Name: "url",
Value: *release.HTMLURL,
})
}
if release.Body != nil {
metadata = append(metadata, MetadataPair{
Name: "body",
Value: *release.Body,
Markdown: true,
})
}
if release.TagName != nil {
metadata = append(metadata, MetadataPair{
Name: "tag",
Value: *release.TagName,
})
}
if commitSHA != "" {
metadata = append(metadata, MetadataPair{
Name: "commit_sha",
Value: commitSHA,
})
}
if *release.Draft {
metadata = append(metadata, MetadataPair{
Name: "draft",
Value: "true",
})
}
if *release.Prerelease {
metadata = append(metadata, MetadataPair{
Name: "pre-release",
Value: "true",
})
}
return metadata
}