engine, lang: Modern exported resources
I've been waiting to write this patch for a long time. I firmly believe that the idea of "exported resources" was truly a brilliant one, but which was never even properly understood by its original inventors! This patch set aims to show how it should have been done. The main differences are: * Real-time modelling, since "once per run" makes no sense. * Filter with code/functions not language syntax. * Directed exporting to limit the intended recipients. The next step is to add more "World" reading and filtering functions to make it easy and expressive to make your selection of resources to collect!
This commit is contained in:
27
examples/lang/export0.mcl
Normal file
27
examples/lang/export0.mcl
Normal file
@@ -0,0 +1,27 @@
|
||||
file "/tmp/hello" {
|
||||
content => "hello world from @purpleidea\n",
|
||||
state => $const.res.file.state.exists,
|
||||
|
||||
Meta:hidden => true,
|
||||
|
||||
#Meta:export => ["*",], # export to all
|
||||
#Meta:export => ["hostname1",], # export to just this one
|
||||
Meta:export => [ # export to everyone in this list
|
||||
"${hostname}",
|
||||
"hostname2",
|
||||
"hostname3",
|
||||
],
|
||||
}
|
||||
|
||||
collect file "/tmp/hello" {
|
||||
#content => "i was collected\n", # override
|
||||
|
||||
Meta:hidden => false,
|
||||
}
|
||||
|
||||
# collect a more complex way (use helper functions here instead!)
|
||||
collect file [
|
||||
struct{name => "/tmp/hello", host => "${hostname}",},
|
||||
] {
|
||||
Meta:hidden => false,
|
||||
}
|
||||
Reference in New Issue
Block a user