util

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 31 Imported by: 27

Documentation

Index

Constants

View Source
const (
	KubernetesSecret                    string = "KubernetesSecret"
	AWSSecretsManager                   string = "AWSSecretsManager"
	AWSSystemManager                    string = "AWSSystemManager"
	HashiCorpVault                      string = "HashiCorpVault"
	ESOGoogleSecretsManager             string = "ESO_GoogleSecretsManager"
	ESOAWSSecretsManager                string = "ESO_AWSSecretsManager"
	ESOAzureSecretsManager              string = "ESO_AzureSecretsManager"
	ESOHashiCorpVault                   string = "ESO_HashiCorpVault"
	KubernetesExternalSecret            string = "KubernetesExternalSecret"
	ConfigMapSecretUsageTypeEnvironment string = "environment"
	ConfigMapSecretUsageTypeVolume      string = "volume"
	YamlSeparator                       string = "---\n"
)
View Source
const (
	CI_RUNNER_STREAM                  string = "CI-RUNNER"
	ORCHESTRATOR_STREAM               string = "ORCHESTRATOR"
	KUBEWATCH_STREAM                  string = "KUBEWATCH"
	GIT_SENSOR_STREAM                 string = "GIT-SENSOR"
	BULK_APPSTORE_DEPLOY_TOPIC        string = "APP-STORE.BULK-DEPLOY"
	BULK_APPSTORE_DEPLOY_GROUP        string = "APP-STORE-BULK-DEPLOY-GROUP-1"
	BULK_APPSTORE_DEPLOY_DURABLE      string = "APP-STORE-BULK-DEPLOY-DURABLE-1"
	CD_STAGE_COMPLETE_TOPIC           string = "CD-STAGE-COMPLETE"
	CD_COMPLETE_GROUP                 string = "CD-COMPLETE_GROUP-1"
	CD_COMPLETE_DURABLE               string = "CD-COMPLETE_DURABLE-1"
	BULK_DEPLOY_TOPIC                 string = "CD.BULK"
	BULK_HIBERNATE_TOPIC              string = "CD.BULK-HIBERNATE"
	BULK_DEPLOY_GROUP                 string = "CD.BULK.GROUP-1"
	BULK_HIBERNATE_GROUP              string = "CD.BULK-HIBERNATE.GROUP-1"
	BULK_DEPLOY_DURABLE               string = "CD-BULK-DURABLE-1"
	BULK_HIBERNATE_DURABLE            string = "CD-BULK-HIBERNATE-DURABLE-1"
	CI_COMPLETE_TOPIC                 string = "CI-COMPLETE"
	CI_COMPLETE_GROUP                 string = "CI-COMPLETE_GROUP-1"
	CI_COMPLETE_DURABLE               string = "CI-COMPLETE_DURABLE-1"
	APPLICATION_STATUS_UPDATE_TOPIC   string = "APPLICATION_STATUS_UPDATE"
	APPLICATION_STATUS_UPDATE_GROUP   string = "APPLICATION_STATUS_UPDATE_GROUP-1"
	APPLICATION_STATUS_UPDATE_DURABLE string = "APPLICATION_STATUS_UPDATE_DURABLE-1"
	CRON_EVENTS                       string = "CRON_EVENTS"
	CRON_EVENTS_GROUP                 string = "CRON_EVENTS_GROUP-2"
	CRON_EVENTS_DURABLE               string = "CRON_EVENTS_DURABLE-2"
	WORKFLOW_STATUS_UPDATE_TOPIC      string = "WORKFLOW_STATUS_UPDATE"
	WORKFLOW_STATUS_UPDATE_GROUP      string = "WORKFLOW_STATUS_UPDATE_GROUP-1"
	WORKFLOW_STATUS_UPDATE_DURABLE    string = "WORKFLOW_STATUS_UPDATE_DURABLE-1"
	CD_WORKFLOW_STATUS_UPDATE         string = "CD_WORKFLOW_STATUS_UPDATE"
	CD_WORKFLOW_STATUS_UPDATE_GROUP   string = "CD_WORKFLOW_STATUS_UPDATE_GROUP-1"
	CD_WORKFLOW_STATUS_UPDATE_DURABLE string = "CD_WORKFLOW_STATUS_UPDATE_DURABLE-1"
	NEW_CI_MATERIAL_TOPIC             string = "NEW-CI-MATERIAL"
	NEW_CI_MATERIAL_TOPIC_GROUP       string = "NEW-CI-MATERIAL_GROUP-1"
	NEW_CI_MATERIAL_TOPIC_DURABLE     string = "NEW-CI-MATERIAL_DURABLE-1"
	CD_SUCCESS                        string = "CD.TRIGGER"
	WEBHOOK_EVENT_TOPIC               string = "WEBHOOK_EVENT"
)
View Source
const (
	CpuRegex    = "(^\\d*\\.?\\d+e?\\d*)(m?)$"
	MemoryRegex = "(^\\d*\\.?\\d+e?\\d*)(Ei?|Pi?|Ti?|Gi?|Mi?|Ki?|$)$"
)

