util

package
v0.6.20 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: Apache-2.0 Imports: 75 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GIT_WORKING_DIR       = "/tmp/gitops/"
	GetRepoUrlStage       = "Get Repo Url"
	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"
)
View Source
const (
	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 AppsGroup = "apps"
View Source
const BatchGroup = "batch"
View Source
const BearerToken = "bearer_token"
View Source
const Branch_Master = "master"
View Source
const CertData = "cert_data"
View Source
const CertificateAuthorityData = "cert_auth_data"
View Source
const DEFAULT_CLUSTER = "default_cluster"
View Source
const GIT_ASK_PASS = "/git-ask-pass.sh"
View Source
const K8sClusterResourceApiVersionKey = "apiVersion"
View Source
const K8sClusterResourceCellKey = "cells"
View Source
const K8sClusterResourceColumnDefinitionKey = "columnDefinitions"
View Source
const K8sClusterResourceCreationTimestampKey = "creationTimestamp"
View Source
const K8sClusterResourceCronJobKind = "CronJob"
View Source
const K8sClusterResourceKindKey = "kind"
View Source
const K8sClusterResourceMetadataKey = "metadata"
View Source
const K8sClusterResourceMetadataNameKey = "name"
View Source
const K8sClusterResourceNameKey = "name"
View Source
const K8sClusterResourceNamespaceKey = "namespace"
View Source
const K8sClusterResourceObjectKey = "object"
View Source
const K8sClusterResourceOwnerReferenceKey = "ownerReferences"
View Source
const K8sClusterResourcePriorityKey = "priority"
View Source
const K8sClusterResourceReplicationControllerKind = "ReplicationController"
View Source
const K8sClusterResourceRolloutGroup = "argoproj.io"
View Source
const K8sClusterResourceRolloutKind = "Rollout"
View Source
const K8sClusterResourceRowsKey = "rows"
View Source
const PIPELINE_DEPLOYMENT_TYPE_ACD string = "argo_cd"
View Source
const PIPELINE_DEPLOYMENT_TYPE_HELM string = "helm"
View Source
const PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD string = "manifest_download"
View Source
const RestartingNotSupported = "restarting not supported"
View Source
const Running = "Running"
View Source
const TlsKey = "tls_key"
View Source
const V1VERSION = "v1"

Variables

Functions

func CompareUnOrdered

func CompareUnOrdered(a, b []int) bool

func CreateEcrRepo

func CreateEcrRepo(repoName string, reg string, accessKey string, secretKey string) error

FIXME: this code is temp

func GetLogger deprecated

func GetLogger() *zap.SugaredLogger

Deprecated: instead calling this method inject logger from wire

func InitLogger added in v0.4.1

func InitLogger() (*zap.SugaredLogger, error)

func IntValidator

func IntValidator() (*validator.Validate, error)

func IsAcdApp added in v0.5.3

func IsAcdApp(deploymentAppType string) bool

func IsErrNoRows

func IsErrNoRows(err error) bool

func IsHelmApp added in v0.5.3

func IsHelmApp(deploymentAppType string) bool

func IsManifestDownload added in v0.6.17

func IsManifestDownload(deploymentAppType string) bool

func IsValidUrl added in v0.2.33

func IsValidUrl(input string) bool

func NewHttpClient

func NewHttpClient() *http.Client

func NewSugardLogger

func NewSugardLogger() (*zap.SugaredLogger, error)

func OverrideK8sHttpClientWithTracer added in v0.6.12

func OverrideK8sHttpClientWithTracer(restConfig *rest.Config) (*http.Client, error)

func TopoSort

func TopoSort(graph map[int][]int) []int

func ValidateCheckoutPath

func ValidateCheckoutPath(fl validator.FieldLevel) bool

func ValidateName

func ValidateName(fl validator.FieldLevel) bool

func ValidateNameSpace added in v0.6.0

func ValidateNameSpace(fl validator.FieldLevel) bool

Types

type ApiError

type ApiError struct {
	HttpStatusCode    int         `json:"-"`
	Code              string      `json:"code,omitempty"`
	InternalMessage   string      `json:"internalMessage,omitempty"`
	UserMessage       interface{} `json:"userMessage,omitempty"`
	UserDetailMessage string      `json:"userDetailMessage,omitempty"`
}

func (*ApiError) Error

func (e *ApiError) Error() string

func (*ApiError) ErrorfInternal

func (e *ApiError) ErrorfInternal(format string, a ...interface{}) error

default internal will be set

func (ApiError) ErrorfUser

func (e ApiError) ErrorfUser(format string, a ...interface{}) error

default user message will be set

type BadRequestError added in v0.3.6

type BadRequestError struct {
	E error
}

func (*BadRequestError) Error added in v0.3.6

func (err *BadRequestError) Error() string

type ChartConfig

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

type ChartCreateRequest added in v0.6.17

type ChartCreateRequest struct {
	ChartMetaData *chart.Metadata
	ChartPath     string
}

type ChartCreateResponse added in v0.6.17

type ChartCreateResponse struct {
	BuiltChartPath string
	// contains filtered or unexported fields
}

type ChartDeploymentService added in v0.6.17

type ChartDeploymentService interface {
	RegisterInArgo(chartGitAttribute *ChartGitAttribute, ctx context.Context) error
}

type ChartDeploymentServiceImpl added in v0.6.17

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

func NewChartDeploymentServiceImpl added in v0.6.17

func NewChartDeploymentServiceImpl(logger *zap.SugaredLogger, repositoryService repository4.ServiceClient) *ChartDeploymentServiceImpl

func (*ChartDeploymentServiceImpl) RegisterInArgo added in v0.6.17

func (impl *ChartDeploymentServiceImpl) RegisterInArgo(chartGitAttribute *ChartGitAttribute, ctx context.Context) error

type ChartGitAttribute

type ChartGitAttribute struct {
	RepoUrl, ChartLocation string
}

type ChartTemplateService

type ChartTemplateService interface {
	FetchValuesFromReferenceChart(chartMetaData *chart.Metadata, refChartLocation string, templateName string, userId int32, pipelineStrategyPath string) (*ChartValues, *ChartGitAttribute, error)
	GetChartVersion(location string) (string, error)
	CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, *ChartGitAttribute, error)
	BuildChart(ctx context.Context, chartMetaData *chart.Metadata, referenceTemplatePath string) (string, error)
	BuildChartProxyForHelmApps(chartCreateRequest *ChartCreateRequest) (chartCreateResponse *ChartCreateResponse, err error)
	GitPull(clonedDir string, repoUrl string, appStoreName string) error
	GetDir() string
	CleanDir(dir string)
	GetUserEmailIdAndNameForGitOpsCommit(userId int32) (emailId, name string)
	GetGitOpsRepoName(appName string) string
	GetGitOpsRepoNameFromUrl(gitRepoUrl string) string
	CreateGitRepositoryForApp(gitOpsRepoName, baseTemplateName, version string, userId int32) (chartGitAttribute *ChartGitAttribute, err error)
	PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version, tempReferenceTemplateDir string, repoUrl string, userId int32) (err error)
	GetByteArrayRefChart(chartMetaData *chart.Metadata, referenceTemplatePath string) ([]byte, error)
	CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) error
	UpdateGitRepoUrlInCharts(appId int, chartGitAttribute *ChartGitAttribute, userId int32) error
	CreateAndPushToGitChartProxy(appStoreName, tmpChartLocation string, envName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (chartGitAttribute *ChartGitAttribute, err error)
	LoadChartInBytes(ChartPath string, deleteChart bool) ([]byte, error)
}

