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

Support regexes in class guards

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Spawned from: https://tracker.mender.io/browse/CFE-2971

      In my opinion, it should work the same way in policy as in augments. (So, what you can use in a class guard, you can use in augments). The best suggestion seems to be to support regex with /regex/ syntax, and class expressions with no prefix (as in policy).

      {
          "classes": {
              "class_expression":
              [ "redhat|aix" ],
              "class_expression_or_regex":
              [ "(redhat.PROD)|(debian.TEST)",
                "/cfengine.*/" ],
      }

      Equivalent:

      bundle agent main
      {
        classes:
          redhat|aix::
            "class_expression";
          /cfengine.*/|(redhat.PROD)|(debian.TEST)::
            "class_expression_or_regex";
      } 
      

      Policy doesn't support this currently, so it is an effort to implement. It is a breaking change, but only affects augments files, and should be easy to modify if you are already using regular expressions.

      I agree that augments should be used for "simple stuff"; defining classes and inputting data/variables. Augments should not replace policy. However I think if it worked exactly the same as a class guard, it would be pretty clear and straight forward. I don't like the suggestions of % prefixes or similar, even though they are technically backwards compatible. We should not invent a new syntax / DSL inside augments.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              olehermanse Ole Herman Schumacher Elgesem
              Reporter:
              olehermanse Ole Herman Schumacher Elgesem
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated: