scmauth

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package scmauth provides SCM authentication methods based on secret files

Index

Constants

View Source
const (
	CACertName   = "ca.crt"
	CACertConfig = `# SSL cert
[http]
   sslCAInfo = %[1]s
`
)
View Source
const (
	DefaultUsername      = "builder"
	UsernamePasswordName = "password"
	UsernameSecret       = "username"
	PasswordSecret       = "password"
	TokenSecret          = "token"

	UserPassGitConfig = `# credential git config
[credential]
   helper = store --file=%s
`
)
View Source
const GitConfigName = ".gitconfig"
View Source
const SSHPrivateKeyMethodName = "ssh-privatekey"

Variables

This section is empty.

Functions

func NewDefaultSCMContext added in v1.1.1

func NewDefaultSCMContext() *defaultSCMContext

Types

type CACert added in v1.0.6

type CACert struct {
	SourceURL url.URL
}

CACert implements SCMAuth interface for using a custom certificate authority

func (CACert) Handles added in v1.0.6

func (_ CACert) Handles(name string) bool

Handles returns true if the secret is a CA certificate

func (CACert) Name added in v1.0.6

func (_ CACert) Name() string

Name returns the name of this auth method.

func (CACert) Setup added in v1.0.6

func (s CACert) Setup(baseDir string, context SCMAuthContext) error

Setup creates a .gitconfig fragment that points to the given ca.crt

type GitConfig added in v1.0.6

type GitConfig struct{}

GitConfig implements SCMAuth interface for using a custom .gitconfig file

func (GitConfig) Handles added in v1.0.6

func (_ GitConfig) Handles(name string) bool

Handles returns true if the secret file is a gitconfig

func (GitConfig) Name added in v1.0.6

func (_ GitConfig) Name() string

Name returns the name of this auth method.

func (GitConfig) Setup added in v1.0.6

func (_ GitConfig) Setup(baseDir string, context SCMAuthContext) error

Setup adds the secret .gitconfig as an include to the .gitconfig file to be used in the build

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 added in v1.1.1

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 SCMAuths added in v1.1.1

type SCMAuths []SCMAuth

func GitAuths added in v1.1.1

func GitAuths(sourceURL *url.URL) SCMAuths

func (SCMAuths) Setup added in v1.1.1

func (a SCMAuths) Setup(secretsDir string) (env []string, overrideURL *url.URL, err error)

type SSHPrivateKey

type SSHPrivateKey struct{}

SSHPrivateKey implements SCMAuth interface for using SSH private keys.

func (SSHPrivateKey) Handles added in v1.0.6

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 added in v1.0.6

type UsernamePassword struct {
	SourceURL url.URL
}

UsernamePassword implements SCMAuth interface for using Username and Password credentials

func (UsernamePassword) Handles added in v1.0.6

func (_ UsernamePassword) Handles(name string) bool

Handles returns true if a username, password or token secret is present

func (UsernamePassword) Name added in v1.0.6

func (_ UsernamePassword) Name() string

Name returns the name of this auth method.

func (UsernamePassword) Setup added in v1.0.6

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL