/
config.go
51 lines (48 loc) · 1.14 KB
/
config.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
package client
import "github.com/goreleaser/goreleaser/pkg/config"
// RepoFromRef converts a config.RepoRef into a Repo.
func RepoFromRef(ref config.RepoRef) Repo {
return Repo{
Owner: ref.Owner,
Name: ref.Name,
Branch: ref.Branch,
GitURL: ref.Git.URL,
GitSSHCommand: ref.Git.SSHCommand,
PrivateKey: ref.Git.PrivateKey,
}
}
// TemplateRef templates a config.RepoFromRef
func TemplateRef(apply func(s string) (string, error), ref config.RepoRef) (config.RepoRef, error) {
name, err := apply(ref.Name)
if err != nil {
return ref, err
}
owner, err := apply(ref.Owner)
if err != nil {
return ref, err
}
branch, err := apply(ref.Branch)
if err != nil {
return ref, err
}
gitURL, err := apply(ref.Git.URL)
if err != nil {
return ref, err
}
privateKey, err := apply(ref.Git.PrivateKey)
if err != nil {
return ref, err
}
return config.RepoRef{
Owner: owner,
Name: name,
Token: ref.Token,
Branch: branch,
PullRequest: ref.PullRequest,
Git: config.GitRepoRef{
URL: gitURL,
PrivateKey: privateKey,
SSHCommand: ref.Git.SSHCommand,
},
}, nil
}