crossplane-contrib / function-kcl

Crossplane Composition Functions using KCL Programming Language
Apache License 2.0
39 stars 16 forks source link

Local path example failed to run when running function in docker #165

Closed ma-ble closed 3 weeks ago

ma-ble commented 1 month ago

What happened?

When I try to run the example with the local path via 'make local', it works as expected. When I try to use docker to run the function I get the error message on the Mac that the kcl file cannot be found.

How can we reproduce it?

$ cd examples/resources/network

Disable "render.crossplane.io/runtime: Development" so that the function runs in docker.

$ make local
crossplane render xr.yaml local_composition.yaml functions.yaml -r
crossplane: error: cannot render composite resource: pipeline step "normal" returned a fatal result: failed to run kcl function pipelines: Cannot find the kcl file, please check the file path /examples/resources/network/composition.k
make: *** [local] Error 1

What environment did it happen in?

Function version: v0.10.0 KCL version: 0.10.0-darwin-arm64 kind cluster: 0.24.0 kubectl version Client Version: v1.31.0 Kustomize Version: v5.4.2 Server Version: v1.31.0 uname -a: Darwin Kernel Version 24.0.0 root:xnu-11215.1.12~1/RELEASE_ARM64_T6020 arm64

Peefy commented 4 weeks ago

When you use Docker or Kubernetes to run a local path in a container, you need to mount the corresponding path inside. I will provide corresponding documentation, such as https://github.com/crossplane-contrib/function-go-templating/tree/main/example/filesystem