@@ -754,7 +754,9 @@ static enum status state_copy_into_properties(struct parser_state *state, struct
754754 struct cfl_kvpair * kvp ;
755755 struct cfl_variant * var ;
756756 struct cfl_array * arr ;
757- int idx ;
757+ size_t idx ;
758+ size_t entry_count ;
759+ int array_all_strings ;
758760
759761 cfl_list_foreach (head , & state -> keyvals -> list ) {
760762 kvp = cfl_list_entry (head , struct cfl_kvpair , _head );
@@ -773,33 +775,57 @@ static enum status state_copy_into_properties(struct parser_state *state, struct
773775 }
774776 break ;
775777 case CFL_VARIANT_ARRAY :
776- arr = flb_cf_section_property_add_list ( conf , properties ,
777- kvp -> key , cfl_sds_len ( kvp -> key )) ;
778+ entry_count = kvp -> val -> data . as_array -> entry_count ;
779+ array_all_strings = 1 ;
778780
779- if (arr == NULL ) {
780- flb_error ("unable to add property list" );
781- return YAML_FAILURE ;
782- }
783- for (idx = 0 ; idx < kvp -> val -> data .as_array -> entry_count ; idx ++ ) {
781+ for (idx = 0 ; idx < entry_count ; idx ++ ) {
784782 var = cfl_array_fetch_by_index (kvp -> val -> data .as_array , idx );
783+ if (var == NULL || var -> type != CFL_VARIANT_STRING ) {
784+ array_all_strings = 0 ;
785+ break ;
786+ }
787+ }
788+
789+ if (array_all_strings == 1 ) {
790+ arr = flb_cf_section_property_add_list (conf , properties ,
791+ kvp -> key , cfl_sds_len (kvp -> key ));
785792
786- if (var == NULL ) {
787- flb_error ("unable to retrieve from array by index " );
793+ if (arr == NULL ) {
794+ flb_error ("unable to add property list " );
788795 return YAML_FAILURE ;
789796 }
790- switch (var -> type ) {
791- case CFL_VARIANT_STRING :
797+
798+ for (idx = 0 ; idx < entry_count ; idx ++ ) {
799+ var = cfl_array_fetch_by_index (kvp -> val -> data .as_array , idx );
792800
793801 if (cfl_array_append_string (arr , var -> data .as_string ) < 0 ) {
794802 flb_error ("unable to append string to array" );
795803 return YAML_FAILURE ;
796804 }
797- break ;
798- default :
799- flb_error ("unable to copy value for property" );
805+ }
806+ }
807+ else {
808+ if (flb_cf_section_property_add_variant (conf ,
809+ properties ,
810+ kvp -> key ,
811+ cfl_sds_len (kvp -> key ),
812+ kvp -> val ) == NULL ) {
813+ flb_error ("unable to add variant property" );
800814 return YAML_FAILURE ;
801815 }
816+ kvp -> val = NULL ;
817+ }
818+ break ;
819+ case CFL_VARIANT_KVLIST :
820+ if (flb_cf_section_property_add_variant (conf ,
821+ properties ,
822+ kvp -> key ,
823+ cfl_sds_len (kvp -> key ),
824+ kvp -> val ) == NULL ) {
825+ flb_error ("unable to add variant property" );
826+ return YAML_FAILURE ;
802827 }
828+ kvp -> val = NULL ;
803829 break ;
804830 default :
805831 flb_error ("unknown value type for properties: %d" , kvp -> val -> type );
@@ -1990,6 +2016,10 @@ static int consume_event(struct flb_cf *conf, struct local_ctx *ctx,
19902016 if (state -> section == SECTION_PROCESSOR ) {
19912017 state = state_push_variant (ctx , state , 0 );
19922018 }
2019+ else if (strcmp (state -> key , "routes" ) == 0 ||
2020+ strcmp (state -> key , "processors" ) == 0 ) {
2021+ state = state_push_variant (ctx , state , 0 );
2022+ }
19932023 else {
19942024 state = state_push_witharr (ctx , state , STATE_PLUGIN_VAL_LIST );
19952025 }
@@ -2013,17 +2043,14 @@ static int consume_event(struct flb_cf *conf, struct local_ctx *ctx,
20132043 break ;
20142044 }
20152045
2016- if (strcmp (state -> key , "processors" ) == 0 ) {
2017- state = state_push (ctx , STATE_INPUT_PROCESSORS );
2046+ if (strcmp (state -> key , "routes" ) == 0 ||
2047+ strcmp (state -> key , "processors" ) == 0 ) {
2048+ state = state_push_variant (ctx , state , 1 );
20182049
20192050 if (state == NULL ) {
20202051 flb_error ("unable to allocate state" );
20212052 return YAML_FAILURE ;
20222053 }
2023-
2024- if (state_create_group (conf , state , "processors" ) == YAML_FAILURE ) {
2025- return YAML_FAILURE ;
2026- }
20272054 break ;
20282055 }
20292056
0 commit comments