type ChartTemplateServiceImpl

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

func NewChartTemplateServiceImpl

func NewChartTemplateServiceImpl(logger *zap.SugaredLogger,
	chartWorkingDir ChartWorkingDir,
	client *http.Client,
	gitFactory *GitFactory, globalEnvVariables *util.GlobalEnvVariables,
	gitOpsConfigRepository repository.GitOpsConfigRepository,
	userRepository repository2.UserRepository, chartRepository chartRepoRepository.ChartRepository) *ChartTemplateServiceImpl

func (ChartTemplateServiceImpl) BuildChart added in v0.6.12

func (impl ChartTemplateServiceImpl) BuildChart(ctx context.Context, chartMetaData *chart.Metadata, referenceTemplatePath string) (string, error)

TODO: convert BuildChart and BuildChartProxyForHelmApps into one function

func (ChartTemplateServiceImpl) BuildChartProxyForHelmApps added in v0.6.17

func (impl ChartTemplateServiceImpl) BuildChartProxyForHelmApps(chartCreateRequest *ChartCreateRequest) (*ChartCreateResponse, error)

func (ChartTemplateServiceImpl) CleanDir

func (impl ChartTemplateServiceImpl) CleanDir(dir string)

func (ChartTemplateServiceImpl) CreateAndPushToGitChartProxy added in v0.6.17

