mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 07:08:45 +05:00
Updated check config sanity
This commit is contained in:
committed by
Dan Christian Bogos
parent
f361026e44
commit
111e9758a7
@@ -98,6 +98,13 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
return fmt.Errorf("<%s> cannot find CDR export template with ID: <%s>", utils.CDRs, cdrePrfl)
|
||||
}
|
||||
}
|
||||
for prfl, cdre := range cfg.CdreProfiles {
|
||||
for _, field := range cdre.Fields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.CDRs, utils.NewErrMandatoryIeMissing(utils.Path), prfl, field.Tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Loaders sanity checks
|
||||
for _, ldrSCfg := range cfg.loaderCfg {
|
||||
@@ -118,6 +125,9 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
if field.Type != utils.META_COMPOSED && field.Type != utils.MetaString && field.Type != utils.MetaVariable {
|
||||
return fmt.Errorf("<%s> invalid field type %s for %s at %s", utils.LoaderS, field.Type, data.Type, field.Tag)
|
||||
}
|
||||
if field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.LoaderS, utils.NewErrMandatoryIeMissing(utils.Path), data.Type, field.Tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,6 +275,29 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.DiameterAgent, connID)
|
||||
}
|
||||
}
|
||||
for prf, tmp := range cfg.diameterAgentCfg.Templates {
|
||||
for _, field := range tmp {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for template %s at %s", utils.DiameterAgent, utils.NewErrMandatoryIeMissing(utils.Path), prf, field.Tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, req := range cfg.diameterAgentCfg.RequestProcessors {
|
||||
for _, field := range req.RequestFields {
|
||||
if field.Type != utils.META_NONE &&
|
||||
field.Type != utils.MetaTemplate &&
|
||||
field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.DiameterAgent, utils.NewErrMandatoryIeMissing(utils.Path), req.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
for _, field := range req.ReplyFields {
|
||||
if field.Type != utils.META_NONE &&
|
||||
field.Type != utils.MetaTemplate &&
|
||||
field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.DiameterAgent, utils.NewErrMandatoryIeMissing(utils.Path), req.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Radius Agent
|
||||
if cfg.radiusAgentCfg.Enabled {
|
||||
@@ -280,6 +313,18 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.RadiusAgent, connID)
|
||||
}
|
||||
}
|
||||
for _, req := range cfg.radiusAgentCfg.RequestProcessors {
|
||||
for _, field := range req.RequestFields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.RadiusAgent, utils.NewErrMandatoryIeMissing(utils.Path), req.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
for _, field := range req.ReplyFields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.RadiusAgent, utils.NewErrMandatoryIeMissing(utils.Path), req.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//DNS Agent
|
||||
if cfg.dnsAgentCfg.Enabled {
|
||||
@@ -295,6 +340,18 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.DNSAgent, connID)
|
||||
}
|
||||
}
|
||||
for _, req := range cfg.dnsAgentCfg.RequestProcessors {
|
||||
for _, field := range req.RequestFields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.DNSAgent, utils.NewErrMandatoryIeMissing(utils.Path), req.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
for _, field := range req.ReplyFields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.DNSAgent, utils.NewErrMandatoryIeMissing(utils.Path), req.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// HTTPAgent checks
|
||||
for _, httpAgentCfg := range cfg.httpAgentCfg {
|
||||
@@ -313,7 +370,48 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
if !utils.SliceHasMember([]string{utils.MetaTextPlain, utils.MetaXml}, httpAgentCfg.ReplyPayload) {
|
||||
return fmt.Errorf("<%s> unsupported reply payload %s", utils.HTTPAgent, httpAgentCfg.ReplyPayload)
|
||||
}
|
||||
for _, req := range httpAgentCfg.RequestProcessors {
|
||||
for _, field := range req.RequestFields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.HTTPAgent, utils.NewErrMandatoryIeMissing(utils.Path), req.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
for _, field := range req.ReplyFields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.HTTPAgent, utils.NewErrMandatoryIeMissing(utils.Path), req.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//SIP Agent
|
||||
if cfg.sipAgentCfg.Enabled {
|
||||
if len(cfg.sipAgentCfg.SessionSConns) == 0 {
|
||||
return fmt.Errorf("<%s> no %s connections defined",
|
||||
utils.SIPAgent, utils.SessionS)
|
||||
}
|
||||
for _, connID := range cfg.sipAgentCfg.SessionSConns {
|
||||
if strings.HasPrefix(connID, utils.MetaInternal) && !cfg.sessionSCfg.Enabled {
|
||||
return fmt.Errorf("<%s> not enabled but requested by <%s> component.", utils.SessionS, utils.SIPAgent)
|
||||
}
|
||||
if _, has := cfg.rpcConns[connID]; !has && !strings.HasPrefix(connID, utils.MetaInternal) {
|
||||
return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.SIPAgent, connID)
|
||||
}
|
||||
}
|
||||
for _, req := range cfg.sipAgentCfg.RequestProcessors {
|
||||
for _, field := range req.RequestFields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.SIPAgent, utils.NewErrMandatoryIeMissing(utils.Path), req.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
for _, field := range req.ReplyFields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.SIPAgent, utils.NewErrMandatoryIeMissing(utils.Path), req.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if cfg.attributeSCfg.Enabled {
|
||||
if cfg.attributeSCfg.ProcessRuns < 1 {
|
||||
return fmt.Errorf("<%s> process_runs needs to be bigger than 0", utils.AttributeS)
|
||||
@@ -425,6 +523,16 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, field := range rdr.CacheDumpFields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.ERs, utils.NewErrMandatoryIeMissing(utils.Path), rdr.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
for _, field := range rdr.Fields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.ERs, utils.NewErrMandatoryIeMissing(utils.Path), rdr.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// EventExporter sanity checks
|
||||
@@ -459,6 +567,11 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, field := range exp.Fields {
|
||||
if field.Type != utils.META_NONE && field.Path == utils.EmptyString {
|
||||
return fmt.Errorf("<%s> %s for %s at %s", utils.EEs, utils.NewErrMandatoryIeMissing(utils.Path), exp.ID, field.Tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// StorDB sanity checks
|
||||
|
||||
Reference in New Issue
Block a user