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

std.thisFile returning empty string #623

Closed
RixTmobilender opened this issue Oct 12, 2021 · 2 comments · Fixed by #626
Closed

std.thisFile returning empty string #623

RixTmobilender opened this issue Oct 12, 2021 · 2 comments · Fixed by #626

Comments

@RixTmobilender
Copy link

RixTmobilender commented Oct 12, 2021

Apologies if this issue is best served in the upstream jsonnet repo.
I believe I'm hitting a bug where std.thisFile is returning an empty string, I can't intantiate helm correctly due to this behavior.

the following snippet:

helm+: {
  local tanka = import "github.com/grafana/jsonnet-libs/tanka-util/main.libsonnet",
  local helm = tanka.helm.new(std.thisFile),
  executable: helm,
  debug_field: std.thisFile,
  charts_folder: "./charts/", // this is relative to the file where we instantiate executable (right here above)
},

is producing:

"helm": {
  "charts_folder": "./charts/",
  "debug_field": "",
  "executable": {
    "#new": {
      "function": {
        "args": [
          {
            "default": null,
            "name": "calledFrom",
            "type": "string"
          }
        ],
        "help": "`new` initiates the `helm` object. It must be called before any `helm.template` call:\n \u003e ```jsonnet\n \u003e // std.thisFile required to correctly resolve local Helm Charts\n \u003e helm.new(std.thisFile)\n \u003e ```\n"
      }
    },
    "_config": {}
  }
},

Any idea why this might occur and if it's related to tanka?
The rest of my snippet for reference
launcher.jsonnet.txt

Actually trying to use the instantiated helm to template results in an error code:
Error: evaluating jsonnet: RUNTIME ERROR: helmTemplate: 'opts.calledFrom' is unset or empty.

I'm currently working around this by manually writing the filepath to the current file, it works flawlessly.

@Duologic
Copy link
Member

Did you try it with plain jsonnet?

@RixTmobilender
Copy link
Author

Right (doh), I just did and it seems I only get blank strings when using tanka (I'm currently using latest release v0.18.1)
Notice the value of $.rendered_tanka_env.data.helm.debug_field

Using the attached launcher.jsonnet I ran:

  • $ jsonnet --tla-str cluster_category=devopsservices --tla-str env_override=local --tla-str env_name=prerequisites launcher.jsonnet -J lib -J vendor
    and:
  • $ tk --tla-str cluster_category=devopsservices --tla-str env_override=local --tla-str env_name=prerequisites launcher.jsonnet eval

Which yielded respectively:

  •   {
        "rendered_tanka_env": {
           "data": {
              "helm": {
                 "charts_folder": "./charts/",
                 "debug_field": "launcher.jsonnet",
                 "executable": {
                    "#new": {
                       "function": {
                          "args": [
                             {
                                "default": null,
                                "name": "calledFrom",
                                "type": "string"
                             }
                          ],
                          "help": "`new` initiates the `helm` object. It must be called before any `helm.template` call:\n > ```jsonnet\n > // std.thisFile required to correctly resolve local Helm Charts\n > helm.new(std.thisFile)\n > ```\n"
                       }
                    },
                    "_config": { }
                 }
              }
           }
        }
     }

and:

  •   {
       "rendered_tanka_env": {
         "data": {
           "helm": {
             "charts_folder": "./charts/",
             "debug_field": "",
             "executable": {
               "#new": {
                 "function": {
                   "args": [
                     {
                       "default": null,
                       "name": "calledFrom",
                       "type": "string"
                     }
                   ],
                   "help": "`new` initiates the `helm` object. It must be called before any `helm.template` call:\n \u003e ```jsonnet\n \u003e // std.thisFile required to correctly resolve local Helm Charts\n \u003e helm.new(std.thisFile)\n \u003e ```\n"
                 }
               },
               "_config": {}
             }
           }
         }
       }
     }

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

Successfully merging a pull request may close this issue.

2 participants