Help us shape the future of Go! Take the 2026 Go Developer Survey

git

package
v0.6.29 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: Apache-2.0 Imports: 30 Imported by: 12

Documentation

Index

Constants

View Source
const (
	HTTP_URL_PROTOCOL              = "http://"
	HTTPS_URL_PROTOCOL             = "https://"
	BITBUCKET_CLONE_BASE_URL       = "https://bitbucket.org/"
	BITBUCKET_GITOPS_DIR           = "bitbucketGitOps"
	BITBUCKET_REPO_NOT_FOUND_ERROR = "404 Not Found"
	BITBUCKET_COMMIT_TIME_LAYOUT   = "2001-01-01T10:00:00+00:00"
)
View Source
const (
	GIT_WORKING_DIR       = "/tmp/gitops/"
	GetRepoUrlStage       = "Get Repo RedirectionUrl"
	CreateRepoStage       = "Create Repo"
	CloneHttpStage        = "Clone Http"
	CreateReadmeStage     = "Create Readme"
	CloneSshStage         = "Clone Ssh"
	GITLAB_PROVIDER       = "GITLAB"
	GITHUB_PROVIDER       = "GITHUB"
	AZURE_DEVOPS_PROVIDER = "AZURE_DEVOPS"
	BITBUCKET_PROVIDER    = "BITBUCKET_CLOUD"
	GITHUB_API_V3         = "api/v3"
	GITHUB_HOST           = "github.com"
)

Variables

This section is empty.

Functions

func CreateGitlabClient

func CreateGitlabClient(host, token string) (*gitlab.Client, error)

func GetGitConfig

func GetGitConfig(gitOpsConfigReadService config.GitOpsConfigReadService) (*bean.GitConfig, error)

func SanitiseCustomGitRepoURL

func SanitiseCustomGitRepoURL(activeGitOpsConfig apiGitOpsBean.GitOpsConfigDto, gitRepoURL string) (sanitisedGitRepoURL string)

SanitiseCustomGitRepoURL - It will sanitise the user given repository url based on GitOps provider

Case BITBUCKET_PROVIDER:

  • The clone URL format https://<user-name>@bitbucket.org/<workspace-name>/<repo-name>.git
  • Here the <user-name> can differ from user to user. SanitiseCustomGitRepoURL will return the repo url in format : https://bitbucket.org/<workspace-name>/<repo-name>.git

Case AZURE_DEVOPS_PROVIDER:

  • The clone URL format https://<organisation-name>@dev.azure.com/<organisation-name>/<project-name>/_git/<repo-name>
  • Here the <user-name> can differ from user to user. SanitiseCustomGitRepoURL will return the repo url in format : https://dev.azure.com/<organisation-name>/<project-name>/_git/<repo-name>

Types

type ChartConfig

type ChartConfig struct {
	ChartName      string
	ChartLocation  string
	FileName       string //filename
	FileContent    string
	ReleaseMessage string
	ChartRepoName  string
	UserName       string
	UserEmailId    string
}

type DetailedErrorGitOpsConfigActions

type DetailedErrorGitOpsConfigActions struct {
	SuccessfulStages []string         `json:"successfulStages"`
	StageErrorMap    map[string]error `json:"stageErrorMap"`
	ValidatedOn      time.Time        `json:"validatedOn"`
	DeleteRepoFailed bool             `json:"deleteRepoFailed"`
}

type GitAzureClient

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

func NewGitAzureClient

func NewGitAzureClient(token string, host string, project string, logger *zap.SugaredLogger, gitOpsHelper *GitOpsHelper) (GitAzureClient, error)

func (GitAzureClient) CommitValues

func (impl GitAzureClient) CommitValues(config *ChartConfig, gitOpsConfig *bean2.GitOpsConfigDto) (commitHash string, commitTime time.Time, err error)

func (GitAzureClient) CreateReadme

func (impl GitAzureClient) CreateReadme(config *bean2.GitOpsConfigDto) (string, error)

func (GitAzureClient) CreateRepository

func (impl GitAzureClient) CreateRepository(config *bean2.GitOpsConfigDto) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions)

func (GitAzureClient) DeleteRepository

func (impl GitAzureClient) DeleteRepository(config *bean2.GitOpsConfigDto) error

func (GitAzureClient) GetRepoUrl

func (impl GitAzureClient) GetRepoUrl(config *bean2.GitOpsConfigDto) (repoUrl string, err error)

type GitBitbucketClient

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

func NewGitBitbucketClient

func NewGitBitbucketClient(username, token, host string, logger *zap.SugaredLogger, gitOpsHelper *GitOpsHelper) GitBitbucketClient

func (GitBitbucketClient) CommitValues

func (impl GitBitbucketClient) CommitValues(config *ChartConfig, gitOpsConfig *bean2.GitOpsConfigDto) (commitHash string, commitTime time.Time, err error)

func (GitBitbucketClient) CreateReadme

func (impl GitBitbucketClient) CreateReadme(config *bean2.GitOpsConfigDto) (string, error)

func (GitBitbucketClient) CreateRepository

