@@ -393,21 +393,9 @@ func (c *QuesmaNewConfiguration) validateProcessor(p Processor) error {
393393 if errTarget != nil {
394394 return errTarget
395395 }
396- // fallback to old style, simplified target configuration
397- if len (targets ) > 0 {
398- for _ , target := range targets {
399- if c .getBackendConnectorByName (target .target ) == nil {
400- return fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName )
401- }
402- }
403- }
404- if len (targets ) == 0 {
405- if _ , ok := indexConfig .Target .([]interface {}); ok {
406- for _ , target := range indexConfig .Target .([]interface {}) {
407- if c .getBackendConnectorByName (target .(string )) == nil {
408- return fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName )
409- }
410- }
396+ for _ , target := range targets {
397+ if c .getBackendConnectorByName (target .target ) == nil {
398+ return fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName )
411399 }
412400 }
413401 }
@@ -568,29 +556,15 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
568556 if errTarget != nil {
569557 errAcc = multierror .Append (errAcc , errTarget )
570558 }
571- if len (targets ) > 0 {
572- for _ , target := range targets {
573- if targetType , found := c .getTargetType (target .target ); found {
574- defaultConfig .QueryTarget = append (defaultConfig .QueryTarget , targetType )
575- } else {
576- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of %s" , target , DefaultWildcardIndexName ))
577- }
578- if val , exists := target .properties ["useCommonTable" ]; exists {
579- conf .CreateCommonTable = val == "true"
580- conf .UseCommonTableForWildcard = val == "true"
581- }
559+ for _ , target := range targets {
560+ if targetType , found := c .getTargetType (target .target ); found {
561+ defaultConfig .QueryTarget = append (defaultConfig .QueryTarget , targetType )
562+ } else {
563+ errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of %s" , target , DefaultWildcardIndexName ))
582564 }
583- }
584- // fallback to old style, simplified target configuration
585- if len (targets ) == 0 {
586- if _ , ok := defaultConfig .Target .([]interface {}); ok {
587- for _ , target := range defaultConfig .Target .([]interface {}) {
588- if targetType , found := c .getTargetType (target .(string )); found {
589- defaultConfig .QueryTarget = append (defaultConfig .QueryTarget , targetType )
590- } else {
591- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of %s" , target , DefaultWildcardIndexName ))
592- }
593- }
565+ if val , exists := target .properties ["useCommonTable" ]; exists {
566+ conf .CreateCommonTable = val == "true"
567+ conf .UseCommonTableForWildcard = val == "true"
594568 }
595569 }
596570
@@ -615,28 +589,14 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
615589 if errTarget != nil {
616590 errAcc = multierror .Append (errAcc , errTarget )
617591 }
618- if len (targets ) > 0 {
619- for _ , target := range targets {
620- if targetType , found := c .getTargetType (target .target ); found {
621- processedConfig .QueryTarget = append (processedConfig .QueryTarget , targetType )
622- } else {
623- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName ))
624- }
625- if val , exists := target .properties ["useCommonTable" ]; exists {
626- processedConfig .UseCommonTable = val == "true"
627- }
592+ for _ , target := range targets {
593+ if targetType , found := c .getTargetType (target .target ); found {
594+ processedConfig .QueryTarget = append (processedConfig .QueryTarget , targetType )
595+ } else {
596+ errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName ))
628597 }
629- }
630- // fallback to old style, simplified target configuration
631- if len (targets ) == 0 {
632- if _ , ok := indexConfig .Target .([]interface {}); ok {
633- for _ , target := range indexConfig .Target .([]interface {}) {
634- if targetType , found := c .getTargetType (target .(string )); found {
635- processedConfig .QueryTarget = append (processedConfig .QueryTarget , targetType )
636- } else {
637- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName ))
638- }
639- }
598+ if val , exists := target .properties ["useCommonTable" ]; exists {
599+ processedConfig .UseCommonTable = val == "true"
640600 }
641601 }
642602 if len (processedConfig .QueryTarget ) == 2 && ! ((processedConfig .QueryTarget [0 ] == ClickhouseTarget && processedConfig .QueryTarget [1 ] == ElasticsearchTarget ) ||
@@ -684,29 +644,15 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
684644 if errTarget != nil {
685645 errAcc = multierror .Append (errAcc , errTarget )
686646 }
687- if len (targets ) > 0 {
688- for _ , target := range targets {
689- if targetType , found := c .getTargetType (target .target ); found {
690- defaultConfig .QueryTarget = append (defaultConfig .QueryTarget , targetType )
691- } else {
692- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of %s" , target , DefaultWildcardIndexName ))
693- }
694- if val , exists := target .properties ["useCommonTable" ]; exists {
695- conf .CreateCommonTable = val == "true"
696- conf .UseCommonTableForWildcard = val == "true"
697- }
647+ for _ , target := range targets {
648+ if targetType , found := c .getTargetType (target .target ); found {
649+ defaultConfig .QueryTarget = append (defaultConfig .QueryTarget , targetType )
650+ } else {
651+ errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of %s" , target , DefaultWildcardIndexName ))
698652 }
699- }
700- // fallback to old style, simplified target configuration
701- if len (targets ) == 0 {
702- if _ , ok := defaultConfig .Target .([]interface {}); ok {
703- for _ , target := range defaultConfig .Target .([]interface {}) {
704- if targetType , found := c .getTargetType (target .(string )); found {
705- defaultConfig .QueryTarget = append (defaultConfig .QueryTarget , targetType )
706- } else {
707- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of %s" , target , DefaultWildcardIndexName ))
708- }
709- }
653+ if val , exists := target .properties ["useCommonTable" ]; exists {
654+ conf .CreateCommonTable = val == "true"
655+ conf .UseCommonTableForWildcard = val == "true"
710656 }
711657 }
712658 if defaultConfig .UseCommonTable {
@@ -721,29 +667,15 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
721667 if errTarget != nil {
722668 errAcc = multierror .Append (errAcc , errTarget )
723669 }
724- if len (targets ) > 0 {
725- for _ , target := range targets {
726- if targetType , found := c .getTargetType (target .target ); found {
727- defaultConfig .IngestTarget = append (defaultConfig .IngestTarget , targetType )
728- } else {
729- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of %s" , target , DefaultWildcardIndexName ))
730- }
731- if val , exists := target .properties ["useCommonTable" ]; exists {
732- conf .CreateCommonTable = val == "true"
733- conf .UseCommonTableForWildcard = val == "true"
734- }
670+ for _ , target := range targets {
671+ if targetType , found := c .getTargetType (target .target ); found {
672+ defaultConfig .IngestTarget = append (defaultConfig .IngestTarget , targetType )
673+ } else {
674+ errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of %s" , target , DefaultWildcardIndexName ))
735675 }
736- }
737- // fallback to old style, simplified target configuration
738- if len (targets ) == 0 {
739- if _ , ok := ingestProcessor .Config .IndexConfig [DefaultWildcardIndexName ].Target .([]interface {}); ok {
740- for _ , target := range ingestProcessor .Config .IndexConfig [DefaultWildcardIndexName ].Target .([]interface {}) {
741- if targetType , found := c .getTargetType (target .(string )); found {
742- defaultConfig .IngestTarget = append (defaultConfig .IngestTarget , targetType )
743- } else {
744- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of %s" , target , DefaultWildcardIndexName ))
745- }
746- }
676+ if val , exists := target .properties ["useCommonTable" ]; exists {
677+ conf .CreateCommonTable = val == "true"
678+ conf .UseCommonTableForWildcard = val == "true"
747679 }
748680 }
749681 if ingestProcessorDefaultIndexConfig .UseCommonTable {
@@ -777,28 +709,14 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
777709 if errTarget != nil {
778710 errAcc = multierror .Append (errAcc , errTarget )
779711 }
780- if len (targets ) > 0 {
781- for _ , target := range targets {
782- if targetType , found := c .getTargetType (target .target ); found {
783- processedConfig .QueryTarget = append (processedConfig .QueryTarget , targetType )
784- } else {
785- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName ))
786- }
787- if val , exists := target .properties ["useCommonTable" ]; exists {
788- processedConfig .UseCommonTable = val == true
789- }
712+ for _ , target := range targets {
713+ if targetType , found := c .getTargetType (target .target ); found {
714+ processedConfig .QueryTarget = append (processedConfig .QueryTarget , targetType )
715+ } else {
716+ errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName ))
790717 }
791- }
792- // fallback to old style, simplified target configuration
793- if len (targets ) == 0 {
794- if _ , ok := indexConfig .Target .([]interface {}); ok {
795- for _ , target := range indexConfig .Target .([]interface {}) {
796- if targetType , found := c .getTargetType (target .(string )); found {
797- processedConfig .QueryTarget = append (processedConfig .QueryTarget , targetType )
798- } else {
799- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName ))
800- }
801- }
718+ if val , exists := target .properties ["useCommonTable" ]; exists {
719+ processedConfig .UseCommonTable = val == true
802720 }
803721 }
804722 if len (processedConfig .QueryTarget ) == 2 && ! ((processedConfig .QueryTarget [0 ] == ClickhouseTarget && processedConfig .QueryTarget [1 ] == ElasticsearchTarget ) ||
@@ -837,28 +755,14 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
837755 if errTarget != nil {
838756 errAcc = multierror .Append (errAcc , errTarget )
839757 }
840- if len (targets ) > 0 {
841- for _ , target := range targets {
842- if targetType , found := c .getTargetType (target .target ); found {
843- processedConfig .IngestTarget = append (processedConfig .IngestTarget , targetType )
844- } else {
845- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName ))
846- }
847- if val , exists := target .properties ["useCommonTable" ]; exists {
848- processedConfig .UseCommonTable = val == true
849- }
758+ for _ , target := range targets {
759+ if targetType , found := c .getTargetType (target .target ); found {
760+ processedConfig .IngestTarget = append (processedConfig .IngestTarget , targetType )
761+ } else {
762+ errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName ))
850763 }
851- }
852- // fallback to old style, simplified target configuration
853- if len (targets ) == 0 {
854- if _ , ok := indexConfig .Target .([]interface {}); ok {
855- for _ , target := range indexConfig .Target .([]interface {}) {
856- if targetType , found := c .getTargetType (target .(string )); found {
857- processedConfig .IngestTarget = append (processedConfig .IngestTarget , targetType )
858- } else {
859- errAcc = multierror .Append (errAcc , fmt .Errorf ("invalid target %s in configuration of index %s" , target , indexName ))
860- }
861- }
764+ if val , exists := target .properties ["useCommonTable" ]; exists {
765+ processedConfig .UseCommonTable = val == true
862766 }
863767 }
864768 conf .IndexConfig [indexName ] = processedConfig
@@ -980,6 +884,12 @@ func (c *QuesmaNewConfiguration) getTargetsExtendedConfig(target any) ([]struct
980884
981885 if targets , ok := target .([]interface {}); ok {
982886 for _ , target := range targets {
887+ if targetName , ok := target .(string ); ok {
888+ result = append (result , struct {
889+ target string
890+ properties map [string ]interface {}
891+ }{target : targetName , properties : map [string ]interface {}{}})
892+ }
983893 if targetMap , ok := target .(map [string ]interface {}); ok {
984894 for name , settings := range targetMap {
985895 if settingsMap , ok := settings .(map [string ]interface {}); ok {
0 commit comments