Documentation ¶
Index ¶
- Constants
- func GetDefaultConfigKeysMap() map[ConfigKeyStr]bool
- func GetUnitSuffix(unitKey ConfigKeyStr, unitStr string) units.UnitSuffix
- func GetUnitSuffixStr(unitKey ConfigKey, unit units.UnitSuffix) string
- type ConfigKey
- type ConfigKeyStr
- type ConfigurationBean
- type InfraConfig
- func (infraConfig InfraConfig) GetCiDefaultTimeout() int64
- func (infraConfig InfraConfig) GetCiLimitCpu() string
- func (infraConfig InfraConfig) GetCiLimitMem() string
- func (infraConfig InfraConfig) GetCiReqCpu() string
- func (infraConfig InfraConfig) GetCiReqMem() string
- func (infraConfig InfraConfig) LoadCiLimitCpu() (*InfraProfileConfigurationEntity, error)
- func (infraConfig InfraConfig) LoadCiLimitMem() (*InfraProfileConfigurationEntity, error)
- func (infraConfig InfraConfig) LoadCiReqCpu() (*InfraProfileConfigurationEntity, error)
- func (infraConfig InfraConfig) LoadCiReqMem() (*InfraProfileConfigurationEntity, error)
- func (infraConfig InfraConfig) LoadDefaultTimeout() (*InfraProfileConfigurationEntity, error)
- func (infraConfig InfraConfig) LoadInfraConfigInEntities() ([]*InfraProfileConfigurationEntity, error)
- type InfraConfigMetaData
- type InfraConfigRepository
- type InfraConfigRepositoryImpl
- func (impl *InfraConfigRepositoryImpl) CreateConfigurations(tx *pg.Tx, configurations []*InfraProfileConfigurationEntity) error
- func (impl *InfraConfigRepositoryImpl) CreateProfile(tx *pg.Tx, infraProfile *InfraProfileEntity) error
- func (impl *InfraConfigRepositoryImpl) GetConfigurationsByProfileId(profileId int) ([]*InfraProfileConfigurationEntity, error)
- func (impl *InfraConfigRepositoryImpl) GetConfigurationsByProfileName(profileName string) ([]*InfraProfileConfigurationEntity, error)
- func (impl *InfraConfigRepositoryImpl) GetProfileByName(name string) (*InfraProfileEntity, error)
- func (impl *InfraConfigRepositoryImpl) UpdateConfigurations(tx *pg.Tx, configurations []*InfraProfileConfigurationEntity) error
- func (impl *InfraConfigRepositoryImpl) UpdateProfile(tx *pg.Tx, profileName string, profile *InfraProfileEntity) error
- type InfraConfigService
- type InfraConfigServiceImpl
- func (impl *InfraConfigServiceImpl) GetConfigurationUnits() map[ConfigKeyStr]map[string]units.Unit
- func (impl *InfraConfigServiceImpl) GetInfraConfigurationsByScope(scope Scope) (*InfraConfig, error)
- func (impl *InfraConfigServiceImpl) GetProfileByName(name string) (*ProfileBean, error)
- func (impl *InfraConfigServiceImpl) UpdateProfile(userId int32, profileName string, profileToUpdate *ProfileBean) error
- func (impl *InfraConfigServiceImpl) Validate(profileToUpdate *ProfileBean, defaultProfile *ProfileBean) error
- type InfraProfileConfigurationEntity
- type InfraProfileEntity
- type ProfileBean
- type ProfileResponse
- type ProfileType
- type ProfilesResponse
- type Scope
Constants ¶
View Source
const CPULimReqErrorCompErr = "cpu limit should not be less than cpu request"
View Source
const DEFAULT_PROFILE_EXISTS = "default profile exists"
View Source
const DEFAULT_PROFILE_NAME = "default"
View Source
const InvalidProfileName = "profile name is invalid"
View Source
const InvalidUnit = "invalid %s unit found in %s "
View Source
const MEMLimReqErrorCompErr = "memory limit should not be less than memory request"
View Source
const NO_PROPERTIES_FOUND = "no properties found"
View Source
const PayloadValidationError = "payload validation failed"
Variables ¶
This section is empty.
Functions ¶
func GetDefaultConfigKeysMap ¶
func GetDefaultConfigKeysMap() map[ConfigKeyStr]bool
GetDefaultConfigKeysMap returns a map of default config keys
func GetUnitSuffix ¶
func GetUnitSuffix(unitKey ConfigKeyStr, unitStr string) units.UnitSuffix
GetUnitSuffix loosely typed method to get the unit suffix using the unitKey type
func GetUnitSuffixStr ¶
func GetUnitSuffixStr(unitKey ConfigKey, unit units.UnitSuffix) string
GetUnitSuffixStr loosely typed method to get the unit suffix using the unitKey type
Types ¶
type ConfigKey ¶
type ConfigKey int
const CPULimit ConfigKey = 1
const CPURequest ConfigKey = 2
const MemoryLimit ConfigKey = 3
const MemoryRequest ConfigKey = 4
const TimeOut ConfigKey = 5
func GetConfigKey ¶
func GetConfigKey(configKeyStr ConfigKeyStr) ConfigKey
type ConfigKeyStr ¶
type ConfigKeyStr string
const CPU_LIMIT ConfigKeyStr = "cpu_limit"
const CPU_REQUEST ConfigKeyStr = "cpu_request"
const MEMORY_LIMIT ConfigKeyStr = "memory_limit"
const MEMORY_REQUEST ConfigKeyStr = "memory_request"
const TIME_OUT ConfigKeyStr = "timeout"
func GetConfigKeyStr ¶
func GetConfigKeyStr(configKey ConfigKey) ConfigKeyStr
type ConfigurationBean ¶
type ConfigurationBean struct { Id int `json:"id"` Key ConfigKeyStr `json:"key"` Value float64 `json:"value" validate:"required,gt=0"` Unit string `json:"unit" validate:"required,gt=0"` ProfileName string `json:"profileName"` ProfileId int `json:"profileId"` Active bool `json:"active"` }
func (*ConfigurationBean) ConvertToInfraProfileConfigurationEntity ¶
func (configurationBean *ConfigurationBean) ConvertToInfraProfileConfigurationEntity() *InfraProfileConfigurationEntity
type InfraConfig ¶
type InfraConfig struct { // currently only for ci CiLimitCpu string `env:"LIMIT_CI_CPU" envDefault:"0.5"` CiLimitMem string `env:"LIMIT_CI_MEM" envDefault:"3G"` CiReqCpu string `env:"REQ_CI_CPU" envDefault:"0.5"` CiReqMem string `env:"REQ_CI_MEM" envDefault:"3G"` CiDefaultTimeout int64 `env:"DEFAULT_TIMEOUT" envDefault:"3600"` }
InfraConfig is used for read only purpose outside this package
func (InfraConfig) GetCiDefaultTimeout ¶
func (infraConfig InfraConfig) GetCiDefaultTimeout() int64
func (InfraConfig) GetCiLimitCpu ¶
func (infraConfig InfraConfig) GetCiLimitCpu() string
func (InfraConfig) GetCiLimitMem ¶
func (infraConfig InfraConfig) GetCiLimitMem() string
func (InfraConfig) GetCiReqCpu ¶
func (infraConfig InfraConfig) GetCiReqCpu() string
func (InfraConfig) GetCiReqMem ¶
func (infraConfig InfraConfig) GetCiReqMem() string
func (InfraConfig) LoadCiLimitCpu ¶
func (infraConfig InfraConfig) LoadCiLimitCpu() (*InfraProfileConfigurationEntity, error)
func (InfraConfig) LoadCiLimitMem ¶
func (infraConfig InfraConfig) LoadCiLimitMem() (*InfraProfileConfigurationEntity, error)
func (InfraConfig) LoadCiReqCpu ¶
func (infraConfig InfraConfig) LoadCiReqCpu() (*InfraProfileConfigurationEntity, error)
func (InfraConfig) LoadCiReqMem ¶
func (infraConfig InfraConfig) LoadCiReqMem() (*InfraProfileConfigurationEntity, error)
func (InfraConfig) LoadDefaultTimeout ¶
func (infraConfig InfraConfig) LoadDefaultTimeout() (*InfraProfileConfigurationEntity, error)
func (InfraConfig) LoadInfraConfigInEntities ¶
func (infraConfig InfraConfig) LoadInfraConfigInEntities() ([]*InfraProfileConfigurationEntity, error)
type InfraConfigMetaData ¶
type InfraConfigMetaData struct { DefaultConfigurations []ConfigurationBean `json:"defaultConfigurations"` ConfigurationUnits map[ConfigKeyStr]map[string]units.Unit `json:"configurationUnits"` }
type InfraConfigRepository ¶
type InfraConfigRepository interface { GetProfileByName(name string) (*InfraProfileEntity, error) GetConfigurationsByProfileName(profileName string) ([]*InfraProfileConfigurationEntity, error) GetConfigurationsByProfileId(profileId int) ([]*InfraProfileConfigurationEntity, error) CreateProfile(tx *pg.Tx, infraProfile *InfraProfileEntity) error CreateConfigurations(tx *pg.Tx, configurations []*InfraProfileConfigurationEntity) error UpdateConfigurations(tx *pg.Tx, configurations []*InfraProfileConfigurationEntity) error UpdateProfile(tx *pg.Tx, profileName string, profile *InfraProfileEntity) error sql.TransactionWrapper }
type InfraConfigRepositoryImpl ¶
type InfraConfigRepositoryImpl struct { *sql.TransactionUtilImpl // contains filtered or unexported fields }
func NewInfraProfileRepositoryImpl ¶
func NewInfraProfileRepositoryImpl(dbConnection *pg.DB, TransactionUtilImpl *sql.TransactionUtilImpl) *InfraConfigRepositoryImpl
func (*InfraConfigRepositoryImpl) CreateConfigurations ¶
func (impl *InfraConfigRepositoryImpl) CreateConfigurations(tx *pg.Tx, configurations []*InfraProfileConfigurationEntity) error
func (*InfraConfigRepositoryImpl) CreateProfile ¶
func (impl *InfraConfigRepositoryImpl) CreateProfile(tx *pg.Tx, infraProfile *InfraProfileEntity) error
CreateProfile saves the default profile in the database only once in a lifetime. If the default profile already exists, it will not be saved again.
func (*InfraConfigRepositoryImpl) GetConfigurationsByProfileId ¶
func (impl *InfraConfigRepositoryImpl) GetConfigurationsByProfileId(profileId int) ([]*InfraProfileConfigurationEntity, error)
func (*InfraConfigRepositoryImpl) GetConfigurationsByProfileName ¶
func (impl *InfraConfigRepositoryImpl) GetConfigurationsByProfileName(profileName string) ([]*InfraProfileConfigurationEntity, error)
func (*InfraConfigRepositoryImpl) GetProfileByName ¶
func (impl *InfraConfigRepositoryImpl) GetProfileByName(name string) (*InfraProfileEntity, error)
func (*InfraConfigRepositoryImpl) UpdateConfigurations ¶
func (impl *InfraConfigRepositoryImpl) UpdateConfigurations(tx *pg.Tx, configurations []*InfraProfileConfigurationEntity) error
func (*InfraConfigRepositoryImpl) UpdateProfile ¶
func (impl *InfraConfigRepositoryImpl) UpdateProfile(tx *pg.Tx, profileName string, profile *InfraProfileEntity) error
type InfraConfigService ¶
type InfraConfigService interface { // GetConfigurationUnits fetches all the units for the configurations. GetConfigurationUnits() map[ConfigKeyStr]map[string]units.Unit // GetProfileByName fetches the profile and its configurations matching the given profileName. GetProfileByName(name string) (*ProfileBean, error) // UpdateProfile updates the profile and its configurations matching the given profileName. // If profileName is empty, it will return an error. UpdateProfile(userId int32, profileName string, profileBean *ProfileBean) error GetInfraConfigurationsByScope(scope Scope) (*InfraConfig, error) }
type InfraConfigServiceImpl ¶
type InfraConfigServiceImpl struct {
// contains filtered or unexported fields
}
func NewInfraConfigServiceImpl ¶
func NewInfraConfigServiceImpl(logger *zap.SugaredLogger, infraProfileRepo InfraConfigRepository, appService app.AppService, units *units.Units) (*InfraConfigServiceImpl, error)
func (*InfraConfigServiceImpl) GetConfigurationUnits ¶
func (impl *InfraConfigServiceImpl) GetConfigurationUnits() map[ConfigKeyStr]map[string]units.Unit
func (*InfraConfigServiceImpl) GetInfraConfigurationsByScope ¶
func (impl *InfraConfigServiceImpl) GetInfraConfigurationsByScope(scope Scope) (*InfraConfig, error)
func (*InfraConfigServiceImpl) GetProfileByName ¶
func (impl *InfraConfigServiceImpl) GetProfileByName(name string) (*ProfileBean, error)
func (*InfraConfigServiceImpl) UpdateProfile ¶
func (impl *InfraConfigServiceImpl) UpdateProfile(userId int32, profileName string, profileToUpdate *ProfileBean) error
func (*InfraConfigServiceImpl) Validate ¶
func (impl *InfraConfigServiceImpl) Validate(profileToUpdate *ProfileBean, defaultProfile *ProfileBean) error
type InfraProfileConfigurationEntity ¶
type InfraProfileConfigurationEntity struct { Id int `sql:"id"` Key ConfigKey `sql:"key"` Value float64 `sql:"value"` Unit units.UnitSuffix `sql:"unit"` ProfileId int `sql:"profile_id"` Active bool `sql:"active"` sql.AuditLog // contains filtered or unexported fields }
func (*InfraProfileConfigurationEntity) ConvertToConfigurationBean ¶
func (infraProfileConfiguration *InfraProfileConfigurationEntity) ConvertToConfigurationBean() ConfigurationBean
type InfraProfileEntity ¶
type InfraProfileEntity struct { Id int `sql:"id"` Name string `sql:"name"` Description string `sql:"description"` Active bool `sql:"active"` sql.AuditLog // contains filtered or unexported fields }
func (*InfraProfileEntity) ConvertToProfileBean ¶
func (infraProfile *InfraProfileEntity) ConvertToProfileBean() ProfileBean
type ProfileBean ¶
type ProfileBean struct { Id int `json:"id"` Name string `json:"name" validate:"required,min=1,max=50"` Description string `json:"description" validate:"max=300"` Active bool `json:"active"` Configurations []ConfigurationBean `json:"configurations" validate:"dive"` Type ProfileType `json:"type"` AppCount int `json:"appCount"` CreatedBy int32 `json:"createdBy"` CreatedOn time.Time `json:"createdOn"` UpdatedBy int32 `json:"updatedBy"` UpdatedOn time.Time `json:"updatedOn"` }
func UpdateProfileMissingConfigurationsWithDefault ¶
func UpdateProfileMissingConfigurationsWithDefault(profile ProfileBean, defaultConfigurations []ConfigurationBean) ProfileBean
func (*ProfileBean) ConvertToInfraProfileEntity ¶
func (profileBean *ProfileBean) ConvertToInfraProfileEntity() *InfraProfileEntity
type ProfileResponse ¶
type ProfileResponse struct { Profile ProfileBean `json:"profile"` InfraConfigMetaData }
type ProfileType ¶
type ProfileType string
const DEFAULT ProfileType = "DEFAULT"
const NORMAL ProfileType = "NORMAL"
type ProfilesResponse ¶
type ProfilesResponse struct { Profiles []ProfileBean `json:"profiles"` InfraConfigMetaData }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.