0

I'm trying out Tanka for k8s configs generation. Also, I'm using VS Code extension by Grafana Labs.

I've problems in VS Code with referencing Tanka configuration as described here. I'm using configuration to retrieve namespace, like so:

local k = import 'k.libsonnet';
local tk = import 'tk';

{
  namespace: k.core.v1.namespace.new(tk.env.spec.namespace),
}

Initially, I was receiving an error: RUNTIME ERROR: Undefined external variable: tanka.dev/environment. I supposed that Tanka wants path to my environment, and so added it to VS Code settings:

{
  "jsonnet.languageServer.extVars": {
    "tanka.dev/environment": "environments/default"
  }
}

Now I'm receiving another error in the k.core.v1.namespace.new(tk.env.spec.namespace) expression:

RUNTIME ERROR: Unexpected type string, expected number
    <path to repo>/environments/default/main.jsonnet:7:38-49    
    <path to repo>/vendor/github.com/jsonnet-libs/k8s-libsonnet/1.25/_gen/core/v1/namespace.libsonnet:51:35-39  thunk from <function <anonymous>>
    <path to repo>/vendor/github.com/jsonnet-libs/k8s-libsonnet/1.25/_gen/core/v1/namespace.libsonnet:33:42-46  object <anonymous>
    Field "name"    
    Field "metadata"    
    Field "namespace"   
    During manifestation

The error is quite confusing to me. What and where expects number?

  • both namespace and name are strings in my spec.json
  • according to the same configuration docs they should be strings
  • on line 33 of namespace.libsonnet there is a function withName which expects name argument of type d.T.string
  • tk works fine from the CLI

I suppose that I've set wrong tanka.dev/environment, but I can't find docs that say what should be set there.

Also, just to check if it helps, I tried setting "jsonnet.languageServer.tankaMode": true in VS Code settings to no avail.

Please, help me to resolve the error and if possible explain what's going on here.

Vsevolod
  • 87
  • 6

0 Answers0