bundlesmatching

Table of Contents
Table of Contents

Prototype: bundlesmatching(name, tag1, tag2, ...)

Return type: slist

Description: Return the list of defined bundles matching name and any tags given. Both bundlename and tags are regular expressions. name is required, tags are optional.

This function searches for the given unanchored name and tag1,tag2`,... regular expression in the list of currently defined bundles.

Every bundle is prefixed with the namespace, usually default:.

When any tags are given, only the bundles with those tags are returned. Bundle tags are set a tags variable within a meta promise; see the example below.

This function, used together with the findfiles function, allows you to do dynamic inputs and a dynamic bundle call chain. The dynamic chain is constrained by an explicit regular expression to avoid accidental or intentional running of unwanted bundles.

Arguments:

  • name: string, in the range: .*

Example:

body common control
{
      bundlesequence => { mefirst };
}

bundle common g
{
  vars:
      "todo" slist => bundlesmatching("default:run.*");
}

bundle agent mefirst
{
  methods:
      # note this is a dynamic bundle sequence!
      "" usebundle => $(g.todo);
}

bundle agent run_deprecated
{
  meta:
      "tags" slist => { "deprecated" };
}

bundle agent run_123_456
{
  vars:
      "bundles" slist => bundlesmatching(".*");
      "deprecated_bundles" slist => bundlesmatching(".*", "deprecated");
      "no_bundles" slist => bundlesmatching("891");
  reports:
      "bundles = $(bundles)";
      "deprecated bundles = $(deprecated_bundles)";
      "no bundles = $(no_bundles)";
}

Output:

R: bundles = default:run_123_456
R: bundles = default:run_deprecated
R: bundles = default:mefirst
R: bundles = default:g
R: deprecated bundles = default:run_deprecated

See also: findfiles().