Skip to content

Commit

Permalink
fix(jsonnet): import "tk" panic (#290)
Browse files Browse the repository at this point in the history
`jsonnet.Importer` requires us to return the same `jsonnet.Contents`
each time the same path is imported.

Before, we returned a different `jsonnet.Contents` instance instead,
which the VM noticed and panics.
  • Loading branch information
sh0rez authored Jun 9, 2020
1 parent 62526fe commit eeff531
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions pkg/jsonnet/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ func tkLoader(importedFrom, importedPath string) (contents *jsonnet.Contents, fo
return nil, "", nil
}

s := jsonnet.MakeContents(tkLibsonnet)
return &s, filepath.Join(locationInternal, "tk.libsonnet"), nil
return &tkLibsonnet, filepath.Join(locationInternal, "tk.libsonnet"), nil
}

// newFileLoader returns an importLoader that uses jsonnet.FileImporter to source
Expand Down
6 changes: 4 additions & 2 deletions pkg/jsonnet/tk.libsonnet.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package jsonnet

const tkLibsonnet = `
import jsonnet "github.com/google/go-jsonnet"

var tkLibsonnet = jsonnet.MakeContents(`
{
env: std.extVar("tanka.dev/environment"),
}
`
`)

0 comments on commit eeff531

Please sign in to comment.