kapicorp / kapitan

Generic templated configuration management for Kubernetes, Terraform and other things
https://kapitan.dev
Apache License 2.0
1.8k stars 197 forks source link

Add jsonnet native function (manifestYamlFromJson) #729

Open anarcher opened 3 years ago

anarcher commented 3 years ago

Describe the bug/feature When I use Grafana's ksonnet-util 1 with Kapitan, I can't do kapitan compile because that Jsonnet native function(manifestYamlFromJson) is null.

vendor/ksonnet-util/util.libsonnet:206:5-27       function <anonymous>
...
RUNTIME ERROR: only functions can be called, got null

ksonnet-util/util.libsonnet:

204   manifestYaml(value):: (
205     local f = std.native('manifestYamlFromJson');
206     f(std.toString(value))
207   ),

To Reproduce

jb init
jb install github.com/grafana/loki/production/ksonnet/promtail
jb install github.com/jsonnet-libs/k8s-alpha/1.16
$ cat components/promtail/main.jsonnet
local promtail = import 'promtail/promtail.libsonnet';

promtail {
  _config+:: {
    namespace: 'addon-logging',
  },
}
$ kapitan compile

Jsonnet error: failed to compile /Users/anarch/git/anarcher/k8s-kapitan-addons/components/promtail/main.jsonnet:
 RUNTIME ERROR: only functions can be called, got null
        /Users/anarch/git/anarcher/k8s-kapitan-addons/vendor/ksonnet-util/util.libsonnet:206:5-27       function <anonymous>
        /Users/anarch/git/anarcher/k8s-kapitan-addons/vendor/promtail/promtail.libsonnet:41:23-61       object <data>
        /Users/anarch/git/anarcher/k8s-kapitan-addons/vendor/github.com/jsonnet-libs/k8s-alpha/1.16/_gen/core/v1/configMap.libsonnet:59:27-31  object <anonymous>
        /Users/anarch/git/anarcher/k8s-kapitan-addons/vendor/promtail/promtail.libsonnet:(39:5)-(42:7)  object <anonymous>
        During manifestation

Compile error: failed to compile target: dev

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem/idea.

If it's a bug (please complete the following information):

Additional context

This manifestYamlFromJson func is defined in Tanka's native funcs: https://github.com/grafana/tanka/blob/17da685bbff3baee75e529b13c19d8f047015395/pkg/jsonnet/native/funcs.go#L109

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open for 1 year with no activity. Remove the stale label or comment if this issue is still relevant for you. If not, please close it yourself.