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

Document "data" attribute of jsonnet_library rule #57

Open
calder opened this issue Jun 25, 2018 · 7 comments
Open

Document "data" attribute of jsonnet_library rule #57

calder opened this issue Jun 25, 2018 · 7 comments

Comments

@calder
Copy link

calder commented Jun 25, 2018

It would be useful for jsonnet_library targets to be able to read data from non-Jsonnet files.

@Globegitter
Copy link
Collaborator

@calder Do you mean via std.extVar or another way?

@mtsgrd
Copy link
Contributor

mtsgrd commented Aug 30, 2018

In the Jsonnet tutorial here it says that importstr is for verbatim UTF-8 text. When constructing e.g. a ConfigMap it is often useful to import arbitrary file types, such as .toml, .yaml, .txt and so on.

One place that comes to mind is my configuration of Traefik, where I have a configuration file traefik.toml. Currently, if I want this in a separate file rather than in-line, I have to incorrectly change the extension to .jsonnet.

local config = importstr "traefik-config.jsonnet"; // Should be traefik-config.toml
{
  apiVersion: "v1",
  kind: "ConfigMap",
  metadata: {
    name: "traefik-config",
    labels: {
      app: "traefik",
    },
  },
  data: {
    "traefik.toml": config,
  },
}

@mtsgrd
Copy link
Contributor

mtsgrd commented Aug 30, 2018

Although, I'm not sure why I didn't realize this has been supported since Nov 2016.. 4ef65ef

@Globegitter
Copy link
Collaborator

Ahh cool, I was not even aware of that, we have been using std.extVar and ext-str-file to get to exactly the same result. But the importstr does seem a little bit nicer.

@mtsgrd
Copy link
Contributor

mtsgrd commented Sep 13, 2018

@calder perhaps this issue can be closed?

@calder
Copy link
Author

calder commented Sep 13, 2018

Nice! Still needs documentation in README though.

@samschlegel
Copy link
Contributor

@calder In that case could you change this issue to something like Document "data" attribute in jsonnet_library rule?

@calder calder changed the title Add "data" attribute to jsonnet_library rule Document "data" attribute of jsonnet_library rule Nov 25, 2018
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

No branches or pull requests

4 participants