Re: per-promise 'inform => "false"'?

"'Nick Anderson' via help-cfengine" <[email protected]> Thu, 31 Aug 2023 12:13:58 -0500
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
  Re-sent, there were supposed to be examples included, oops.

        Thanks, Nick!

        I was unaware of the "report_to_file" functionality on
        "reports::". That's good to know.

  There are a few `reports' promise features that are little known. The
  `printfile' body comes to mind which emits a files content as a
  report.

  ,----
  | bundle agent __main__
  | {
  |   reports:
  |     "I am $(this.promise_filename).";
  |     "I contain" printfile => cat( $(this.promise_filename) );
  | }
  `----
  Listing 1: Example illustrating body printfile cat

  ,----
  | R: I am $(this.policy_filename).
  | R: I contain
  | R: body file control{ inputs => { '$(sys.libdir)/stdlib.cf' };}
  | R: bundle agent __main__
  | R: {
  | R:   reports:
  | R:     "I am $(this.policy_filename).";
  | R:     "I contain" printfile => cat( $(this.promise_filename) );
  | R: }
  `----


  Also the `return_value_index' attribute, which defines an associative
  array key for the variable named by the `useresult' attribute for the
  calling `methods' type promise in the calling bundle.

  ,----
  | bundle agent __main__
  | {
  |   methods:
  |
  |       "Call a bundle, define an associative array as a byproduct"
  |         usebundle => example_bundle_return_value_index_and_useresult("value 1"),
  |         useresult => "my_array";
  |
  |       "Call a bundle, define an associative array as a byproduct"
  |         usebundle => example_bundle_return_value_index_and_useresult(""),
  |         useresult => "my_array";
  |
  |   reports:
  |       "JSON representation of 'my_array' :$(const.n) $(with)"
  |         with => storejson( mergedata( my_array ) );
  | }
  | bundle agent example_bundle_return_value_index_and_useresult(param)
  | {
  |   reports:
  |       "Value 0"
  |         bundle_return_value_index => "0";
  |
  |       "Value 2"
  |         bundle_return_value_index => "two";
  |
  |       "$(with)"
  |         with => string_upcase( "$(param)" ), # Here we upcase the value of param and use it as the value for the key returned
  |         bundle_return_value_index => "$(param)"; # Here the parameter value is used to set the key that is returned
  |
  | }
  `----
  Listing 2: Example illustrating useresult and
  bundle_return_value_index

  ,----
  | R: JSON representation of 'my_array' :
  |  {
  |   "0": "Value 0",
  |   "two": "Value 2",
  |   "value 1": "VALUE 1"
  | }
  `----


        Enterprise reporting? Well, for ages I've been gently
        trying to push Enterprise here. A few months ago, we
        started pursuing it, but the cost, even after some
        negotiation was going to be prohibitive. (In contrast to
        technical aspects of CFE, this aspect is out of my hands.)

  Yeah, that's unfortunate. But, I like to eat so I gotta suggest it :D.

-- 
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/87il8v6so9.fsf%40northern.tech.