util

package
v0.0.0-...-19fb9ea Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 68 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"
)
View Source
const Branch_Master = "master"
View Source
const GIT_ASK_PASS = "/git-ask-pass.sh"
View Source
const PIPELINE_DEPLOYMENT_TYPE_ACD string = "argo_cd"
View Source
const PIPELINE_DEPLOYMENT_TYPE_HELM string = "helm"
View Source
const Running = "Running"

Variables

This section is empty.

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

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

func IntValidator

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

func IsErrNoRows

func IsErrNoRows(err error) bool

func IsValidUrl

func IsValidUrl(input string) bool

func NewHttpClient

func NewHttpClient() *http.Client

func NewSugardLogger

func NewSugardLogger() (*zap.SugaredLogger, 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

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

type BadRequestError struct {
	E error
}

func (*BadRequestError) Error

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 ChartGitAttribute

type ChartGitAttribute struct {
	RepoUrl, ChartLocation string
}

type ChartTemplateService

type ChartTemplateService interface {
	FetchValuesFromReferenceChart(chartMetaData *chart.Metadata, refChartLocation string, templateName string, userId int32) (*ChartValues, *ChartGitAttribute, error)
	GetChartVersion(location string) (string, error)
	CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, templateName string, version string, envName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, *ChartGitAttribute, error)
	GitPull(clonedDir string, repoUrl string, appStoreName string) error
	GetDir() 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)
	RegisterInArgo(chartGitAttribute *ChartGitAttribute, ctx context.Context) error
	BuildChartAndPushToGitRepo(chartMetaData *chart.Metadata, referenceTemplatePath string, gitOpsRepoName, referenceTemplate, version, repoUrl string, userId int32) error
	GetByteArrayRefChart(chartMetaData *chart.Metadata, referenceTemplatePath string) ([]byte, error)
	CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) 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, repositoryService repository4.ServiceClient) *ChartTemplateServiceImpl

func (ChartTemplateServiceImpl) BuildChartAndPushToGitRepo

func (impl ChartTemplateServiceImpl) BuildChartAndPushToGitRepo(chartMetaData *chart.Metadata, referenceTemplatePath string, gitOpsRepoName, referenceTemplate, version, repoUrl string, userId int32) error

func (ChartTemplateServiceImpl) CleanDir

func (impl ChartTemplateServiceImpl) CleanDir(dir string)

func (ChartTemplateServiceImpl) CreateChartProxy

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

func (ChartTemplateServiceImpl) CreateGitRepositoryForApp

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

func (ChartTemplateServiceImpl) CreateReadmeInGitRepo

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

func (ChartTemplateServiceImpl) FetchValuesFromReferenceChart

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

func (ChartTemplateServiceImpl) GetByteArrayRefChart

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

func (impl ChartTemplateServiceImpl) GetDir() string

func (ChartTemplateServiceImpl) GetGitOpsRepoName

func (impl ChartTemplateServiceImpl) GetGitOpsRepoName(appName string) string

func (ChartTemplateServiceImpl) GetGitOpsRepoNameFromUrl

func (impl ChartTemplateServiceImpl) GetGitOpsRepoNameFromUrl(gitRepoUrl string) string

func (*ChartTemplateServiceImpl) GetUserEmailIdAndNameForGitOpsCommit

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

func (ChartTemplateServiceImpl) GitPull

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

func (ChartTemplateServiceImpl) RegisterInArgo

func (impl ChartTemplateServiceImpl) RegisterInArgo(chartGitAttribute *ChartGitAttribute, ctx context.Context) 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 {
	Host        string
	BearerToken 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 ForbiddenError

type ForbiddenError struct {
	E error
}

func (*ForbiddenError) Error

func (err *ForbiddenError) Error() string

type GitAzureClient

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

func NewGitAzureClient

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

func (GitAzureClient) CommitValues

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

func (GitAzureClient) CreateReadme

func (impl GitAzureClient) CreateReadme(repoName, userName, userEmailId, owner string) (string, error)

func (GitAzureClient) CreateRepository

func (impl GitAzureClient) CreateRepository(name, description, bitbucketWorkspaceId, bitbucketProjectKey, userName, userEmailId string) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions)

func (GitAzureClient) DeleteRepository

func (impl GitAzureClient) DeleteRepository(name, userName, gitHubOrgName, azureProjectName string, repoOptions *bitbucket.RepositoryOptions) error

func (GitAzureClient) GetRepoUrl

func (impl GitAzureClient) GetRepoUrl(repoName string, repoOptions *bitbucket.RepositoryOptions) (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, gitService GitService) GitBitbucketClient

