File: string_contexts.cf

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (86 lines) | stat: -rw-r--r-- 2,677 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# fixes https://dev.cfengine.com/issues/2504
# using variables in string contexts

body common control
{
      inputs => { "../../default.cf.sub" };
      bundlesequence  => { default("$(this.promise_filename)") };
      version => "1.0";
}

#######################################################

bundle agent test
{
  defaults:
      "s1" string => "1";
      "s2" string => "2";
      "s3" string => "3";
      "s4" string => "4";
      "s5" string => "5";
      "s6" string => "6";
      "s7" string => "7";
      "s8" string => "8";

  classes:
      "$(mylist)" expression => "any";

  vars:
      "mylist" slist => { "a", "b", "c" };
      "myvar" string => "me";
      "myclass" string => "any";
      "s1" string => "hello, this is $(myvar)",
      if => "$(myclass)";
    any::
      "s2" string => "any hello";
    'any'::
      "s3" string => "string hello";
    "$(myclass)"::
      "s4" string => "variable context hello!!!";
      "s4_2" string => "variable context hello!!!";
    "$(myclass).any"::
      "s5" string => "compound variable context hello!!!";
    "not$(myclass)"::
      "s6" string => "BAD variable context hello!!!";
    "$(myclass)"::
      "s7" string => "augmented variable context hello!!!",
      if => "any";

    "$(myclass)"::
      "s8" string => "BAD augmented variable context hello!!!",
      if => "nonesuch";
    "$(mylist).cfengine"::
      "iterated_$(mylist)" string => "iteration class $(mylist)";

    "myclass . cfengine | any"::
      "whitespace1" string => "$(this.promiser): quoted with spaces";

    myclass . cfengine | any::
      "whitespace2" string => "$(this.promiser): unquoted with spaces, starts with valid class";

    nosuchclass . any::
      "whitespace3" string => "$(this.promiser): unquoted with spaces, should be missing";

    nosuchclass | any::
      "whitespace4" string => "$(this.promiser): unquoted with spaces, starts with missing class but is true";

    any	 |	 ( cfengine | linux )::
      "whitespace5" string => "$(this.promiser): remove spaces and tabs from an expression";

    any	 .	 ( nosuchclass . any )::
      "whitespace6" string => "$(this.promiser): remove spaces and tabs from an expression that is false in the end, should be missing";

    "cf engine"::
      "whitespace7" string => "$(this.promiser): quoted with spaces but no operators, should be missing with an error";

}

#######################################################

bundle agent check
{
  methods:
      "check"  usebundle => dcs_check_state(test,
                                           "$(this.promise_filename).expected.json",
                                           $(this.promise_filename));
}