-
Notifications
You must be signed in to change notification settings - Fork 4
/
info.go
90 lines (78 loc) · 2.94 KB
/
info.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package project
import (
"strings"
"github.com/samber/lo"
"projectforge.dev/projectforge/app/util"
)
const DefaultGoVersion = "1.21"
type Doc struct {
Name string `json:"name"`
Provider string `json:"provider,omitempty"`
URL string `json:"url"`
}
type Docs []*Doc
type ModuleDef struct {
Key string `json:"key"`
Path string `json:"path"`
URL string `json:"url"`
}
type ModuleDefs []*ModuleDef
type Info struct {
Org string `json:"org,omitempty"`
AuthorID string `json:"authorID,omitempty"`
AuthorName string `json:"authorName,omitempty"`
AuthorEmail string `json:"authorEmail,omitempty"`
Team string `json:"team,omitempty"`
License string `json:"license,omitempty"`
Homepage string `json:"homepage,omitempty"`
Sourcecode string `json:"sourcecode,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
CI string `json:"ci,omitempty"`
Homebrew string `json:"homebrew,omitempty"`
Bundle string `json:"bundle,omitempty"`
SigningIdentity string `json:"signingIdentity,omitempty"`
NotarizeEmail string `json:"notarizeEmail,omitempty"`
DatabaseEngine string `json:"databaseEngine,omitempty"`
Slack string `json:"slack,omitempty"`
Channels []string `json:"channels,omitempty"`
JavaPackage string `json:"javaPackage,omitempty"`
GoVersion string `json:"goVersion,omitempty"`
GoBinary string `json:"goBinary,omitempty"`
ConfigVars util.KeyTypeDescs `json:"configVars,omitempty"`
ExtraFiles []string `json:"extraFiles,omitempty"`
Deployments []string `json:"deployments,omitempty"`
EnvVars []string `json:"envVars,omitempty"`
Docs Docs `json:"docs,omitempty"`
ModuleDefs ModuleDefs `json:"moduleDefs,omitempty"`
}
func (i *Info) SigningIdentityTrimmed() string {
if strings.Contains(i.SigningIdentity, "(") && strings.Contains(i.SigningIdentity, ")") {
return i.SigningIdentity[strings.LastIndex(i.SigningIdentity, "(")+1 : strings.LastIndex(i.SigningIdentity, ")")]
}
return i.SigningIdentity
}
func (i *Info) AuthorIDSafe() string {
if i.AuthorID == "" {
if !strings.Contains(i.AuthorEmail, "@") {
return "no_owner"
}
return i.AuthorEmail
}
spl := util.StringSplitAndTrim(i.AuthorID, " ")
ret := make([]string, 0, len(spl))
lo.ForEach(spl, func(x string, _ int) {
x = strings.ReplaceAll(x, ",", "")
if !strings.HasPrefix(x, "@") {
x = "@" + x
}
ret = append(ret, x)
})
return strings.Join(ret, " ")
}
func (i *Info) NotarizationEmail() string {
if i.NotarizeEmail != "" {
return i.NotarizeEmail
}
return i.AuthorEmail
}