starlark
starlark copied to clipboard
Support yaml marshal/unmarshal
For all the same reasons the json
module was added to starlark.
Note there's an implementation over here for the Go implementation of starlark https://github.com/qri-io/starlib/tree/master/encoding/yaml but I doubt that's useful in any way.
The motivation is that the pnpm
tool needs to be integrated as a repository rule, and the data needed to fetch packages in in yaml: https://pnpm.io/git#lockfiles
As a workaround we're using the yq
toolchain to translate yaml to json, which starlark does know how to read: https://docs.aspect.build/aspect-build/bazel-lib/v0.9.6/docs/yq-docgen.html#yq
however it's difficult in a Bazel repository rule to access a tool provided by a toolchain, and impossible under bzlmod (https://github.com/bazelbuild/bazel/issues/14445 - one module extension fetches a yq
binary but another module extension wants to run it)