func (GitBitbucketClient) CommitValues

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

func (GitBitbucketClient) CreateReadme

func (impl GitBitbucketClient) CreateReadme(repoName, userName, userEmailId string, owner string) (string, error)

func (GitBitbucketClient) CreateRepository

func (impl GitBitbucketClient) CreateRepository(name, description, workSpaceId, projectKey, userName, userEmailId string) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions)

func (GitBitbucketClient) DeleteRepository

func (impl GitBitbucketClient) DeleteRepository(name, userName, gitHubOrgName, azureProjectName string, repoOptions *bitbucket.RepositoryOptions) error

func (GitBitbucketClient) GetRepoUrl

func (impl GitBitbucketClient) GetRepoUrl(repoName string, repoOptions *bitbucket.RepositoryOptions) (repoUrl string, err error)

type GitCliUtil

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

func NewGitCliUtil

func NewGitCliUtil(logger *zap.SugaredLogger) *GitCliUtil

func (*GitCliUtil) Checkout

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

func (*GitCliUtil) Clone

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

func (*GitCliUtil) Fetch

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

func (*GitCliUtil) Init

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

func (*GitCliUtil) ListBranch

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

func (*GitCliUtil) Pull

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

type GitClient

type GitClient interface {
	CreateRepository(name, description, bitbucketWorkspaceId, bitbucketProjectKey, userName, userEmailId string) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions)
	CommitValues(config *ChartConfig, bitbucketWorkspaceId string) (commitHash string, err error)
	GetRepoUrl(projectName string, repoOptions *bitbucket.RepositoryOptions) (repoUrl string, err error)
	DeleteRepository(name, userName, gitHubOrgName, azureProjectName string, repoOptions *bitbucket.RepositoryOptions) error
	CreateReadme(name, userName, userEmailId, owner string) (string, error)
}

func NewGitLabClient

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

func NewGitOpsClient

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

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

	GitWorkingDir string
	// contains filtered or unexported fields
}

func NewGitFactory

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

func (*GitFactory) GetGitLabGroupPath

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

func (*GitFactory) NewClientForValidation

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) (GitHubClient, error)

func (GitHubClient) CommitValues

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

func (GitHubClient) CreateReadme

func (impl GitHubClient) CreateReadme(repoName, userName, userEmailId, owner string) (string, error)

func (GitHubClient) CreateRepository

func (impl GitHubClient) CreateRepository(name, description, bitbucketWorkspaceId, bitbucketProjectKey, userName, userEmailId string) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions)

func (GitHubClient) DeleteRepository

func (impl GitHubClient) DeleteRepository(name, userName, gitHubOrgName, azureProjectName string, repoOptions *bitbucket.RepositoryOptions) error

func (GitHubClient) GetRepoUrl

func (impl GitHubClient) GetRepoUrl(projectName string, repoOptions *bitbucket.RepositoryOptions) (repoUrl string, err error)

type GitLabClient

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

func (GitLabClient) CommitValues

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

func (GitLabClient) CreateReadme

func (impl GitLabClient) CreateReadme(namespace, projectName, userName, userEmailId string) (string, error)

func (GitLabClient) CreateRepository

func (impl GitLabClient) CreateRepository(name, description, bitbucketWorkspaceId, bitbucketProjectKey, userName, userEmailId string) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions)

func (GitLabClient) DeleteProject

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

func (GitLabClient) DeleteRepository

func (impl GitLabClient) DeleteRepository(name, userName, gitHubOrgName, azureProjectName string, repoOptions *bitbucket.RepositoryOptions) error

func (GitLabClient) GetRepoUrl

func (impl GitLabClient) GetRepoUrl(projectName string, repoOptions *bitbucket.RepositoryOptions) (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

type InternalServerError struct {
	E error
}

func (*InternalServerError) Error

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) CreateConfigMap

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

func (K8sUtil) CreateJob

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

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

func (K8sUtil) DeleteAndCreateJob

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

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

func (K8sUtil) DeletePodByLabel

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

func (K8sUtil) GetClient

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

func (K8sUtil) GetClientByToken

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

func (K8sUtil) GetClientForInCluster

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

func (K8sUtil) GetClientSet

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) GetK8sClusterRestConfig

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

func (K8sUtil) GetK8sDiscoveryClient

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

func (K8sUtil) GetK8sDiscoveryClientInCluster

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

func (K8sUtil) GetResourceInfoByLabelSelector

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

func (K8sUtil) GetSecret

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

func (K8sUtil) ListNamespaces

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

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

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