func (impl GitBitbucketClient) CreateRepository(config *bean2.GitOpsConfigDto) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions)

func (GitBitbucketClient) DeleteRepository

func (impl GitBitbucketClient) DeleteRepository(config *bean2.GitOpsConfigDto) error

func (GitBitbucketClient) GetRepoUrl

func (impl GitBitbucketClient) GetRepoUrl(config *bean2.GitOpsConfigDto) (repoUrl string, err error)

type GitFactory

type GitFactory struct {
	Client       GitOpsClient
	GitOpsHelper *GitOpsHelper
	// contains filtered or unexported fields
}

func NewGitFactory

func NewGitFactory(logger *zap.SugaredLogger, gitOpsConfigReadService config.GitOpsConfigReadService) (*GitFactory, error)

func (*GitFactory) GetGitLabGroupPath

func (factory *GitFactory) GetGitLabGroupPath(gitOpsConfig *gitOps.GitOpsConfigDto) (string, error)

func (*GitFactory) NewClientForValidation

func (factory *GitFactory) NewClientForValidation(gitOpsConfig *gitOps.GitOpsConfigDto) (GitOpsClient, *GitOpsHelper, error)

func (*GitFactory) Reload

func (factory *GitFactory) Reload(gitOpsConfigReadService config.GitOpsConfigReadService) error

type GitHubClient

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

func NewGithubClient

func NewGithubClient(host string, token string, org string, logger *zap.SugaredLogger,
	gitOpsHelper *GitOpsHelper) (GitHubClient, error)

func (GitHubClient) CommitValues

func (impl GitHubClient) CommitValues(config *ChartConfig, gitOpsConfig *bean2.GitOpsConfigDto) (commitHash string, commitTime time.Time, err error)

func (GitHubClient) CreateReadme

func (impl GitHubClient) CreateReadme(config *bean2.GitOpsConfigDto) (string, error)

func (GitHubClient) CreateRepository

func (impl GitHubClient) CreateRepository(config *bean2.GitOpsConfigDto) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions)

func (GitHubClient) DeleteRepository

func (impl GitHubClient) DeleteRepository(config *bean2.GitOpsConfigDto) error

func (GitHubClient) GetRepoUrl

func (impl GitHubClient) GetRepoUrl(config *bean2.GitOpsConfigDto) (repoUrl string, err error)

type GitLabClient

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

func (GitLabClient) CommitValues

func (impl GitLabClient) CommitValues(config *ChartConfig, gitOpsConfig *bean2.GitOpsConfigDto) (commitHash string, commitTime time.Time, err error)

func (GitLabClient) CreateReadme

func (impl GitLabClient) CreateReadme(config *bean2.GitOpsConfigDto) (string, error)

func (GitLabClient) CreateRepository

func (impl GitLabClient) CreateRepository(config *bean2.GitOpsConfigDto) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions)

func (GitLabClient) DeleteProject

func (impl GitLabClient) DeleteProject(projectName string) (err error)

func (GitLabClient) DeleteRepository

func (impl GitLabClient) DeleteRepository(config *bean2.GitOpsConfigDto) error

func (GitLabClient) GetRepoUrl

func (impl GitLabClient) GetRepoUrl(config *bean2.GitOpsConfigDto) (repoUrl string, err error)

type GitOperationService

type GitOperationService interface {
	CreateGitRepositoryForApp(gitOpsRepoName string, userId int32) (chartGitAttribute *commonBean.ChartGitAttribute, err error)
	CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) error
	GitPull(clonedDir string, repoUrl string, appStoreName string) error

	CommitValues(chartGitAttr *ChartConfig) (commitHash string, commitTime time.Time, err error)
	CommitRequirementsAndValues(appStoreName, repoUrl string, requirementsConfig *ChartConfig,
		valuesConfig *ChartConfig) (gitHash string, err error)
	CommitAndPushAllChanges(clonedDir, commitMsg, userName, userEmailId string) (commitHash string, err error)
	PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version,
		tempReferenceTemplateDir string, repoUrl string, userId int32) (err error)
	PushChartToGitOpsRepoForHelmApp(PushChartToGitRequest *bean.PushChartToGitRequestDTO,
		requirementsConfig *ChartConfig, valuesConfig *ChartConfig) (*commonBean.ChartGitAttribute, string, error)

	CreateRepository(dto *apiBean.GitOpsConfigDto, userId int32) (string, bool, error)
	GetRepoUrlByRepoName(repoName string) (string, error)

	GetClonedDir(chartDir, repoUrl string) (string, error)
	CloneInDir(repoUrl, chartDir string) (string, error)
	ReloadGitOpsProvider() error
	UpdateGitHostUrlByProvider(request *apiBean.GitOpsConfigDto) error
}

type GitOperationServiceImpl

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

func NewGitOperationServiceImpl

func NewGitOperationServiceImpl(logger *zap.SugaredLogger, gitFactory *GitFactory,
	gitOpsConfigReadService config.GitOpsConfigReadService,
	chartTemplateService util.ChartTemplateService) *GitOperationServiceImpl

func (*GitOperationServiceImpl) CloneInDir

