engine: resources: Add new gzip resource

This may have lots of uses, particularly for bootstrapping and handoff
if we want to compress payloads. It is also a good model resource for
how to implement such a resource to avoid re-computing the result on
every CheckApply call. Of course if the computation is cheaper than the
hashing of the data this isn't the optimal approach.
This commit is contained in:
James Shubin
2024-09-13 03:32:10 -04:00
parent 9a5f6a5bd3
commit 5bbc06d8bc
2 changed files with 537 additions and 0 deletions

17
examples/lang/gzip.mcl Normal file
View File

@@ -0,0 +1,17 @@
# gzip a file!
file "/tmp/input" {
state => "exists",
content => "hello world from purpleidea!\n",
}
gzip "/tmp/input.gz" {
input => "/tmp/input",
level => $const.res.gzip.level.no_compression,
Depend => File["/tmp/input"], # TODO: add autoedges
}
gzip "/tmp/data.gz" {
content => "hello world from purpleidea!\n",
level => $const.res.gzip.level.best_compression,
}