]> granicus.if.org Git - icinga2/commitdiff
Make script variables constant.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 12 Feb 2014 10:49:38 +0000 (11:49 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 12 Feb 2014 10:51:50 +0000 (11:51 +0100)
Fixes #5446

doc/2.6-running-icinga-2.md
doc/3.03-macros.md
doc/4.1-configuration-syntax.md
doc/4.2-global-variables.md
icinga-app/icinga.cpp
lib/config/config_parser.yy

index bcbbdfa1cf097e9b247e56140d5b4f9dd1e00473..b338b8e224897144f9734de081557391ae5a4a1f 100644 (file)
@@ -32,7 +32,7 @@ Icinga 2's init script is installed in `/etc/init.d/icinga2` by default:
       -V [ --version ]      show version information
       -l [ --library ] arg  load a library
       -I [ --include ] arg  add include search directory
-         -D [ --define] args   define a variable
+         -D [ --define] args   define a constant
       -c [ --config ] arg   parse a configuration file
       -C [ --validate ]     exit after validating the configuration
       -x [ --debug ]        enable debugging
@@ -50,9 +50,9 @@ Icinga 2's init script is installed in `/etc/init.d/icinga2` by default:
 Instead of loading libraries using the [`library` config directive](#library)
 you can also use the `--library` command-line option.
 
-#### Variables
+#### Constants
 
-[Global variables](#global-variables) can be set using the `--define` command-line option.
+[Global constants](#global-constants) can be set using the `--define` command-line option.
 
 #### Config Include Path
 
index 84e1ad00ba5a35eb9a1ade5811b507d36b7260f7..cbea18376ec1a6e166fd6a9a95688c817b46e219 100644 (file)
@@ -3,7 +3,7 @@
 
 > **Note**
 >
-> There is a limited set of special [global variables](#global-variables) which can be re-used and
+> There is a limited set of special [global constants](#global-constants) which can be re-used and
 > also partly overridden such as `IcingaEnableChecks`. 
 
 ### <a id="runtime-macros"></a> Runtime Macros
@@ -64,7 +64,7 @@ up macros:
 2. Service object
 3. Host object
 4. Command object
-5. Global macros in the IcingaMacros variable
+5. Global macros in the IcingaMacros constant
 
 This execution order allows you to define default values for macros in your
 command objects. The `my-ping` command shown above uses this to set default
@@ -262,7 +262,7 @@ when passing credentials to database checks:
 
 ### <a id="configuration-macros"></a> Configuration Macros
 
-Icinga 2 allows you to define constant variables which can be used in a limited
+Icinga 2 allows you to define constants which can be used in a limited
 scope. For example, constant expressions can reference a pre-defined global constant
 variable and calculate a value for the service check interval.
 
@@ -276,4 +276,4 @@ Example:
       check_interval = (MyCheckInterval / 2.5)
     }
 
-More details in the chapter [Constant Expressions](#constant-expressions).
\ No newline at end of file
+More details in the chapter [Constant Expressions](#constant-expressions).
index d31a614c3544ff5822d8485b8fc9e9e07bb162e2..a0c3795aa99e95179d030e2ca6e637d6c055b372 100644 (file)
@@ -296,21 +296,20 @@ dictionary by exiplicitely overriding their value with `null`.
     services["ping6"] = null
 
 
-### <a id="variables"></a> Variables
+### <a id="constants"></a> Constants
 
-Global variables can be set using the `var` and `const` keywords:
+Global constants can be set using the `const` keyword:
 
-    var VarName = "some value"
+    const VarName = "some value"
 
 The value can be a string, number, array or a dictionary.
 
-Variables can be set multiple times unless they were introduced using
-the `const` keyword.
+Constants cannot be changed once they are set.
 
 > **Note**
 >
-> The `set` keyword is an alias for the `var` keyword and is available
-> in order to provide compatibility with older versions. Its use is
+> The `set` and `var` keywords are an alias for `const` and are available
+> in order to provide compatibility with older versions. Their use is
 > deprecated.
 
 ### <a id="constant-expressions"></a> Constant Expressions
@@ -328,7 +327,7 @@ overridden by grouping expressions using parentheses:
       check_interval ((15 * 60) / 2)
     }
 
-Global variables may be used in constant expressions.
+Global constants may be used in constant expressions.
 
     var MyCheckInterval = 10m
 
index 98c82c856c0eac083be418fd2cd19deb6c102c57..eb9560504b65aee67e13d6c92ead66a44cdea577 100644 (file)
@@ -1,6 +1,6 @@
-## <a id="global-variables"></a> Global Variables
+## <a id="global-constants"></a> Global Constants
 
-Icinga 2 provides a number of special global variables:
+Icinga 2 provides a number of special global constants. Some of them can be overriden using the `--define` command line parameter:
 
 Variable                  |Description
 --------------------------|-------------------
index 66af811752b118b01dc2cf18e28d07a8496a0612..33a87b9e27fc9090f346a6015ef3ff6871d4015f 100644 (file)
@@ -209,7 +209,7 @@ int main(int argc, char **argv)
                ("version,V", "show version information")
                ("library,l", po::value<std::vector<String> >(), "load a library")
                ("include,I", po::value<std::vector<String> >(), "add include search directory")
-               ("define,D", po::value<std::vector<String> >(), "define a variable")
+               ("define,D", po::value<std::vector<String> >(), "define a constant")
                ("config,c", po::value<std::vector<String> >(), "parse a configuration file")
                ("no-config,z", "start without a configuration file")
                ("validate,C", "exit after validating the configuration")
index 9102c1dbd9855be1f9b3e2542b2730c4eb875f0c..122d8bb77c80691dc97f8fb50b2b6a8df2efbbfb 100644 (file)
@@ -203,9 +203,7 @@ variable: variable_decl identifier T_EQUAL value
                }
 
                ScriptVariable::Ptr sv = ScriptVariable::Set($2, *value);
-
-               if (!$1)
-                       sv->SetConstant(true);
+               sv->SetConstant(true);
 
                free($2);
                delete value;