util

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: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PIPELINE_DEPLOYMENT_TYPE_ACD               = "argo_cd"
	PIPELINE_DEPLOYMENT_TYPE_HELM              = "helm"
	PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD = "manifest_download"
	CHART_WORKING_DIR_PATH                     = "/tmp/charts/"
)

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

func GetGRPCDetailedError(err error) (codes.Code, string)

func GetGRPCErrorDetailedMessage added in v0.6.23

func GetGRPCErrorDetailedMessage(err error) string

func GetLogger deprecated

func GetLogger() *zap.SugaredLogger

Deprecated: instead calling this method inject logger from wire

func GetTruncatedMessage added in v0.6.26

func GetTruncatedMessage(message string, maxLength int) string

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

TODO refactoring: This feature belongs to enterprise only

func IsOCIConfigChartProvider added in v0.6.23

func IsOCIConfigChartProvider(ociRegistryConfig *dockerRegistryRepository.OCIRegistryConfig) bool

func IsOCIRegistryChartProvider added in v0.6.23

func IsOCIRegistryChartProvider(ociRegistry dockerRegistryRepository.DockerArtifactStore) 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 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 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 ChartTemplateService

type ChartTemplateService interface {
	FetchValuesFromReferenceChart(chartMetaData *chart.Metadata, refChartLocation string, templateName string, userId int32, pipelineStrategyPath string) (*ChartValues, error)
	GetChartVersion(location string) (string, error)
	BuildChart(ctx context.Context, chartMetaData *chart.Metadata, referenceTemplatePath string) (string, error)
	BuildChartProxyForHelmApps(chartCreateRequest *ChartCreateRequest) (chartCreateResponse *ChartCreateResponse, err error)
	GetDir() string
	CleanDir(dir string)
	GetByteArrayRefChart(chartMetaData *chart.Metadata, referenceTemplatePath string) ([]byte, error)
	LoadChartInBytes(ChartPath string, deleteChart bool) ([]byte, error)
	LoadChartFromDir(dir string) (*chart.Chart, error)
	CreateZipFileForChart(chart *chart.Chart, outputChartPathDir string) ([]byte, error)
	PackageChart(tempReferenceTemplateDir string, chartMetaData *chart.Metadata) (*string, string, error)
}

type ChartTemplateServiceImpl

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

func NewChartTemplateServiceImpl

func NewChartTemplateServiceImpl(logger *zap.SugaredLogger) *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) CreateZipFileForChart added in v0.6.24

func (impl ChartTemplateServiceImpl) CreateZipFileForChart(chart *chart.Chart, outputChartPathDir string) ([]byte, 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, 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) LoadChartFromDir added in v0.6.24

func (impl ChartTemplateServiceImpl) LoadChartFromDir(dir string) (*chart.Chart, error)

func (ChartTemplateServiceImpl) LoadChartInBytes added in v0.6.17

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

func (ChartTemplateServiceImpl) PackageChart added in v0.6.29

func (impl ChartTemplateServiceImpl) PackageChart(tempReferenceTemplateDir string, chartMetaData *chart.Metadata) (*string, string, 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 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 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 LogConfig

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

	DevMode bool `env:"LOGGER_DEV_MODE" envDefault:"false"`
}

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, isJob bool) (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