func (impl ChartTemplateServiceImpl) CreateAndPushToGitChartProxy(appStoreName, tmpChartLocation string, envName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (chartGitAttribute *ChartGitAttribute, err error)

func (ChartTemplateServiceImpl) CreateChartProxy

func (impl ChartTemplateServiceImpl) CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, *ChartGitAttribute, error)

func (ChartTemplateServiceImpl) CreateGitRepositoryForApp added in v0.4.5

func (impl ChartTemplateServiceImpl) CreateGitRepositoryForApp(gitOpsRepoName, baseTemplateName, version string, userId int32) (chartGitAttribute *ChartGitAttribute, err error)

func (ChartTemplateServiceImpl) CreateReadmeInGitRepo added in v0.4.21

func (impl ChartTemplateServiceImpl) CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) error

func (ChartTemplateServiceImpl) FetchValuesFromReferenceChart added in v0.4.5

func (impl ChartTemplateServiceImpl) FetchValuesFromReferenceChart(chartMetaData *chart.Metadata, refChartLocation string, templateName string, userId int32, pipelineStrategyPath string) (*ChartValues, *ChartGitAttribute, error)

func (ChartTemplateServiceImpl) GetByteArrayRefChart added in v0.4.14

func (impl ChartTemplateServiceImpl) GetByteArrayRefChart(chartMetaData *chart.Metadata, referenceTemplatePath string) ([]byte, error)

GetByteArrayRefChart this method will be used for getting byte array from reference chart to store in db

func (ChartTemplateServiceImpl) GetChartVersion

func (impl ChartTemplateServiceImpl) GetChartVersion(location string) (string, error)

func (ChartTemplateServiceImpl) GetDir added in v0.3.22

func (impl ChartTemplateServiceImpl) GetDir() string

func (ChartTemplateServiceImpl) GetGitOpsRepoName added in v0.3.18

func (impl ChartTemplateServiceImpl) GetGitOpsRepoName(appName string) string

func (ChartTemplateServiceImpl) GetGitOpsRepoNameFromUrl added in v0.3.18

func (impl ChartTemplateServiceImpl) GetGitOpsRepoNameFromUrl(gitRepoUrl string) string

func (*ChartTemplateServiceImpl) GetUserEmailIdAndNameForGitOpsCommit added in v0.4.1

func (impl *ChartTemplateServiceImpl) GetUserEmailIdAndNameForGitOpsCommit(userId int32) (string, string)

func (ChartTemplateServiceImpl) GitPull

func (impl ChartTemplateServiceImpl) GitPull(clonedDir string, repoUrl string, appStoreName string) error

func (ChartTemplateServiceImpl) LoadChartInBytes added in v0.6.17

func (impl ChartTemplateServiceImpl) LoadChartInBytes(ChartPath string, deleteChart bool) ([]byte, error)

func (ChartTemplateServiceImpl) PushChartToGitRepo added in v0.6.12

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

func (ChartTemplateServiceImpl) UpdateGitRepoUrlInCharts added in v0.6.17

func (impl ChartTemplateServiceImpl) UpdateGitRepoUrlInCharts(appId int, chartGitAttribute *ChartGitAttribute, userId int32) error

type ChartValues

type ChartValues struct {
	Values                  string `json:"values"`            //yaml
	AppOverrides            string `json:"appOverrides"`      //json
	EnvOverrides            string `json:"envOverrides"`      //json
	ReleaseOverrides        string `json:"releaseOverrides"`  //json
	PipelineOverrides       string `json:"pipelineOverrides"` //json
	ImageDescriptorTemplate string `json:"-"`
}

type ChartWorkingDir

type ChartWorkingDir string

type ClusterConfig

