Discussion
Loading...

Discussion

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
clacke: exhausted pixie dream boy πŸ‡ΈπŸ‡ͺπŸ‡­πŸ‡°πŸ’™πŸ’›
clacke: exhausted pixie dream boy πŸ‡ΈπŸ‡ͺπŸ‡­πŸ‡°πŸ’™πŸ’›
@clacke@libranet.de  Β·  activity timestamp 7 days ago

I gave the team a half-hour crash course in jq, some of the key features of its data and execution model, and how to do a handful of useful everyday things.

After, I had so many questions for myself that I spent over an hour learning more jq. I now have a greater understanding for how brilliant the language is, and I would do that crash course differently.

I think I owe @hpr an episode, if there isn't one.

I found many cheat sheets and liked none of them. A cheat sheet would be perfect to go in the show notes.

#jq

  • Copy link
  • Flag this post
  • Block
clacke: exhausted pixie dream boy πŸ‡ΈπŸ‡ͺπŸ‡­πŸ‡°πŸ’™πŸ’›
clacke: exhausted pixie dream boy πŸ‡ΈπŸ‡ͺπŸ‡­πŸ‡°πŸ’™πŸ’›
@clacke@libranet.de replied  Β·  activity timestamp 7 days ago

In Github Actions, jq comes pre-installed in the default worker. This can save you a lot of headache. Don't try to manipulate JSON with bash or Python, that's just clunky and error-prone when you can use jq instead.

I rewrote some of my own code from half a year ago. It's now shorter, more readable (if you know jq – hence the crash course), has zero quoting issues and provides better error messages.

#GithubActions

  • Copy link
  • Flag this comment
  • Block
clacke: exhausted pixie dream boy πŸ‡ΈπŸ‡ͺπŸ‡­πŸ‡°πŸ’™πŸ’›
clacke: exhausted pixie dream boy πŸ‡ΈπŸ‡ͺπŸ‡­πŸ‡°πŸ’™πŸ’›
@clacke@libranet.de replied  Β·  activity timestamp 7 days ago

A team member suggested we might want to replace some or all of our jinja use with jq. Makes sense. Would save us some Python setup too, which would simplify things.

There is yq for yaml as well, but JSON is valid yaml, so jq is enough.

  • Copy link
  • Flag this comment
  • Block
Jamey Sharp
Jamey Sharp
@jamey@toot.cat replied  Β·  activity timestamp 7 days ago

@clacke Did you mean this the other way around? JSON is valid YAML, so yq is enough because it can handle both?

  • Copy link
  • Flag this comment
  • Block
clacke: exhausted pixie dream boy πŸ‡ΈπŸ‡ͺπŸ‡­πŸ‡°πŸ’™πŸ’›
clacke: exhausted pixie dream boy πŸ‡ΈπŸ‡ͺπŸ‡­πŸ‡°πŸ’™πŸ’›
@clacke@libranet.de replied  Β·  activity timestamp 7 days ago

@jamey I mean we don't need yq, because anything we need to express can be expressed as JSON. Then we won't have to install anything extra, as jq comes preinstalled.

I think you can even tell kubectl to read your input as JSON, and avoid any potential ambiguity.

  • Copy link
  • Flag this comment
  • Block
Jamey Sharp
Jamey Sharp
@jamey@toot.cat replied  Β·  activity timestamp 7 days ago

@clacke Oh, if you control your data sources and can dictate JSON, I guess that works too. I think my confusion is because I'm missing the context on what you're using jq or jinja for here, but that's okay.

  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About Β· Code of conduct Β· Privacy Β· Users Β· Instances
Bonfire social Β· 1.0.2-alpha.2 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct