-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfuture_41_struct_pup-4483.pp
57 lines (45 loc) · 1.19 KB
/
future_41_struct_pup-4483.pp
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
# Test using a data type as the key in a struct.
$hashone = {
mode => write,
path => '/etc/puppetlabs',
links => 3,
thing => undef,
}
$hashtwo = {
mode => write,
path => '/etc/puppetlabs',
links => 3,
}
$structone = Struct[ {
mode => Enum[read, write, update],
path => String[1],
links => Integer,
thing => Optional[Integer],
}]
$structtwo = Struct[ {
mode => Enum[read, write, update],
path => String[1],
links => Integer,
NotUndef['thing'] => Optional[Integer],
}]
$structthree = Struct[ {
mode => Enum[read, write, update],
path => String[1],
links => Integer,
Enum['thing'] => Optional[Integer],
}]
notice( $hashone =~ $structone )
# true
notice( $hashone =~ $structtwo )
# true
notice( $hashtwo =~ $structone )
# true
notice( $hashtwo =~ $structtwo )
# false
notice( $hashone =~ $structthree )
# true
notice( $hashtwo =~ $structthree )
# false
# HA HA, so Enum['thing'] is the same as NotUndef['thing'], just like I suspected. This fits my intuition, but it contradicts the spec
# https://github.com/puppetlabs/puppet-specifications/blob/master/language/types_values_variables.md#struct-type
# ...which says you should only use NotUndef and Optional in the key.