diff --git a/demos/hello.bass b/demos/hello.bass index 953ded10..04521363 100644 --- a/demos/hello.bass +++ b/demos/hello.bass @@ -1,5 +1,5 @@ (defn main [lines] (-> ($ sh -c "for i in $(seq 1 $0); do echo line $i; sleep 0.5; done" $lines) - (with-label :start (now 0)) + (with-env {:START (now 0)}) (with-image (linux/alpine)) run)) diff --git a/demos/multi-fail.bass b/demos/multi-fail.bass index 791a5029..95bb9f64 100644 --- a/demos/multi-fail.bass +++ b/demos/multi-fail.bass @@ -1,7 +1,9 @@ (defn echo-sleep-exit [msg seconds exit-code] (subpath (from (linux/alpine) - (with-label ($ sleep (str seconds)) :at (now 0)) + (with-env + ($ sleep (str seconds)) + {:AT (now 0)}) ($ sh -c (str "echo \"$0\"; exit " exit-code) $msg)) ./)) diff --git a/demos/speedtest.bass b/demos/speedtest.bass index 4c2a2676..0e4d0d2f 100644 --- a/demos/speedtest.bass +++ b/demos/speedtest.bass @@ -8,7 +8,7 @@ (defn speedtest [] (from (speedtest-cli) (-> ($ speedtest --accept-license --format json-pretty) - (with-label :at (now 0))))) + (with-env {:NOW (now 0)})))) (defn main [] (let [results (next (read (speedtest) :json))] diff --git a/docs/lit/guide.lit b/docs/lit/guide.lit index 2cfacec3..3662c987 100644 --- a/docs/lit/guide.lit +++ b/docs/lit/guide.lit @@ -59,20 +59,20 @@ for common tasks. If you'd like to learn the language, see \reference{bassics}. Thunks are cached forever. They can be cleared with \code{bass --prune}, but this should only be necessary for regaining disk space. }{ - To influence caching, use \b{with-label} to stamp thunks with arbitrary - data. Two thunks that differ only in labels will be cached independently. + If you want to run a cache multiple times, just set a random value as an + environment variable: }{{{ - (run (with-label + (run (with-env (from (linux/alpine) - ($ echo "Hello, world!")) - :foo "bar")) + ($ echo "Hi again!")) + {:NOW (now 0)})) }}}{ Tip: to avoid deep nesting like above, consider the alternative \b{->} form. }{{{ - (-> ($ echo "Hello, world!") + (-> ($ echo "Hi again!") (with-image (linux/alpine)) - (with-label :foo "bar") + (with-env {:NOW (now 0)}) run) }}} } @@ -181,8 +181,8 @@ for common tasks. If you'd like to learn the language, see \reference{bassics}. (defn counter [tag] (from (linux/alpine) - (-> ($ sh -c "echo x >> /var/cache/file; cat /var/cache/file | wc -l") - (with-label :tag tag) + (-> ($ sh -c "echo $0 >> /var/cache/file; cat /var/cache/file | wc -l" + $tag) (with-mount my-cache /var/cache/)))) (defn count [tag] diff --git a/docs/lit/index.lit b/docs/lit/index.lit index 226ef5a0..3399c272 100644 --- a/docs/lit/index.lit +++ b/docs/lit/index.lit @@ -81,7 +81,7 @@ release}{https://github.com/vito/bass/releases/latest} and skim the (defn ls-remote [repo ref & timestamp] (-> ($ git ls-remote $repo $ref) (with-image *git-image*) - (with-label :at (now 60)) ; rerun every minute + (with-env {:MINUTE (now 60)}) ; rerun every minute (read :unix-table) ; line and space separated table output next ; first row : first)) ; first column: diff --git a/pkg/bass/ground.go b/pkg/bass/ground.go index 424487d4..7221ff48 100644 --- a/pkg/bass/ground.go +++ b/pkg/bass/ground.go @@ -701,7 +701,8 @@ func init() { Ground.Set("with-label", Func("with-label", "[thunk name val]", (Thunk).WithLabel), `returns thunk with the label set to val`, - `Labels are typically used to control caching. Two thunks that differ only in labels will evaluate separately and produce independent results.`, + `Labels are used to set metadata on a thunk, and are not used by the thunk itself.`, + `When the thunk is exported or published, labels will be included in the OCI image.`, `=> (with-label ($ sleep 10) :at (now 10))`) Ground.Set("with-port", diff --git a/pkg/runtimes/testdata/sleep.bass b/pkg/runtimes/testdata/sleep.bass index 0c0af4d7..8600c312 100644 --- a/pkg/runtimes/testdata/sleep.bass +++ b/pkg/runtimes/testdata/sleep.bass @@ -1 +1,3 @@ -(run (-> ($ sleep "999") (with-label :now (now 1)) (with-image (linux/alpine)))) +(run (-> ($ sleep "999") + (with-env {:RANDOM (str *random*)}) + (with-image (linux/alpine)))) diff --git a/std/git.bass b/std/git.bass index b416f584..b94e2d90 100644 --- a/std/git.bass +++ b/std/git.bass @@ -14,7 +14,7 @@ (defn ls-remote [repo ref & timestamp] (-> ($ git ls-remote $repo $ref) (with-image *git-image*) - (with-label :at (if (empty? timestamp) (now 0) (first timestamp))) + (with-env {:TIME (if (empty? timestamp) (now 0) (first timestamp))}) (read :unix-table) next first))