type ClusterConfig struct {
	ClusterName           string
	Host                  string
	BearerToken           string
	InsecureSkipTLSVerify bool
	KeyData               string
	CertData              string
	CAData                string
}

type ClusterResourceListMap added in v0.6.12

type ClusterResourceListMap struct {
	Headers []string                 `json:"headers"`
	Data    []map[string]interface{} `json:"data"`
}

type DetailedErrorGitOpsConfigActions added in v0.2.27

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

type ForbiddenError added in v0.3.6

type ForbiddenError struct {
	E error
}

func (*ForbiddenError) Error added in v0.3.6

func (err *ForbiddenError) Error() string

type GitAzureClient added in v0.2.11

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

func NewGitAzureClient added in v0.2.11

func NewGitAzureClient(token string, host string, project string, logger *zap.SugaredLogger, gitService GitService,
	gitOpsConfigRepository repository.GitOpsConfigRepository) (GitAzureClient, error)

func (GitAzureClient) CommitValues added in v0.2.11

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

func (GitAzureClient) CreateReadme added in v0.4.21

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

func (GitAzureClient) CreateRepository added in v0.2.11

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

func (GitAzureClient) DeleteRepository added in v0.2.27

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

func (GitAzureClient) GetCommits added in v0.6.4

func (impl GitAzureClient) GetCommits(repoName, projectName string) ([]*GitCommitDto, error)

func (GitAzureClient) GetRepoUrl added in v0.2.11

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

type GitBitbucketClient added in v0.2.33

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

func NewGitBitbucketClient added in v0.2.33

func NewGitBitbucketClient(username, token, host string, logger *zap.SugaredLogger, gitService GitService,
	gitOpsConfigRepository repository.GitOpsConfigRepository) GitBitbucketClient

func (GitBitbucketClient) CommitValues added in v0.2.33

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

func (GitBitbucketClient) CreateReadme added in v0.4.21

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

func (GitBitbucketClient) CreateRepository added in v0.2.33

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

func (GitBitbucketClient) DeleteRepository added in v0.2.33

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

func (GitBitbucketClient) GetCommits added in v0.6.4

func (impl GitBitbucketClient) GetCommits(repoName, projectName string) ([]*GitCommitDto, error)

func (GitBitbucketClient) GetRepoUrl added in v0.2.33

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

type GitCliUtil added in v0.2.11

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

func NewGitCliUtil added in v0.2.11

func NewGitCliUtil(logger *zap.SugaredLogger) *GitCliUtil

func (*GitCliUtil) Checkout added in v0.2.11

func (impl *GitCliUtil) Checkout(rootDir string, branch string) (response, errMsg string, err error)

func (*GitCliUtil) Clone added in v0.2.11

func (impl *GitCliUtil) Clone(rootDir string, remoteUrl string, username string, password string) (response, errMsg string, err error)

func (*GitCliUtil) Fetch added in v0.2.11

func (impl *GitCliUtil) Fetch(rootDir string, username string, password string) (response, errMsg string, err error)

func (*GitCliUtil) Init added in v0.2.11

func (impl *GitCliUtil) Init(rootDir string, remoteUrl string, isBare bool) error

func (*GitCliUtil) ListBranch added in v0.4.21

func (impl *GitCliUtil) ListBranch(rootDir string, username string, password string) (response, errMsg string, err error)

func (*GitCliUtil) Pull added in v0.2.11

func (impl *GitCliUtil) Pull(rootDir string, username string, password string, branch string) (response, errMsg string, err error)

type GitClient

type GitClient interface {
	CreateRepository(config *bean2.GitOpsConfigDto) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions)
	CommitValues(config *ChartConfig, gitOpsConfig *bean2.GitOpsConfigDto) (commitHash string, commitTime time.Time, err error)
	GetRepoUrl(config *bean2.GitOpsConfigDto) (repoUrl string, err error)
	DeleteRepository(config *bean2.GitOpsConfigDto) error
	CreateReadme(config *bean2.GitOpsConfigDto) (string, error)
	GetCommits(repoName, projectName string) ([]*GitCommitDto, error)
}

func NewGitLabClient

func NewGitLabClient(config *GitConfig, logger *zap.SugaredLogger, gitService GitService) (GitClient, error)

func NewGitOpsClient added in v0.2.33