Variables

View Source
var (
	CpuUnitChecker, _    = regexp.Compile(CpuRegex)
	MemoryUnitChecker, _ = regexp.Compile(MemoryRegex)
)
View Source
var (
	GitCommit            = ""
	BuildTime            = ""
	ServerMode           = ""
	SERVER_MODE_FULL     = "FULL"
	SERVER_MODE_HYPERION = "EA_ONLY"
)
View Source
var GIT_SENSOR_SUBJECTS = []string{NEW_CI_MATERIAL_TOPIC}

Functions

func AddStream added in v0.4.0

func AddStream(js nats.JetStreamContext, streamNames ...string) error

func AppendErrorString

func AppendErrorString(errs []string, err error) []string

func AutoScale added in v0.2.37

func AutoScale(dat map[string]interface{}) (bool, error)

func BuildDeployedAppName added in v0.4.15

func BuildDeployedAppName(appName string, environmentName string) string

func BuildDevtronBomUrl added in v0.4.1

func BuildDevtronBomUrl(bomUrl string, version string) string

func CheckForMissingFiles added in v0.3.22

func CheckForMissingFiles(chartLocation string) error

func Close

func Close(c Closer, logger *zap.SugaredLogger)

func CompareLimitsRequests added in v0.2.37

func CompareLimitsRequests(dat map[string]interface{}, chartVersion string) (bool, error)

func ComputeHash

func ComputeHash(template *v1.PodTemplateSpec, collisionCount *int32) string

ComputeHash returns a hash value calculated from pod template and a collisionCount to avoid hash collision. The hash will be safe encoded to avoid bad words.

func ContainsString

func ContainsString(list []string, element string) bool

func CpuToNumber added in v0.2.37

func CpuToNumber(cpu string) (int64, error)

func DeepHashObject

func DeepHashObject(hasher hash.Hash, objectToWrite interface{})

DeepHashObject writes specified object to hash using the spew library which follows pointers and prints actual values of the nested objects ensuring the hash does not change when a pointer changes.

func ExtractChartVersion

func ExtractChartVersion(chartVersion string) (int, int, error)

func ExtractTarGz added in v0.3.22

func ExtractTarGz(gzipStream io.Reader, chartDir string) error

func Generate added in v0.2.8

func Generate(size int) string

Generates random string

func GetClientIP added in v0.4.11

func GetClientIP(r *http.Request) string

GetClientIP gets a requests IP address by reading off the forwarded-for header (for proxies) and falls back to use the remote address.

func GetErrorOrNil

func GetErrorOrNil(errs []string) error

func GetStreamSubjects added in v0.4.0

func GetStreamSubjects(streamName string) []string

func HttpRequest added in v0.2.18

func HttpRequest(url string) (map[string]interface{}, error)

func Int

