bundle agent function_meta(prefix,params)
{

  vars:

    any::
      # variables
      "$(prefix)confidx"       slist   => getindices("$(prefix)_vars.conf");
      "$(prefix)mainfile"      string  => "$(globals.dir_cache)/main/$(prefix)/config.csv";
      "$(prefix)archfile"      string  => "$(globals.dir_cache)/$(architectures_vars.architecture_name)/$(prefix)/config.csv";
      "$(prefix)concatfile"    string  => "$(globals.dir_cache)/main/$(prefix)/concat.csv";
      # readfile
      "$(prefix)len"           int     => readstringarrayidx("$(prefix)meta","$($(prefix)concatfile)","\s*#[^\n]*",";",10000,4000000);

    architecture_defined::
      "concatlist"             slist   => { "function_meta.$(prefix)mainfile", "function_meta.$(prefix)archfile" };

    !architecture_defined::
      "concatlist"             slist   => { "function_meta.$(prefix)mainfile" };

    any::
      "$(prefix)servicebundle"  string => "$(prefix)_vars.meta";
      "$(prefix)metaidx"        slist  => { getindices("$(prefix)meta") };
      "$(prefix)types"          slist  => getindices("$($(prefix)servicebundle)");
      "$(prefix)fields"         slist  => getindices("$(prefix)_vars.meta[$($(prefix)types)]");

      "$(prefix)$($(prefix)meta[$($(prefix)metaidx)][0])[$($(prefix)metaidx)][$($(prefix)fields)]"
        string      => "$($(prefix)meta[$($(prefix)metaidx)][$($($(prefix)servicebundle)[$($(prefix)types)][$($(prefix)fields)])])",
        ifvarclass  => "$($(prefix)meta[$($(prefix)metaidx)][1])";

  classes:

    any::
      "$(prefix)meta_ok" not => regcmp("0","$($(prefix)len)");

  files:

        "$($(prefix)mainfile)"
            create      => "true",
            copy_from => u_dcp("$(globals.resources_location)/main/$(prefix)/config.csv");

        "$($(prefix)archfile)"
            create      => "true",
            copy_from   => u_dcp("$(globals.resources_location)/$(architectures_vars.architecture_name)/$(prefix)/config.csv"),
            ifvarclass  => "architecture_defined";

        "$($(prefix)concatfile)"
            create        => "true",
            edit_defaults => empty,
            edit_line     => concatWith(@(this.concatlist));

}

bundle edit_line concatWith(file)
{

  insert_lines:

    "$($(file))"
      insert_type    => "file_preserve_block",
      expand_scalars => "false";
}