Documentation
¶
Index ¶
- func CleanURL(inputURL string) (string, error)
- func CopyService(serviceName string, source Source, dest Destination, ...) ([]string, error)
- func CreateClient(token, toURL, repoType string, tlsVerify bool) *scm.Client
- func GitError(msg, url string) error
- func IsGitError(err error) bool
- type Author
- type Destination
- type Repo
- type Repository
- func (r *Repository) Checkout(branch string) error
- func (r *Repository) CheckoutAndCreate(branch string) error
- func (r *Repository) Clone() error
- func (r *Repository) Commit(msg string, author *Author) error
- func (r *Repository) CopyFile(src, dst string) error
- func (r *Repository) DeleteCache() error
- func (r *Repository) DirectoriesUnderPath(path string) ([]os.FileInfo, error)
- func (r *Repository) DisablePush()
- func (r *Repository) GetCommitID() string
- func (r *Repository) GetName() string
- func (r *Repository) GetUniqueEnvironmentFolder() (string, error)
- func (r *Repository) Push(branchName string) error
- func (r *Repository) StageFiles(filenames ...string) error
- func (r *Repository) Walk(base string, cb func(prefix, name string) error) error
- func (r *Repository) WriteFile(src io.Reader, dst string) error
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyService ¶
func CopyService(serviceName string, source Source, dest Destination, sourceEnvironment, destinationEnvironment string) ([]string, error)
CopyService takes the name of a service to copy from a Source to a Destination. Source, Destination implement Walk() and are typically Repository objects.
Only files under /services/[serviceName]/base/config/* are copied to the destination
Returns the list of files that were copied, and possibly an error.
func CreateClient ¶ added in v0.2.1
CreateClient creates and returns a go-scm GitHub client, using the provided oauth2 token.
func GitError ¶
GitError returns an error whereby the user part of the url is removed (e.g. an access token) Accepts the message to use and the url to remove the user part from
func IsGitError ¶
IsGitError performs a cast to see if an error really is of type gitError
Types ¶
type Author ¶
Author represents the details needed to commit and push to Git, including the auth-token to use when pushing upstream.
type Destination ¶
type Destination interface { CopyFile(src, dst string) error WriteFile(src io.Reader, dst string) error }
Destination is implemented by values that can have files written and stored permanently.
type Repo ¶
type Repo interface { Destination Source Clone() error Checkout(branch string) error CheckoutAndCreate(branch string) error DirectoriesUnderPath(path string) ([]os.FileInfo, error) GetUniqueEnvironmentFolder() (string, error) GetCommitID() string StageFiles(filenames ...string) error Commit(msg string, author *Author) error Push(branch string) error DeleteCache() error }
type Repository ¶
type Repository struct { LocalPath string RepoURL string // contains filtered or unexported fields }
func NewRepository ¶
func NewRepository(repoURL, localPath string, tlsVerify bool, debug bool) (*Repository, error)
NewRepository creates and returns a local cache of an upstream repository.
The repoURL should be of the form https://github.com/myorg/myrepo. The path should be a local directory where the contents are cloned to.
func (*Repository) Checkout ¶
func (r *Repository) Checkout(branch string) error
func (*Repository) CheckoutAndCreate ¶
func (r *Repository) CheckoutAndCreate(branch string) error
func (*Repository) Clone ¶
func (r *Repository) Clone() error
func (*Repository) Commit ¶
func (r *Repository) Commit(msg string, author *Author) error
Commit does the git commit -m with the msg & author after first running git config commands for the user.name and user.email these are intentionally *not* global settings because we don't want to touch a user's $HOME/.gitconfig This means the settings only apply inside of our local repository cache.
func (*Repository) CopyFile ¶
func (r *Repository) CopyFile(src, dst string) error
func (*Repository) DeleteCache ¶
func (r *Repository) DeleteCache() error
DeleteCache removes the local clones from the promotion cache.
func (*Repository) DirectoriesUnderPath ¶ added in v0.2.1
func (r *Repository) DirectoriesUnderPath(path string) ([]os.FileInfo, error)
Returns the directory names of those under a certain path (excluding sub-dirs) Returns an error if a directory list attempt errored
func (*Repository) DisablePush ¶ added in v0.2.2
func (r *Repository) DisablePush()
func (*Repository) GetCommitID ¶
func (r *Repository) GetCommitID() string
func (*Repository) GetName ¶
func (r *Repository) GetName() string
func (*Repository) GetUniqueEnvironmentFolder ¶ added in v0.2.1
func (r *Repository) GetUniqueEnvironmentFolder() (string, error)
Returns the single directory under the environments folder for a given repo Returns an error if there was a problem in doing so (including if more than one folder found) string return type for ease of mocking, callers would use .Name() anyway
func (*Repository) Push ¶
func (r *Repository) Push(branchName string) error
Does a git push origin *branch name*
func (*Repository) StageFiles ¶
func (r *Repository) StageFiles(filenames ...string) error
This does the git add command on file(s)