gitops

package
v0.0.0-...-d7890aa Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPath     = "/tmp/gitops/"
	ProjectDataPath = "litmus"
)

Variables

This section is empty.

Functions

func GenerateKeys

func GenerateKeys() (string, string, error)

func PathExists

func PathExists(path string) (bool, error)

PathExists checks for the existence of this path

func SetupGitOps

func SetupGitOps(user GitUser, gitConfig GitConfig) (string, error)

SetupGitOps clones and sets up the repo for git ops and returns the LatestCommit

Types

type GitConfig

type GitConfig struct {
	ProjectID     string
	RepositoryURL string
	LocalPath     string
	RemoteName    string
	Branch        string
	LatestCommit  string
	UserName      *string
	Password      *string
	AuthType      model.AuthType
	Token         *string
	SSHPrivateKey *string
}

GitConfig structure for the GitOps settings

func GetGitOpsConfig

func GetGitOpsConfig(repoData gitops.GitConfigDB) GitConfig

GetGitOpsConfig is used for constructing the GitConfig from dbSchemaGitOps.GitConfigDB

func (GitConfig) GetChanges

func (c GitConfig) GetChanges() (string, map[string]int, error)

GetChanges returns the LatestCommit and list of files changed(since previous LatestCommit) in the project directory mentioned in GitConfig

func (GitConfig) GetLatestCommitHash

func (c GitConfig) GetLatestCommitHash() (string, error)

GetLatestCommitHash returns the latest commit hash in the local repo for the project directory

func (GitConfig) GitCheckout

func (c GitConfig) GitCheckout() error

GitCheckout changes the current active branch to specified branch in GitConfig

func (GitConfig) GitClone

func (c GitConfig) GitClone() (*git.Repository, error)

GitClone clones the repo

func (GitConfig) GitCommit

func (c GitConfig) GitCommit(user GitUser, message string, deleteFile *string) (string, error)

GitCommit saves the changes in the repo and commits them with the message provided

func (GitConfig) GitGetStatus

func (c GitConfig) GitGetStatus() (bool, error)

GitGetStatus executes "git get status --porcelain" for the provided Repository Path, returns true if the repository is clean and false if the repository is dirty

func (GitConfig) GitHardReset

func (c GitConfig) GitHardReset() error

GitHardReset executes "git reset --hard HEAD" in provided Repository Path

func (GitConfig) GitPull

func (c GitConfig) GitPull() error

GitPull updates the repository in provided Path

func (GitConfig) GitPush

func (c GitConfig) GitPush() error

GitPush pushes the current changes to remote set in GitConfig, always needs auth credentials

func (GitConfig) UnsafeGitPull

func (c GitConfig) UnsafeGitPull() error

UnsafeGitPull executes git pull after a hard reset when uncommitted changes are present in repo. Not safe.

type GitMutexLock

type GitMutexLock struct {
	// contains filtered or unexported fields
}

GitMutexLock structure for the Git MutexLock

func NewGitLock

func NewGitLock() GitMutexLock

NewGitLock returns a instance of GitMutexLock

func (*GitMutexLock) Lock

func (g *GitMutexLock) Lock(repo string, branch *string)

Lock acquires a lock on particular project or repo for access

func (*GitMutexLock) Unlock

func (g *GitMutexLock) Unlock(repo string, branch *string)

Unlock releases the lock on particular project or repo

type GitUser

type GitUser struct {
	// contains filtered or unexported fields
}

func GitUserFromContext

func GitUserFromContext(ctx context.Context) GitUser

type Service

type Service interface {
	GitOpsNotificationHandler(ctx context.Context, infra chaos_infrastructure.ChaosInfra, experimentID string) (string, error)
	EnableGitOpsHandler(ctx context.Context, projectID string, config model.GitConfig) (bool, error)
	DisableGitOpsHandler(ctx context.Context, projectID string) (bool, error)
	UpdateGitOpsDetailsHandler(ctx context.Context, projectID string, config model.GitConfig) (bool, error)
	GetGitOpsDetails(ctx context.Context, projectID string) (*model.GitConfigResponse, error)
	UpsertExperimentToGit(ctx context.Context, projectID string, experiment *model.ChaosExperimentRequest) error
	DeleteExperimentFromGit(ctx context.Context, projectID string, experiment *model.ChaosExperimentRequest) error
	GitOpsSyncHandler(singleRun bool)
	SyncDBToGit(ctx context.Context, config GitConfig) error
}

func NewGitOpsService

func NewGitOpsService(gitOpsOperator *gitops.Operator, chaosExperimentService chaosExperimentOps.Service, chaosExperimentOps chaos_experiment.Operator) Service

NewGitOpsService returns a new instance of a gitOpsService

Directories

Path Synopsis
model

Jump to

Keyboard shortcuts

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