Skip to content

Commit

Permalink
Fixes #14128: Split ncf_lib like cfengine lib
Browse files Browse the repository at this point in the history
  • Loading branch information
amousset committed Jan 9, 2019
1 parent 4304a45 commit 4a86a0b
Show file tree
Hide file tree
Showing 16 changed files with 2,133 additions and 2,106 deletions.
23 changes: 23 additions & 0 deletions tree/20_cfe_basics/commands.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#####################################################################################
# Copyright 2013 Normation SAS
#####################################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################################

body contain outputable
{
useshell => "true";
no_output => "false";
}
346 changes: 346 additions & 0 deletions tree/20_cfe_basics/common.cf

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,24 @@
# WARNING:
#
# @parameter mode The dry-run mode, "true" to enable dry-run-mode and "false" to disable it
# @agent_requirements "capabilities": [ "bodydefault" ] || "agent_version" >= 3.9
#

bundle agent set_dry_run_mode(mode)
{
vars:
# this is a way to remove the class without side effect
pass2.unset_mode::
"ignored" string => "", classes => if_ok_cancel("dry_run");
"ignored" string => "",
classes => if_ok_cancel("dry_run");

classes:
# double negation, so that the default is dry_run (in case of error)
"unset_mode" expression => strcmp("${mode}", "false");
"pass2" expression => "pass1";
"pass1" expression => "any";
"pass2" expression => "pass1";
"pass1" expression => "any";

pass2.!unset_mode::
"dry_run" expression => "any", scope => "namespace";
"dry_run" expression => "any", scope => "namespace";

reports:
pass2.debug.unset_mode::
Expand All @@ -105,12 +105,13 @@ bundle agent set_dry_run_mode(mode)

# This bundle initializes the context for push/pop
# It is called in 10_ncf_internals/initialization.cf
bundle agent dry_run_initialization {
bundle agent dry_run_initialization
{
vars:
# designed to be incremented when a global unique ID is needed
"dry_run_unique.value" string => "1";
# stack of dry_run modes
"dry_run_unique.stack" slist => {};
"dry_run_unique.stack" slist => {};
}

# Push current dry-run mode to the stack and set a new mode instead.
Expand Down Expand Up @@ -271,4 +272,3 @@ body file control
{
namespace => "default";
}

46 changes: 0 additions & 46 deletions tree/20_cfe_basics/dry_run_lib.unsupported.cf

This file was deleted.

Loading

0 comments on commit 4a86a0b

Please sign in to comment.