Files
mgmt/test/shell/env0.mcl
James Shubin 9dae5ef83b engine: resources: Improve the file res and add strict state
This might be slightly controversial, in that you must specify the state
if a file would need to be created to perform the action. We no longer
implicitly assume that just specifying content is enough. As it turns
out, I believe this is safer and more correct. The code to implement
this turns out to be much more logical and simplified, and does this
removes an ambiguous corner case from the reversed resource code.

Some discussion in: https://github.com/purpleidea/mgmt/issues/540

This patch also does a bit of related cleanup.
2019-09-14 16:07:53 -04:00

24 lines
518 B
Plaintext

import "fmt"
import "sys"
$tmpdir = sys.defaultenv("TMPDIR", "/tmp")
$x = sys.getenv("TEST")
$y = sys.getenv("DOESNOTEXIST")
$z = sys.getenv("EMPTY")
$a = sys.defaultenv("TEST", "321")
$b = sys.defaultenv("DOESNOTEXIST", "321")
$c = sys.defaultenv("EMPTY", "456")
$t = sys.hasenv("TEST")
$f = sys.hasenv("DOESNOTEXIST")
$env = sys.env()
$m = maplookup($env, "TEST", "321")
file "${tmpdir}/environ" {
state => "exists",
content => fmt.printf("%s,%s,%s:%s,%s,%s:%t,%t:%s", $x, $y, $z, $a, $b, $c, $t, $f, $m),
}