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

Function for canonifying slists (canonify mode for mapdata())

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done
    • Priority: (None)
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.9.0
    • Component/s: Built-in functions
    • Labels:
      None

      Description

      canonify mode for mapdata()

      bundle agent main
      {
        vars:
          "list" slist => { "one-one", "two-two" };
      
          "canonified_values"
            data => mapdata( canonify, "$(this.v)", list );
      
          "canonified_keys"
            data => mapdata( canonify, "$(this.k)", list );
      
      }
      
      # cf-agent --no-lock --log-level info --show-evaluated-vars=main.canonified --file /tmp/example-mapdata-canonify.cf
      Variable name                            Variable value                                               Meta tags                               
      default:main.canonified_keys             ["0","1"]                                                    source=promise                          
      default:main.canonified_values           ["one_one","two_two"]                                        source=promise                          

      Original Issue

      The process for canonifying an slist is somewhat cumbersome. Currently, the way of doing this requires an intermediary variable like this:

      bundle agent canonify_slist_the_hard_way
      {
        vars:
          "list" slist => {"some#string", "some!other.string>"};
          "list_c_map[$(list)]" string => canonify("$(list)");
          "list_c" slist => maplist("$(list_c_map[$(this)])", "list");
      }
      

      It would be nice to have a builtin function to simplify the process to something like this:

      bundle agent canonify_slist_the_easy_way
      {
        vars:
          "list" slist => {"some#string", "some!other.string>"};
          "list_c" slist => canonify_slist("list");
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10040 Kristian Amlie
                Reporter:
                sanders John Sanders (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel