Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined external variable: tanka.dev/environment #480

Closed
smuth4 opened this issue Jan 17, 2021 · 3 comments · Fixed by #482 or #498
Closed

Undefined external variable: tanka.dev/environment #480

smuth4 opened this issue Jan 17, 2021 · 3 comments · Fixed by #482 or #498

Comments

@smuth4
Copy link
Contributor

smuth4 commented Jan 17, 2021

This error occurs on the latest build (works just fine in 0.13.0) when I try to use any of the spec data as per https://tanka.dev/config#jsonnet-access:

Error: evaluating jsonnet: RUNTIME ERROR: Undefined external variable: tanka.dev/environment
        <internal>/tk.libsonnet:3:8-43  object <anonymous>
        /home/tanka-test/environments/default/main.jsonnet:7:13-19
        Field "test"
        During manifestation

Minimal reproducible example:
environments/default/main.jsonnet

local tk = import "tk";
{
  test: {
    apiVersion: 'v1',
    kind: 'Namespace',
    metadata: {
      name: tk.env.spec.namespace
    }
  }
}

environments/default/spec.json

{
  "apiVersion": "tanka.dev/v1alpha1",
  "kind": "Environment",
  "metadata": {
    "name": "environments/default"
  },
  "spec": {
    "apiServer": "",
    "namespace": "default",
    "resourceDefaults": {},
    "expectVersions": {}
  }
}

tk eval environments/default, also happens on any other command against it.

@sh0rez
Copy link
Member

sh0rez commented Jan 20, 2021

Hi, I verified and reproduces this bug. It will be fixed in #482. Thanks for reporting!

@smuth4
Copy link
Contributor Author

smuth4 commented Jan 30, 2021

Sorry for the time it took me to circle back around to this, but it looks like this bug still exists for tk eval.

For more context, I wanted to put the namespace into a rolebinding's subject dynamically. In my use case, I can local spec = import 'spec.json'; directly, but it wouldn't work for tanka specific libsonnets.

@Duologic
Copy link
Member

Duologic commented Feb 2, 2021

You are right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants