Command line tool to modify YAML files

1,064 views
Skip to first unread message

Alex Breadman

unread,
Oct 29, 2020, 6:21:04 PM10/29/20
to golang-nuts
Hi everyone,

I needed a tool today to insert or overwrite top-level values in a YAML file so that my CI pipeline can be cleaner and less complicated.

So I made a Go cmd tool called:


I hope someone finds this useful! I will be making a Github Action once I figure out how.

Please contribute where you think improvements can be made.

Howard C. Shaw III

unread,
Nov 2, 2020, 11:41:58 AM11/2/20
to golang-nuts
If written because you needed experience and writing a program to perform a task you need done is better for learning, then go you! But if you are legitimately looking to solve a problem, you might want to throw a quick search out first before implementing Yet Another X.

For yamlfukr update file.yaml key value:
yq w -i file.yaml key value

yq also supports b.c.d.e key names to edit deeper values.


dasel put string -f file.yaml -p yaml "key" value

dasel also supports b.c.d.e key names to edit deeper values.

yaml-cli update:value file.yml key value  

If you intend to keep developing yamlfukr, you might want to examine some of the alternatives, and if you find them unsuitable, add to your documentation why you find them so, so that someone coming on your project can see why they should consider going with your tool instead of one of the alternatives.

alex breadman

unread,
Nov 2, 2020, 11:50:20 AM11/2/20
to Howard C. Shaw III, golang-nuts
Thanks for the reply.

I just did it for fun actually, and for the purpose of learning to make GitHub actions.

I saw yq but it seemed like it was written in python, which I have no time for.

The dasel one looks the best imo.



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/b1fb908a-94f7-4487-b76a-50153d87c868n%40googlegroups.com.

Tyler Compton

unread,
Nov 2, 2020, 12:26:35 PM11/2/20
to alex breadman, Howard C. Shaw III, golang-nuts
I saw yq but it seemed like it was written in python, which I have no time for.

You're going to be limiting your tooling options quite a bit in that case :) 

alex breadman

unread,
Nov 2, 2020, 12:30:12 PM11/2/20
to Tyler Compton, Howard C. Shaw III, golang-nuts
Not really.

I'll just rewrite them in go if there isn't a tool I need, or it the interface is crappy. I have built a few databases from scratch, so writing simple tools is trivial.


Reply all
Reply to author
Forward
0 new messages