func Int() int

Int returns a non-negative pseudo-random int.

func Int63nRange

func Int63nRange(min, max int64) int64

IntnRange generates an int64 integer in range [min,max). By design this should panic if input is invalid, <= 0.

func InterfaceToMapAdapter added in v0.4.14

func InterfaceToMapAdapter(resp interface{}) map[string]interface{}

InterfaceToMapAdapter it will convert any golang struct into map

func Intn

func Intn(max int) int

Intn generates an integer in range [0,max). By design this should panic if input is invalid, <= 0.

func IntnRange

func IntnRange(min, max int) int

IntnRange generates an integer in range [min,max). By design this should panic if input is invalid, <= 0.

func IsBaseStack added in v0.5.3

func IsBaseStack() bool

func IsFullStack added in v0.5.3

func IsFullStack() bool

func IsHelmApp added in v0.5.3

func IsHelmApp(appOfferingMode string) bool

func MemoryToNumber added in v0.2.37

func MemoryToNumber(memory string) (int64, error)

func ParseFloat added in v0.2.37

func ParseFloat(str string) (float64, error)

func Perm

func Perm(n int) []int

Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n) from the default Source.

func ReadFromUrlWithRetry added in v0.4.1

func ReadFromUrlWithRetry(url string) ([]byte, error)

func SafeEncodeString

func SafeEncodeString(s string) string

SafeEncodeString encodes s using the same characters as rand.String. This reduces the chances of bad words and ensures that strings generated from hash functions appear consistent throughout the API.

func Seed

func Seed(seed int64)

Seed seeds the rng with the provided seed.

func String

func String(n int) string

String generates a random alphanumeric string, without vowels, which is n characters long. This will panic if n is less than zero. How the random string is created: - we generate random int63's - from each int63, we are extracting multiple random letters by bit-shifting and masking - if some index is out of range of alphanums we neglect it (unlikely to happen multiple times in a row)

func Tprintf added in v0.4.1

func Tprintf(tmpl string, data interface{}) (string, error)

Tprintf passed template string is formatted usign its operands and returns the resulting string. Spaces are added between operands when neither is a string.

Types

type Closer

type Closer interface {
	Close() error
}

type CpuChecker added in v0.2.37

type CpuChecker struct{}

func (CpuChecker) IsFormat added in v0.2.37

func (f CpuChecker) IsFormat(input interface{}) bool

type CustomFormatCheckers added in v0.2.37

type CustomFormatCheckers struct {
}

func NewGoJsonSchemaCustomFormatChecker added in v0.2.37

func NewGoJsonSchemaCustomFormatChecker() *CustomFormatCheckers

func (CustomFormatCheckers) AddCheckers added in v0.2.37

func (c CustomFormatCheckers) AddCheckers()

type DevtronSecretConfig added in v0.5.3

type DevtronSecretConfig struct {
	DevtronSecretName string `env:"DEVTRON_SECRET_NAME" envDefault:"devtron-secret"`
}

func GetDevtronSecretName added in v0.5.3

func GetDevtronSecretName() (*DevtronSecretConfig, error)

type GlobalEnvVariables added in v0.3.17

type GlobalEnvVariables struct {
	GitOpsRepoPrefix string `env:"GITOPS_REPO_PREFIX" envDefault:""`
}

func GetGlobalEnvVariables added in v0.3.17

func GetGlobalEnvVariables() (*GlobalEnvVariables, error)

type MemoryChecker added in v0.2.37

type MemoryChecker struct{}

func (MemoryChecker) IsFormat added in v0.2.37

func (f MemoryChecker) IsFormat(input interface{}) bool

type ServerVersion added in v0.3.9

type ServerVersion struct {
	GitCommit  string `json:"gitCommit"`
	BuildTime  string `json:"buildTime"`
	ServerMode string `json:"serverMode"`
}

func GetDevtronVersion added in v0.3.9

func GetDevtronVersion() *ServerVersion

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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