func NewGitOpsClient(config *GitConfig, logger *zap.SugaredLogger, gitService GitService, gitOpsConfigRepository repository.GitOpsConfigRepository) (GitClient, error)

type GitCommitDto added in v0.6.4

type GitCommitDto struct {
	CommitHash string    `json:"commitHash"`
	AuthorName string    `json:"authorName"`
	CommitTime time.Time `json:"commitTime"`
}

type GitConfig

type GitConfig struct {
	GitlabGroupId        string //local
	GitlabGroupPath      string //local
	GitToken             string //not null  // public
	GitUserName          string //not null  // public
	GitWorkingDir        string //working directory for git. might use pvc
	GithubOrganization   string
	GitProvider          string // SUPPORTED VALUES  GITHUB, GITLAB
	GitHost              string
	AzureToken           string
	AzureProject         string
	BitbucketWorkspaceId string
	BitbucketProjectKey  string
}

func GetGitConfig

func GetGitConfig(gitOpsRepository repository.GitOpsConfigRepository) (*GitConfig, error)

type GitFactory

type GitFactory struct {
	Client        GitClient
	GitService    GitService
	GitWorkingDir string
	// contains filtered or unexported fields
}

func NewGitFactory

func NewGitFactory(logger *zap.SugaredLogger, gitOpsRepository repository.GitOpsConfigRepository, gitCliUtil *GitCliUtil) (*GitFactory, error)

func (*GitFactory) GetGitLabGroupPath added in v0.2.29

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

func (*GitFactory) NewClientForValidation added in v0.2.27

func (factory *GitFactory) NewClientForValidation(gitOpsConfig *bean2.GitOpsConfigDto) (GitClient, *GitServiceImpl, error)

func (*GitFactory) Reload

func (factory *GitFactory) Reload() error

type GitHubClient

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

func NewGithubClient

func NewGithubClient(host string, token string, org string, logger *zap.SugaredLogger,
	gitService GitService, gitOpsConfigRepository repository.GitOpsConfigRepository) (GitHubClient, error)

func (GitHubClient) CommitValues

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

func (GitHubClient) CreateReadme added in v0.4.21

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 added in v0.2.27

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

func (GitHubClient) GetCommits added in v0.6.4

