2020-07-06 22:12:41 +02:00
|
|
|
package client
|
|
|
|
|
2023-04-30 15:18:13 +02:00
|
|
|
import "github.com/goreleaser/goreleaser/pkg/config"
|
2020-07-06 22:12:41 +02:00
|
|
|
|
2022-11-02 19:54:16 +02:00
|
|
|
// RepoFromRef converts a config.RepoRef into a Repo.
|
2020-07-06 22:12:41 +02:00
|
|
|
func RepoFromRef(ref config.RepoRef) Repo {
|
|
|
|
return Repo{
|
2023-04-30 15:18:13 +02:00
|
|
|
Owner: ref.Owner,
|
|
|
|
Name: ref.Name,
|
|
|
|
Branch: ref.Branch,
|
|
|
|
GitURL: ref.Git.URL,
|
|
|
|
GitSSHCommand: ref.Git.SSHCommand,
|
|
|
|
PrivateKey: ref.Git.PrivateKey,
|
2020-07-06 22:12:41 +02:00
|
|
|
}
|
|
|
|
}
|
2022-11-02 19:54:16 +02:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
2023-04-30 15:18:13 +02:00
|
|
|
gitURL, err := apply(ref.Git.URL)
|
|
|
|
if err != nil {
|
|
|
|
return ref, err
|
|
|
|
}
|
|
|
|
privateKey, err := apply(ref.Git.PrivateKey)
|
|
|
|
if err != nil {
|
|
|
|
return ref, err
|
|
|
|
}
|
2022-11-02 19:54:16 +02:00
|
|
|
return config.RepoRef{
|
2023-04-07 03:58:06 +02:00
|
|
|
Owner: owner,
|
|
|
|
Name: name,
|
|
|
|
Token: ref.Token,
|
|
|
|
Branch: branch,
|
|
|
|
PullRequest: ref.PullRequest,
|
2023-04-30 15:18:13 +02:00
|
|
|
Git: config.GitRepoRef{
|
|
|
|
URL: gitURL,
|
|
|
|
PrivateKey: privateKey,
|
|
|
|
SSHCommand: ref.Git.SSHCommand,
|
|
|
|
},
|
2022-11-02 19:54:16 +02:00
|
|
|
}, nil
|
|
|
|
}
|