Since we focus on safety, it would be nice to reduce the chance of any
runtime errors if we made a typo for a resource parameter. With this
patch, each resource can export constants into the global namespace so
that typos would cause a compile error.
Of course in the future if we had a more advanced type system, then we
could support precise types for each individual resource param, but in
an attempt to keep things simple, we'll leave that for another day. It
would add complexity too if we ever wanted to store a parameter
externally.
Lastly, we might consider adding "special case" parsing so that directly
specified fields would parse intelligently. For example, we could allow:
file "/tmp/hello" {
state => exists, # magic sugar!
}
This isn't supported for now, but if it works after all the other parser
changes have been made, it might be something to consider.
34 lines
811 B
Plaintext
34 lines
811 B
Plaintext
file "/tmp/frags/" {
|
|
state => $const.res.file.state.exists,
|
|
}
|
|
|
|
# fragments
|
|
file "/tmp/frags/f1" {
|
|
state => $const.res.file.state.exists,
|
|
content => "i am f1\n",
|
|
}
|
|
file "/tmp/frags/f2" {
|
|
state => $const.res.file.state.exists,
|
|
content => "i am f2\n",
|
|
}
|
|
file "/tmp/frags/f3" {
|
|
state => $const.res.file.state.exists,
|
|
content => "i am f3\n",
|
|
}
|
|
|
|
# You can also drop in an unmanaged file into the frags dir for it to get used!
|
|
# And of course you can hard-code the list of files to use like this one is...
|
|
file "/tmp/bonus_file" {
|
|
state => $const.res.file.state.exists,
|
|
content => "i am a bonus file\n",
|
|
}
|
|
|
|
# automatic edges will get added!
|
|
file "/tmp/whole1" {
|
|
state => $const.res.file.state.exists,
|
|
fragments => [
|
|
"/tmp/frags/", # pull from this dir
|
|
"/tmp/bonus_file", # also pull this one file
|
|
],
|
|
}
|