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

It would be nice if format() could take strings from functions like readdata() (collecting behavior)

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Open
    • Priority: (None)
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Complexity:
      S

      Description

      format() can currently take a data container, but it errors when taking a function that returns a data container.

      https://gist.github.com/nickanderson/4fc7ae53598f7d2f2407131edbcc64c6.

      Example showing format should take functions that return data.

      bundle agent main
      {
        vars:
          "peers" slist => { "one", "two" };
          "year" string => strftime( localtime, "%Y", now() );
          "month" string => strftime( localtime, "%m", now() );
      
          "$(peers)" data => '{ "some-data": "$(peers)" }';
      
        "WORKS[$(peers)]"
          string => format( "%S", "$(peers)" );
      
        "ERRORS[$(peers)]"
          string => format( "%S", parsejson( '{ "some-data": "$(peers)" }' ) );
      }
      
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
         error: format() didn't have enough parameters
      Variable name                            Variable value                                               Meta tags                               
      default:main.WORKS[one]                  {\"some-data\":\"one\"}                                      source=promise                          
      default:main.WORKS[two]                  {\"some-data\":\"two\"}                                      source=promise                          
      default:main.month                       07                                                           source=promise                          
      default:main.one                         {"some-data":"one"}                                          source=promise                          
      default:main.peers                        {"one","two"}                                               source=promise                          
      default:main.two                         {"some-data":"two"}                                          source=promise                          
      default:main.year                        2019                                                         source=promise                          
      default:maintain_key_values_meta.tags     {"deprecated=3.6.0","deprecation-reason=Generic reimplementation","replaced-by=set_line_based"} source=promise                          
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:

                Summary Panel