func (impl *GitOperationServiceImpl) CloneInDir(repoUrl, chartDir string) (string, error)

func (*GitOperationServiceImpl) CommitAndPushAllChanges

func (impl *GitOperationServiceImpl) CommitAndPushAllChanges(clonedDir, commitMsg, userName, userEmailId string) (commitHash string, err error)

func (*GitOperationServiceImpl) CommitRequirementsAndValues

func (impl *GitOperationServiceImpl) CommitRequirementsAndValues(appStoreName, repoUrl string, requirementsConfig *ChartConfig, valuesConfig *ChartConfig) (gitHash string, err error)

func (*GitOperationServiceImpl) CommitValues

func (impl *GitOperationServiceImpl) CommitValues(chartGitAttr *ChartConfig) (commitHash string, commitTime time.Time, err error)

func (*GitOperationServiceImpl) CreateGitRepositoryForApp

func (impl *GitOperationServiceImpl) CreateGitRepositoryForApp(gitOpsRepoName string, userId int32) (chartGitAttribute *commonBean.ChartGitAttribute, err error)

func (*GitOperationServiceImpl) CreateReadmeInGitRepo

func (impl *GitOperationServiceImpl) CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) error

func (*GitOperationServiceImpl) CreateRepository

func (impl *GitOperationServiceImpl) CreateRepository(dto *apiBean.GitOpsConfigDto, userId int32) (string, bool, error)

func (*GitOperationServiceImpl) GetClonedDir

func (impl *GitOperationServiceImpl) GetClonedDir(chartDir, repoUrl string) (string, error)

func (*GitOperationServiceImpl) GetRepoUrlByRepoName

func (impl *GitOperationServiceImpl) GetRepoUrlByRepoName(repoName string) (string, error)

func (*GitOperationServiceImpl) GitPull

func (impl *GitOperationServiceImpl) GitPull(clonedDir string, repoUrl string, appStoreName string) error

func (*GitOperationServiceImpl) PushChartToGitOpsRepoForHelmApp

func (impl *GitOperationServiceImpl) PushChartToGitOpsRepoForHelmApp(PushChartToGitRequest *bean.PushChartToGitRequestDTO, requirementsConfig *ChartConfig, valuesConfig *ChartConfig) (*commonBean.ChartGitAttribute, string, error)

TODO refactoring: Make a common method for both PushChartToGitRepo and PushChartToGitOpsRepoForHelmApp PushChartToGitOpsRepoForHelmApp pushes built chart to GitOps repo (Specific implementation for Helm Apps)

func (*GitOperationServiceImpl) PushChartToGitRepo

func (impl *GitOperationServiceImpl) PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version,
	tempReferenceTemplateDir string, repoUrl string, userId int32) (err error)

func (*GitOperationServiceImpl) ReloadGitOpsProvider

func (impl *GitOperationServiceImpl) ReloadGitOpsProvider() error

func (*GitOperationServiceImpl) UpdateGitHostUrlByProvider

func (impl *GitOperationServiceImpl) UpdateGitHostUrlByProvider(request *apiBean.GitOpsConfigDto) error

type GitOpsClient

type GitOpsClient interface {
	CreateRepository(config *gitOps.GitOpsConfigDto) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions)
	CommitValues(config *ChartConfig, gitOpsConfig *gitOps.GitOpsConfigDto) (commitHash string, commitTime time.Time, err error)
	GetRepoUrl(config *gitOps.GitOpsConfigDto) (repoUrl string, err error)
	DeleteRepository(config *gitOps.GitOpsConfigDto) error
	CreateReadme(config *gitOps.GitOpsConfigDto) (string, error)
}

func NewGitLabClient

func NewGitLabClient(config *bean.GitConfig, logger *zap.SugaredLogger, gitOpsHelper *GitOpsHelper) (GitOpsClient, error)

func NewGitOpsClient

func NewGitOpsClient(config *bean.GitConfig, logger *zap.SugaredLogger, gitOpsHelper *GitOpsHelper) (GitOpsClient, error)

type GitOpsHelper

type GitOpsHelper struct {
	Auth *git.BasicAuth
	// contains filtered or unexported fields
}

GitOpsHelper GitOps Helper maintains the auth creds in state and is used by implementation of git client implementations and GitFactory

func NewGitOpsHelperImpl

func NewGitOpsHelperImpl(auth *git.BasicAuth, logger *zap.SugaredLogger) *GitOpsHelper

func (*GitOpsHelper) Clone

func (impl *GitOpsHelper) Clone(url, targetDir string) (clonedDir string, err error)

func (GitOpsHelper) CommitAndPushAllChanges

func (impl GitOpsHelper) CommitAndPushAllChanges(repoRoot, commitMsg, name, emailId string) (commitHash string, err error)

func (*GitOpsHelper) GetCloneDirectory

func (impl *GitOpsHelper) GetCloneDirectory(targetDir string) (clonedDir string)

func (*GitOpsHelper) Pull

func (impl *GitOpsHelper) Pull(repoRoot string) (err error)

func (*GitOpsHelper) SetAuth

func (impl *GitOpsHelper) SetAuth(auth *git.BasicAuth)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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