Documentation ¶
Overview ¶
Package scmauth provides SCM authentication methods based on secret files
Index ¶
Constants ¶
const ( CACertName = "ca.crt" CACertConfig = `# SSL cert [http] sslCAInfo = %[1]s ` )
const ( DefaultUsername = "builder" UsernamePasswordName = "password" UsernameSecret = "username" PasswordSecret = "password" TokenSecret = "token" UserPassGitConfig = `# credential git config [credential] helper = store --file=%s ` )
const GitConfigName = ".gitconfig"
const SSHPrivateKeyMethodName = "ssh-privatekey"
Variables ¶
This section is empty.
Functions ¶
func NewDefaultSCMContext ¶
func NewDefaultSCMContext() *defaultSCMContext
Types ¶
type CACert ¶
CACert implements SCMAuth interface for using a custom certificate authority
type GitConfig ¶
type GitConfig struct{}
GitConfig implements SCMAuth interface for using a custom .gitconfig file
type SCMAuth ¶
type SCMAuth interface { // Name is the name of the authentication method for use in log and error messages Name() string // Handles returns true if this authentication method handles a file with the given name Handles(name string) bool // Setup lays down the required files for this authentication method to work. // Returns the the source URL stripped of credentials. Setup(baseDir string, context SCMAuthContext) error }
SCMAuth is an interface implemented by different authentication providers which are responsible for setting up the credentials to be used when accessing private repository.
type SCMAuthContext ¶
type SCMAuthContext interface { // Get returns the value of a variable if previously set on the context and // a boolean indicating whether the variable is set or not Get(name string) (string, bool) // Set will set the value of a variable. If a variable has already been set // and the value sent is different, then an error will be returned. Set(name, value string) error // SetOverrideURL will set an override URL. If a value has already been set // and the URL passed is different, then an error will be returned. SetOverrideURL(u *url.URL) error }
SCMAuthContext keeps track of variables needed for SCM authentication. The variables will then be used to invoke git
type SSHPrivateKey ¶
type SSHPrivateKey struct{}
SSHPrivateKey implements SCMAuth interface for using SSH private keys.
func (SSHPrivateKey) Handles ¶
func (_ SSHPrivateKey) Handles(name string) bool
Handles returns true if the file is an SSH private key
func (SSHPrivateKey) Name ¶
func (_ SSHPrivateKey) Name() string
Name returns the name of this auth method.
func (SSHPrivateKey) Setup ¶
func (_ SSHPrivateKey) Setup(baseDir string, context SCMAuthContext) error
Setup creates a wrapper script for SSH command to be able to use the provided SSH key while accessing private repository.
type UsernamePassword ¶
UsernamePassword implements SCMAuth interface for using Username and Password credentials
func (UsernamePassword) Handles ¶
func (_ UsernamePassword) Handles(name string) bool
Handles returns true if a username, password or token secret is present
func (UsernamePassword) Name ¶
func (_ UsernamePassword) Name() string
Name returns the name of this auth method.
func (UsernamePassword) Setup ¶
func (u UsernamePassword) Setup(baseDir string, context SCMAuthContext) error
Setup creates a gitconfig fragment that includes a substitution URL with the username/password included in the URL. Returns source URL stripped of username/password credentials.