common

package
v0.0.0-...-a5d79d0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const CannotAddResourceErrorMsg = "Could not add resource"
View Source
const CannotCheckOutBranchErrorMsg = "Could not check out branch"
View Source
const CannotUpdateResourceErrorMsg = "Could not update resource"
View Source
const ConfigurationServiceName = "configuration-service"
View Source
const GitError = "exit status 128"
View Source
const GitURLNotFound = "not found"
View Source
const HostNotFound = "host"
View Source
const InternalErrorErrMsg = "Internal server error"
View Source
const InvalidUpstreamTokenErrorMsg = "Invalid git token"
View Source
const ProjectDoesNotExistErrorMsg = "Project does not exist"
View Source
const RepositoryNotFoundErrorMsg = "Upstream repository not found"
View Source
const ServiceDoesNotExistErrorMsg = "Service does not exist"
View Source
const StageDoesNotExistErrorMsg = "Stage does not exist"
View Source
const WrongToken = "access token"

Variables

This section is empty.

Functions

func CheckoutBranch

func CheckoutBranch(project string, branch string, disableUpstreamSync bool) error

CheckoutBranch checks out the given branch

func CloneRepo

func CloneRepo(project string, credentials apimodels.GitAuthCredentials) (bool, error)

CloneRepo clones an upstream repository into a local folder "project" and returns whether the Git repo is already initialized.

func ConfigureGitUser

func ConfigureGitUser(project string) error

ConfigureGitUser sets the properties user.name and user.email needed for interacting with git in the given project's git repository

func CreateBranch

func CreateBranch(project string, branch string, sourceBranch string) error

CreateBranch creates a new branch

func DeleteFile

func DeleteFile(path string) error

DeleteFile deletes a file

func FileExists

func FileExists(path string) bool

FileExists checks whether a file is available or not

func GetBranches

func GetBranches(project string) ([]string, error)

GetBranches returns a list of branches within the project

func GetCredentials

func GetCredentials(project string) (*apimodels.GitAuthCredentials, error)

GetCredentials returns the git upstream credentials for a given project (stored as a secret), if available

func GetCurrentVersion

func GetCurrentVersion(project string) (string, error)

GetCurrentVersion gets the latest version (i.e. commit hash) of the currently checked out branch

func GetDefaultBranch

func GetDefaultBranch(project string) (string, error)

GetDefaultBranch returns the name of the default branch of the repo

func GetPaginatedResources

func GetPaginatedResources(dir string, pageSize *int64, nextPageKey *string) *models.Resources

GetPaginatedResources returns a paginates resources set

func GetResourceMetadata

func GetResourceMetadata(project string) *models.Version

GetResourceMetadata godoc

func Lock

func Lock()

Lock locks the mutex

func LockProject

func LockProject(project string)

LockProject

func ProjectExists

func ProjectExists(project string) bool

ProjectExists checks if a project exists

func Reset

func Reset(project string) error

Reset resets the current branch to the latest commit

func ServiceExists

func ServiceExists(project string, stage string, service string, disableUpstreamSync bool) bool

ServiceExists checks if a service exists in a given stage of a project

func StageAndCommitAll

func StageAndCommitAll(project string, message string, withPull bool) error

StageAndCommitAll stages all current changes and commits them to the current branch

func StageExists

func StageExists(project string, stage string, disableUpstreamSync bool) bool

StageExists checks if a stage in a given project exists

func Unlock

func Unlock()

Unlock unlocks the mutex

func UnlockProject

func UnlockProject(project string)

func UpdateOrCreateOrigin

func UpdateOrCreateOrigin(project string) error

UpdateOrCreateOrigin tries to update the remote origin. If no remote origin exists, it will add one

func WriteBase64EncodedFile

func WriteBase64EncodedFile(path string, content string) error

WriteBase64EncodedFile writes a file using the base64 encoded input

func WriteFile

func WriteFile(path string, content []byte) error

WriteFile writes to a file in the filesystem if it exists, it is overwritten

Types

type CommandExecutor

type CommandExecutor interface {
	ExecuteCommand(command string, args []string, directory string) (string, error)
}

type CredentialReader

type CredentialReader interface {
	GetCredentials(project string) (*apimodels.GitAuthCredentials, error)
}

type Git

type Git struct {
	Executor         CommandExecutor
	CredentialReader CredentialReader
}

func NewGit

func (*Git) CheckoutBranch

func (g *Git) CheckoutBranch(project string, branch string, disableUpstreamSync bool) error

CheckoutBranch checks out the given branch

func (*Git) CloneRepo

func (g *Git) CloneRepo(project string, credentials *apimodels.GitAuthCredentials) (bool, error)

CloneRepo clones an upstream repository into a local folder "project" and returns whether the Git repo is already initialized.

func (*Git) ConfigureGitUser

func (g *Git) ConfigureGitUser(project string) error

func (*Git) CreateBranch

func (g *Git) CreateBranch(project string, branch string, sourceBranch string) error

CreateBranch creates a new branch

func (*Git) GetBranches

func (g *Git) GetBranches(project string) ([]string, error)

GetBranches returns a list of branches within the project

func (*Git) GetCurrentVersion

func (g *Git) GetCurrentVersion(project string) (string, error)

GetCurrentVersion gets the latest version (i.e. commit hash) of the currently checked out branch

func (*Git) GetDefaultBranch

func (g *Git) GetDefaultBranch(project string) (string, error)

GetDefaultBranch returns the name of the default branch of the repo

func (*Git) Reset

func (g *Git) Reset(project string) error

func (*Git) StageAndCommitAll

func (g *Git) StageAndCommitAll(project string, message string, withPull bool) error

StageAndCommitAll stages all current changes and commits them to the current branch

func (*Git) UpdateOrCreateOrigin

func (g *Git) UpdateOrCreateOrigin(project string) error

UpdateOrCreateOrigin tries to update the remote origin. If no remote origin exists, it will add one

type K8sCredentialReader

type K8sCredentialReader struct{}

func (K8sCredentialReader) GetCredentials

func (K8sCredentialReader) GetCredentials(project string) (*apimodels.GitAuthCredentials, error)

type KeptnUtilsCommandExecutor

type KeptnUtilsCommandExecutor struct{}

func (KeptnUtilsCommandExecutor) ExecuteCommand

func (KeptnUtilsCommandExecutor) ExecuteCommand(command string, args []string, directory string) (string, error)

type PaginationResult

type PaginationResult struct {
	// Pointer to next page, base64 encoded
	NewNextPageKey string
	NextPageKey    int64
	// Size of returned page
	PageSize float64

	// End Index
	EndIndex int64
}

PaginationResult contains pagination info

func Paginate

func Paginate(totalCount int, pageSize *int64, nextPageKeyString *string) *PaginationResult

Paginate paginates an array

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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