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

string() policy function

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.18.0
    • Component/s: Built-in functions
    • Labels:
    • Story Points:
      0

      Description

      It would be convenient to have a function that can take something like an int, or a bool (context) and returns a string. Currently you can use concat for this, but it's not so readable.

      This is not something you need very often, the most reasonable example I can make is:

      bundle agent main
      {
        vars:
          "class_expressions"
            slist => {
              "my_class.your_class",
              string(and("my_class", strcmp("$(my_string)", "abc"))),
            };
      }
      

      string function is necessary here because and() returns boolean.
      We have type checking to ensure all elements of the slist are strings, but in this case I want to convert the boolean(class expression) to its string representation.

      Current workaround:

      bundle agent main
      {
        vars:
          "class_expressions"
            slist => {
              "my_class.your_class",
              concat(and("my_class", strcmp("$(my_string)", "abc"))),
            };
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Alias Georgios Kotzampopoulos
                Reporter:
                olehermanse Ole Herman Schumacher Elgesem
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel