Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-1976

As a policy writer I want to be able to get the values for variables that are found by variablesmatching

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.10.0
    • Component/s: None
    • Labels:
      None

      Description

      Today getting the values out of variables based on the return of variablesmatching is tricky and error prone.

      Here is an example based on data containers
      https://gist.github.com/neilhwatson/da3176a83d397600bfca

      Trying to construct a classic array where the index is the value of the found variables results in a programming error (noted in #7254

      <pre>
      body common control
      {
      bundlesequence =>

      { "iptables" }

      ;
      }
      bundle agent any
      {
      vars:
      "open_ports" slist =>

      {"5308" }

      ;
      }
      bundle agent apache
      {
      vars:
      "open_ports" slist =>

      {"80"}

      ;
      }
      bundle agent iptables
      {
      vars:
      "port_list" slist => variablesmatching(".*open_ports");

      "port_array[$($(port_list))]" string => "1";
      }
      </pre>

      Getting the values of the variables that you found is a logical next step and I think we should make it easier.

      Perhaps a new function to getvaluesfromvariablesmatching() that returns a list of all values.

      Additionally being able to getvalues/indices from a list of lists could ease this.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10042 Nick Anderson
                Reporter:
                a10042 Nick Anderson
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: