github.com/goreleaser/goreleaser@v1.25.1/internal/client/config.go (about)

     1  package client
     2  
     3  import "github.com/goreleaser/goreleaser/pkg/config"
     4  
     5  // RepoFromRef converts a config.RepoRef into a Repo.
     6  func RepoFromRef(ref config.RepoRef) Repo {
     7  	return Repo{
     8  		Owner:         ref.Owner,
     9  		Name:          ref.Name,
    10  		Branch:        ref.Branch,
    11  		GitURL:        ref.Git.URL,
    12  		GitSSHCommand: ref.Git.SSHCommand,
    13  		PrivateKey:    ref.Git.PrivateKey,
    14  	}
    15  }
    16  
    17  // TemplateRef templates a config.RepoFromRef
    18  func TemplateRef(apply func(s string) (string, error), ref config.RepoRef) (config.RepoRef, error) {
    19  	name, err := apply(ref.Name)
    20  	if err != nil {
    21  		return ref, err
    22  	}
    23  	owner, err := apply(ref.Owner)
    24  	if err != nil {
    25  		return ref, err
    26  	}
    27  	branch, err := apply(ref.Branch)
    28  	if err != nil {
    29  		return ref, err
    30  	}
    31  	gitURL, err := apply(ref.Git.URL)
    32  	if err != nil {
    33  		return ref, err
    34  	}
    35  	privateKey, err := apply(ref.Git.PrivateKey)
    36  	if err != nil {
    37  		return ref, err
    38  	}
    39  	return config.RepoRef{
    40  		Owner:       owner,
    41  		Name:        name,
    42  		Token:       ref.Token,
    43  		Branch:      branch,
    44  		PullRequest: ref.PullRequest,
    45  		Git: config.GitRepoRef{
    46  			URL:        gitURL,
    47  			PrivateKey: privateKey,
    48  			SSHCommand: ref.Git.SSHCommand,
    49  		},
    50  	}, nil
    51  }