func (impl GitHubClient) GetCommits(repoName, projectName string) ([]*GitCommitDto, 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 added in v0.4.21

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 added in v0.2.27

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

func (GitLabClient) GetCommits added in v0.6.4

func (impl GitLabClient) GetCommits(repoName, projectName string) ([]*GitCommitDto, error)

func (GitLabClient) GetRepoUrl

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

type GitService

type GitService interface {
	Clone(url, targetDir string) (clonedDir string, err error)
	CommitAndPushAllChanges(repoRoot, commitMsg, name, emailId string) (commitHash string, err error)
	ForceResetHead(repoRoot string) (err error)
	CommitValues(config *ChartConfig) (commitHash string, err error)

	GetCloneDirectory(targetDir string) (clonedDir string)
	Pull(repoRoot string) (err error)
}

-------------------- go-git integration -------------------

type GitServiceImpl

type GitServiceImpl struct {
	Auth *http.BasicAuth
	// contains filtered or unexported fields
}

func NewGitServiceImpl

func NewGitServiceImpl(config *GitConfig, logger *zap.SugaredLogger, GitCliUtil *GitCliUtil) *GitServiceImpl

func (GitServiceImpl) Clone

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

func (GitServiceImpl) CommitAndPushAllChanges

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

func (GitServiceImpl) CommitValues

func (impl GitServiceImpl) CommitValues(config *ChartConfig) (commitHash string, err error)

func (GitServiceImpl) ForceResetHead

func (impl GitServiceImpl) ForceResetHead(repoRoot string) (err error)

func (GitServiceImpl) GetCloneDirectory

func (impl GitServiceImpl) GetCloneDirectory(targetDir string) (clonedDir string)

func (GitServiceImpl) Pull

func (impl GitServiceImpl) Pull(repoRoot string) (err error)

type InternalServerError added in v0.3.6

type InternalServerError struct {
	E error
}

func (*InternalServerError) Error added in v0.3.6

func (err *InternalServerError) Error() string

type JsonPatchType

type JsonPatchType struct {
	Op    string      `json:"op"`
	Path  string      `json:"path"`
	Value interface{} `json:"value"`
}

type K8sUtil

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

func NewK8sUtil

func NewK8sUtil(logger *zap.SugaredLogger, runTimeConfig *client.RuntimeConfig) *K8sUtil

func (K8sUtil) BuildK8sObjectListTableData added in v0.6.11

func (impl K8sUtil) BuildK8sObjectListTableData(manifest *unstructured.UnstructuredList, namespaced bool, gvk schema.GroupVersionKind, validateResourceAccess func(namespace string, group string, kind string, resourceName string) bool) (*ClusterResourceListMap, error)

func (K8sUtil) CreateConfigMap added in v0.2.14

func (impl K8sUtil) CreateConfigMap(namespace string, cm *v1.ConfigMap, client *v12.CoreV1Client) (*v1.ConfigMap, error)

func (K8sUtil) CreateJob added in v0.3.7

func (impl K8sUtil) CreateJob(namespace string, name string, clusterConfig *ClusterConfig, job *batchV1.Job) error

func (K8sUtil) CreateNsIfNotExists

func (impl K8sUtil) CreateNsIfNotExists(namespace string, clusterConfig *ClusterConfig) (err error)

func (K8sUtil) CreateSecret added in v0.2.14

func (impl K8sUtil) CreateSecret(namespace string, data map[string][]byte, secretName string, secretType v1.SecretType, client *v12.CoreV1Client, labels map[string]string, stringData map[string]string) (*v1.Secret, error)

func (K8sUtil) DeleteAndCreateJob added in v0.3.7

func (impl K8sUtil) DeleteAndCreateJob(content []byte, namespace string, clusterConfig *ClusterConfig) error

DeleteAndCreateJob Deletes and recreates if job exists else creates the job

func (K8sUtil) DeleteJob added in v0.3.7

func (impl K8sUtil) DeleteJob(namespace string, name string, clusterConfig *ClusterConfig) error

func (K8sUtil) DeletePodByLabel added in v0.3.7

func (impl K8sUtil) DeletePodByLabel(namespace string, labels string, clusterConfig *ClusterConfig) error

func (K8sUtil) DeleteSecret added in v0.6.17

func (impl K8sUtil) DeleteSecret(namespace string, name string, client *v12.CoreV1Client) error

func (K8sUtil) GetClient

func (impl K8sUtil) GetClient(clusterConfig *ClusterConfig) (*v12.CoreV1Client, error)

func (K8sUtil) GetClientByToken added in v0.3.14

func (impl K8sUtil) GetClientByToken(serverUrl string, token map[string]string) (*v12.CoreV1Client, error)

func (K8sUtil) GetClientForInCluster added in v0.2.14

func (impl K8sUtil) GetClientForInCluster() (*v12.CoreV1Client, error)

func (K8sUtil) GetClientSet added in v0.3.7

func (impl K8sUtil) GetClientSet(clusterConfig *ClusterConfig) (*kubernetes.Clientset, error)

func (K8sUtil) GetConfigMap

func (impl K8sUtil) GetConfigMap(namespace string, name string, client *v12.CoreV1Client) (*v1.ConfigMap, error)

func (K8sUtil) GetK8sClient added in v0.6.1

func (impl K8sUtil) GetK8sClient() (*v12.CoreV1Client, error)

func (K8sUtil) GetK8sClusterRestConfig added in v0.4.1

func (impl K8sUtil) GetK8sClusterRestConfig() (*rest.Config, error)

func (K8sUtil) GetK8sDiscoveryClient added in v0.2.8

func (impl K8sUtil) GetK8sDiscoveryClient(clusterConfig *ClusterConfig) (*discovery.DiscoveryClient, error)

func (K8sUtil) GetK8sDiscoveryClientInCluster added in v0.2.14

func (impl K8sUtil) GetK8sDiscoveryClientInCluster() (*discovery.DiscoveryClient, error)

func (K8sUtil) GetKubeVersion added in v0.6.15

func (impl K8sUtil) GetKubeVersion() (*version.Info, error)

func (K8sUtil) GetPodByName added in v0.6.10

func (impl K8sUtil) GetPodByName(namespace string, name string, client *v12.CoreV1Client) (*v1.Pod, error)

func (K8sUtil) GetResourceInfoByLabelSelector added in v0.4.0

func (impl K8sUtil) GetResourceInfoByLabelSelector(ctx context.Context, namespace string, labelSelector string) (*v1.Pod, error)

func (K8sUtil) GetRestConfigByCluster added in v0.6.18

func (impl K8sUtil) GetRestConfigByCluster(configMap *ClusterConfig) (*rest.Config, error)

func (K8sUtil) GetSecret added in v0.2.14

func (impl K8sUtil) GetSecret(namespace string, name string, client *v12.CoreV1Client) (*v1.Secret, error)

func (K8sUtil) ListNamespaces added in v0.3.14

func (impl K8sUtil) ListNamespaces(client *v12.CoreV1Client) (*v1.NamespaceList, error)

func (K8sUtil) PatchConfigMap

func (impl K8sUtil) PatchConfigMap(namespace string, clusterConfig *ClusterConfig, name string, data map[string]interface{}) (*v1.ConfigMap, error)

func (K8sUtil) PatchConfigMapJsonType

func (impl K8sUtil) PatchConfigMapJsonType(namespace string, clusterConfig *ClusterConfig, name string, data interface{}, path string) (*v1.ConfigMap, error)

func (K8sUtil) UpdateConfigMap

func (impl K8sUtil) UpdateConfigMap(namespace string, cm *v1.ConfigMap, client *v12.CoreV1Client) (*v1.ConfigMap, error)

func (K8sUtil) UpdateSecret added in v0.2.14

func (impl K8sUtil) UpdateSecret(namespace string, secret *v1.Secret, client *v12.CoreV1Client) (*v1.Secret, error)

func (K8sUtil) ValidateResource added in v0.6.13

func (impl K8sUtil) ValidateResource(resourceObj map[string]interface{}, gvk schema.GroupVersionKind, validateCallback func(namespace string, group string, kind string, resourceName string) bool) bool

type LogConfig

type LogConfig struct {
	Level int `env:"LOG_LEVEL" envDefault:"0"` // default info
}

type MergeUtil

type MergeUtil struct {
	Logger *zap.SugaredLogger
}

func (MergeUtil) ConfigMapMerge

func (m MergeUtil) ConfigMapMerge(appLevelConfigMapJson string, envLevelConfigMapJson string) (data string, err error)

func (MergeUtil) ConfigSecretMerge

func (m MergeUtil) ConfigSecretMerge(appLevelSecretJson string, envLevelSecretJson string, chartMajorVersion int, chartMinorVersion int) (data string, err error)

func (MergeUtil) JsonPatch

func (m MergeUtil) JsonPatch(target, patch []byte) (data []byte, err error)

//returns json representation of merged values

func (m MergeUtil) MergeOverride(helmValues string, override []byte) ([]byte, error) {
	cf, err := conflate.FromData([]byte(helmValues), override)
	if err != nil {
		m.Logger.Errorw("error in merging config",
			"original", helmValues,
			"override", override,
			"error", err)
		return nil, err
	}
	jsonBytes, err := cf.MarshalJSON()
	if err != nil {
		m.Logger.Errorw("error in marshaling yaml ",
			"cf", cf,
			"error", err)
		return nil, err
	}
	dst := new(bytes.Buffer)
	err = json.Compact(dst, jsonBytes)
	if err != nil {
		return nil, err
	}
	jsonBytes = dst.Bytes()
	m.Logger.Infow("merged config ",
		"original", helmValues,
		"override", override,
		"yaml", jsonBytes,
	)
	return jsonBytes, nil
}
func (m MergeUtil) MergeOverrideVal(data ...[]byte) ([]byte, error) {
	cf, err := conflate.FromData(data...)
	if err != nil {
		m.Logger.Errorw("error in merging config",
			"val", data,
			"error", err)
		return nil, err
	}
	jsonBytes, err := cf.MarshalJSON()
	if err != nil {
		m.Logger.Errorw("error in marshaling yaml ",
			"cf", cf,
			"error", err)
		return nil, err
	}
	dst := new(bytes.Buffer)
	err = json.Compact(dst, jsonBytes)
	if err != nil {
		return nil, err
	}
	jsonBytes = dst.Bytes()
	return jsonBytes, nil
}

merges two json objects

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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