mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
Compare commits
855 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fae2b2643c | ||
|
dd86b5e7f2 | ||
|
f1f75683c1 | ||
|
38b9856f50 | ||
|
48eeb2a9df | ||
|
af283315f2 | ||
|
d18a6963f6 | ||
|
77edbb9f5c | ||
|
179c44aacc | ||
|
bc70c1fb16 | ||
|
0b71a40797 | ||
|
3f51a44596 | ||
|
afebf0e621 | ||
|
dc464a5b10 | ||
|
5340ed0ad3 | ||
|
7b52c5fe0e | ||
|
f4392f8658 | ||
|
8e14b3b393 | ||
|
8627441705 | ||
|
aa95ecd012 | ||
|
a2bd463a91 | ||
|
6c3965dca3 | ||
|
bb3ffd40b5 | ||
|
cc08afc435 | ||
|
941a453163 | ||
|
77630ca179 | ||
|
ae4b606707 | ||
|
37f3e21970 | ||
|
25d0787011 | ||
|
b5b8da0a1d | ||
|
fa21510194 | ||
|
f541194250 | ||
|
38666f4db6 | ||
|
8b327d0414 | ||
|
c8630fe4f3 | ||
|
87df9b1ae6 | ||
|
2483c38eeb | ||
|
b2a538bdfc | ||
|
6c26344449 | ||
|
daf0bfe1b9 | ||
|
750a00ec35 | ||
|
25e0a824c5 | ||
|
095f921f62 | ||
|
12d3425b4a | ||
|
0249f00bd5 | ||
|
42b1bf9678 | ||
|
c632fd3641 | ||
|
0470e5cd69 | ||
|
35c6d07248 | ||
|
3f0be107d4 | ||
|
21a9e506cb | ||
|
3722367fbb | ||
|
f7b50e9853 | ||
|
4f3fe256aa | ||
|
2595a929c9 | ||
|
b2186d5404 | ||
|
e93c43f7a0 | ||
|
b1a5387cdd | ||
|
5911ab2929 | ||
|
2ed5b2ff59 | ||
|
111c6e0be1 | ||
|
81136ad57e | ||
|
a6cd250987 | ||
|
ee1f55630f | ||
|
9072e8d3b3 | ||
|
99b08fd612 | ||
|
b2317a14ef | ||
|
3e5f7b147f | ||
|
c4faa70143 | ||
|
4d6d07ec43 | ||
|
bd0818c481 | ||
|
26742b2597 | ||
|
64c618c041 | ||
|
c4c8e5e7b0 | ||
|
e02ad4d7e8 | ||
|
dd17f072cf | ||
|
429c3ca65b | ||
|
cfcac6d1dc | ||
|
a5ddbca97f | ||
|
30027a8cf4 | ||
|
f92a42e4f8 | ||
|
3c466dc66e | ||
|
0816e16d30 | ||
|
802d54e14e | ||
|
10600dd29a | ||
|
3a464272d4 | ||
|
691efadfac | ||
|
6efe4c4797 | ||
|
9e56b364c2 | ||
|
85ec32e3db | ||
|
5c73132c8e | ||
|
c6efd5519b | ||
|
3bae44be68 | ||
|
48a7c59c4b | ||
|
851fbd8cf5 | ||
|
820a3320be | ||
|
61f569aebb | ||
|
9ff51cd066 | ||
|
9dd6d11362 | ||
|
83139e21d9 | ||
|
c77001f969 | ||
|
1be3b31bbc | ||
|
6c14a80991 | ||
|
76bd1896e9 | ||
|
c63801a8a5 | ||
|
f7cfdc29e1 | ||
|
07c6549a58 | ||
|
29f40dad59 | ||
|
fe33e7fcfe | ||
|
0707525b29 | ||
|
62acee54c3 | ||
|
d21c94cf4f | ||
|
626e9cacaf | ||
|
02ef99560d | ||
|
c59209f041 | ||
|
947ffb6986 | ||
|
1a03031297 | ||
|
2c7db0071a | ||
|
0484d0232b | ||
|
91c72d2d9e | ||
|
09ec740d45 | ||
|
532dbd81a5 | ||
|
e86f83fb69 | ||
|
7d5b6b5442 | ||
|
b749973fe0 | ||
|
ba223df4ac | ||
|
e6336bcb85 | ||
|
9ae03e0a1c | ||
|
55712afea6 | ||
|
7518dac99c | ||
|
49ac2bac13 | ||
|
e28df367eb | ||
|
90ec05be54 | ||
|
8f5270cc63 | ||
|
286590b01e | ||
|
c1cf8b4e34 | ||
|
461661112c | ||
|
578f2c27f9 | ||
|
6ed037a9f6 | ||
|
69386316f3 | ||
|
a0e1f65b20 | ||
|
8027f4c568 | ||
|
b13eb7083e | ||
|
b505240d09 | ||
|
7a184bef78 | ||
|
34bc33d5c5 | ||
|
4d8b64d05c | ||
|
2d9cc3c107 | ||
|
018a6e616d | ||
|
7fa2b20b48 | ||
|
316e0d4d5a | ||
|
a0d4c51e27 | ||
|
ceff2cc18d | ||
|
db62a16007 | ||
|
2a6e423d2d | ||
|
5a1b81cbfc | ||
|
8c1f7dfbd7 | ||
|
2e81384eed | ||
|
fbf36037c9 | ||
|
2957210e65 | ||
|
bde419aaee | ||
|
9b185a4409 | ||
|
0c777a4967 | ||
|
e9591e0cd5 | ||
|
04491e13c3 | ||
|
5aff50a345 | ||
|
90d55fb52a | ||
|
e6f97518f3 | ||
|
f4a44e7313 | ||
|
edb5f213d7 | ||
|
5cfd9b05ee | ||
|
0e764c59ce | ||
|
1b887e23b3 | ||
|
a76b72e691 | ||
|
9509831cff | ||
|
e92180e89d | ||
|
a6ae33c3f1 | ||
|
94a563dfd8 | ||
|
0328cfd619 | ||
|
88663a6ce3 | ||
|
b10a9ccfc6 | ||
|
9e9e15df73 | ||
|
6cc6fdf322 | ||
|
a88c2dc5d3 | ||
|
ea231006ed | ||
|
80f187f1a4 | ||
|
98e8b3479f | ||
|
eb539ff326 | ||
|
c09f7aa707 | ||
|
7f5c380d16 | ||
|
6a05e517f1 | ||
|
8ee6f7dc1a | ||
|
8bd54cd603 | ||
|
f2f7b6db0f | ||
|
e082fee5d4 | ||
|
412911561f | ||
|
52ae633cb7 | ||
|
9356ca59bb | ||
|
6dec167f74 | ||
|
00f6981314 | ||
|
4c60a2a967 | ||
|
f4529614c4 | ||
|
f059e13f94 | ||
|
4dbf158505 | ||
|
39a93a2836 | ||
|
7c158fce26 | ||
|
0bf43d2a55 | ||
|
1b0bce5da6 | ||
|
f112bde5fe | ||
|
e5aa4a87a4 | ||
|
f305e8fa12 | ||
|
d2d0c2c111 | ||
|
2aab79431c | ||
|
540d4953f5 | ||
|
7849232255 | ||
|
57cd67f055 | ||
|
6b17fd4fc1 | ||
|
ca8cd78616 | ||
|
9876b0ce8f | ||
|
a23272727d | ||
|
1fb37785d6 | ||
|
efb9027540 | ||
|
2577fe5425 | ||
|
f39c57fed9 | ||
|
1e8f755e7c | ||
|
bb088f6aa2 | ||
|
a96b74e779 | ||
|
09a9e1e7f0 | ||
|
db60746e4e | ||
|
8846255d1c | ||
|
a3e422ff76 | ||
|
2c3357702d | ||
|
c9dbf04da3 | ||
|
fbe53885ae | ||
|
da027f69d7 | ||
|
8cd290c00b | ||
|
363fe5d283 | ||
|
773b1a3517 | ||
|
cf4915d786 | ||
|
08f579f4e3 | ||
|
c9229439f7 | ||
|
9bc66c80b6 | ||
|
8de10e550d | ||
|
1258fa199e | ||
|
3a030651a3 | ||
|
3f48201a19 | ||
|
3cecb4e383 | ||
|
13679e51e2 | ||
|
f42728eef7 | ||
|
93136ba840 | ||
|
5665dc7b71 | ||
|
9302279dd2 | ||
|
5205f01248 | ||
|
0a66bb797d | ||
|
5972bb2f23 | ||
|
ec43f5e7c3 | ||
|
1ce30b25dc | ||
|
3d6a231722 | ||
|
3f04a1b52e | ||
|
aed598c736 | ||
|
e9fa873af8 | ||
|
064cff1341 | ||
|
fc3af441e5 | ||
|
e451119014 | ||
|
d38caf6bc2 | ||
|
4e385a1b93 | ||
|
356aac5a1f | ||
|
663413cd7a | ||
|
f03005f86d | ||
|
bc87aca8d7 | ||
|
62f262147c | ||
|
0259bb44c1 | ||
|
c08980e70f | ||
|
e07a5b6065 | ||
|
f69a81b79b | ||
|
9674acf684 | ||
|
8e1ce4ca70 | ||
|
9bd9468526 | ||
|
75044e480c | ||
|
36084a60a9 | ||
|
9b48cf80e0 | ||
|
bb3b08e648 | ||
|
dcacad1e7e | ||
|
3356061e1e | ||
|
2c062bc2a5 | ||
|
088ec36acd | ||
|
83cb6421df | ||
|
a57944d123 | ||
|
79867473d5 | ||
|
b3efcdc202 | ||
|
af2aa9ad91 | ||
|
db4762ef7c | ||
|
860655b4cd | ||
|
d91b25840a | ||
|
019acfe456 | ||
|
af39fc737d | ||
|
f8a700e400 | ||
|
708ff02e8d | ||
|
2edf64182b | ||
|
b290a65602 | ||
|
05520c2168 | ||
|
5ab584afac | ||
|
b1f139c965 | ||
|
0cb2ff5b2e | ||
|
d6ff198d63 | ||
|
e515b8c2db | ||
|
b63b9644aa | ||
|
461c3e719c | ||
|
643f2467ee | ||
|
4edb3e9021 | ||
|
41c08891d3 | ||
|
85d059340b | ||
|
badd476730 | ||
|
65e6e492cd | ||
|
6a698332dd | ||
|
49615f5581 | ||
|
4f574efdc4 | ||
|
ccb718cd0f | ||
|
73cf6224f2 | ||
|
815edef86a | ||
|
4bc98776a6 | ||
|
1910563bfe | ||
|
2ddf8dd4ed | ||
|
cd83d94b6a | ||
|
6afc2e9189 | ||
|
49b810cedd | ||
|
391ab8d70c | ||
|
b026ebf2c3 | ||
|
5e544a5b7e | ||
|
60511f5f92 | ||
|
59296b7d12 | ||
|
fccd03036f | ||
|
6829d8cb78 | ||
|
449fb8952c | ||
|
afffb2c3ba | ||
|
829ca3b424 | ||
|
d19e9f6917 | ||
|
6a0a4efa7b | ||
|
288aec942c | ||
|
7c4cf72468 | ||
|
b025000f20 | ||
|
1ba1e90e58 | ||
|
e0d1aed5b9 | ||
|
e6fd6905eb | ||
|
0a2a3c4374 | ||
|
ac076cd34a | ||
|
8170eec6d1 | ||
|
23083ed974 | ||
|
93aaa8ccee | ||
|
d7716551cf | ||
|
c791e5c663 | ||
|
a6d4dbb8b8 | ||
|
c7ebdda530 | ||
|
a0d940638c | ||
|
c09513803a | ||
|
f95226e267 | ||
|
f479a7e8e3 | ||
|
f7d4695837 | ||
|
5ee52f9506 | ||
|
c2159d9861 | ||
|
95bc1e1599 | ||
|
e037c57725 | ||
|
e32bc43c4e | ||
|
a8bdc12d83 | ||
|
ae59ad57f4 | ||
|
c321600afa | ||
|
4c95efa469 | ||
|
996ee0b433 | ||
|
bb9cb0c60e | ||
|
a125495eec | ||
|
7fa2835e13 | ||
|
e0f5cb3c59 | ||
|
87550b7fe5 | ||
|
5554301c29 | ||
|
3b0aaac626 | ||
|
65cb472604 | ||
|
fbba38c9b7 | ||
|
e5948c4f16 | ||
|
4eaadf98d0 | ||
|
eedbb0a99f | ||
|
7dabc57b65 | ||
|
fcd3a90f67 | ||
|
88e99e5336 | ||
|
a8cfccd3af | ||
|
3355e80d85 | ||
|
f528b28938 | ||
|
5b7b390a33 | ||
|
4f12e09e78 | ||
|
ee732fbf0b | ||
|
1507f929a2 | ||
|
c11c3df84f | ||
|
06bb3ac826 | ||
|
778f8c6916 | ||
|
9f43a4a265 | ||
|
bb6f07d147 | ||
|
759456e375 | ||
|
5e59803037 | ||
|
a0cb691601 | ||
|
fea8510061 | ||
|
b380ea2892 | ||
|
d66a709213 | ||
|
2fc39b3865 | ||
|
ee07edbd88 | ||
|
b11661a1be | ||
|
eac218980e | ||
|
80e7f46538 | ||
|
086f0ec6b9 | ||
|
89cbe63343 | ||
|
07cd3d4b8b | ||
|
b7b6988e76 | ||
|
9de2039c31 | ||
|
767709fef5 | ||
|
d9ae8e1e5a | ||
|
b0fa0e5b86 | ||
|
6777d639c0 | ||
|
de8dcff803 | ||
|
765ada4dc6 | ||
|
1405584892 | ||
|
8c9c326342 | ||
|
e90b00957b | ||
|
71f5f76213 | ||
|
b9e304e7a4 | ||
|
d473c39a44 | ||
|
9624410add | ||
|
b55fe48bd8 | ||
|
721dd57ed4 | ||
|
6fc3566acd | ||
|
4b63d92a3c | ||
|
3ccd32a47e | ||
|
3f913afbb9 | ||
|
ff598e1933 | ||
|
23de61a8d7 | ||
|
64135a16e1 | ||
|
06d8715cbe | ||
|
e15633023f | ||
|
6f0a329331 | ||
|
55511de9af | ||
|
2db69c91c9 | ||
|
33e35d10dd | ||
|
dfdbbbb24a | ||
|
55c4d01a91 | ||
|
7dc3d62bb6 | ||
|
11116804c5 | ||
|
f68b24323e | ||
|
8f166a9848 | ||
|
3c36db9285 | ||
|
605d6fab9b | ||
|
1f9a3f5f6c | ||
|
a06320f13c | ||
|
279996533d | ||
|
efe942727d | ||
|
e4dc70cc84 | ||
|
8ade1275e2 | ||
|
e1e05d85e3 | ||
|
b99467432e | ||
|
6b07143af7 | ||
|
ed234e37ce | ||
|
c0e4917d52 | ||
|
2713893f87 | ||
|
6bb221e973 | ||
|
7eb01a81da | ||
|
5c117204fa | ||
|
a4fa8f1341 | ||
|
69caccd2d3 | ||
|
67fb924e0e | ||
|
b64187fe32 | ||
|
8e6ceba2ac | ||
|
6ef04e1e77 | ||
|
10029420a5 | ||
|
f91093d5fe | ||
|
090432d241 | ||
|
22d5bd3615 | ||
|
0d477841da | ||
|
1f72817d74 | ||
|
125d04a75b | ||
|
08f6a90603 | ||
|
da398765b8 | ||
|
d356fa0d0b | ||
|
d22bfc241b | ||
|
954affea23 | ||
|
b0d1afb601 | ||
|
b286636909 | ||
|
bdf47c9797 | ||
|
1cc20d52bb | ||
|
651d9edf88 | ||
|
903605df39 | ||
|
0f9facc84b | ||
|
5af86b1333 | ||
|
2bd2a85a4c | ||
|
ceb76e5c17 | ||
|
44322f0248 | ||
|
0347516d82 | ||
|
a46386e093 | ||
|
f5c3beb159 | ||
|
9864afc4e7 | ||
|
69fae2d9cb | ||
|
83c13ce392 | ||
|
d83c46eec2 | ||
|
65802f9e0e | ||
|
07309e1685 | ||
|
24e906bae6 | ||
|
f084f2bb23 | ||
|
96a4161a92 | ||
|
5cc01e43bc | ||
|
9de2573009 | ||
|
29521f2e3e | ||
|
af5724ba29 | ||
|
0a39d29c53 | ||
|
72cd3e4a2a | ||
|
d40ad9649d | ||
|
63313ebb02 | ||
|
de3bfaef60 | ||
|
108b5cb093 | ||
|
b116f40348 | ||
|
ea9df0eede | ||
|
b7dd3e8e0a | ||
|
dc13fa99f7 | ||
|
179049a535 | ||
|
2fa8b24272 | ||
|
f1dbe13f21 | ||
|
02258fbaae | ||
|
6f0538173b | ||
|
6840ea8c78 | ||
|
70b88fa778 | ||
|
bfc1a621c4 | ||
|
166f866f28 | ||
|
b3598aaa43 | ||
|
14ac791eaf | ||
|
25293a6894 | ||
|
d828b214cc | ||
|
9e47685271 | ||
|
699fce9da4 | ||
|
f52de57652 | ||
|
b7554e6e76 | ||
|
ec25511f1b | ||
|
c6a52012ab | ||
|
63ded205e8 | ||
|
d1c1ab0a75 | ||
|
6ec8386f9e | ||
|
4dbe3636c2 | ||
|
4a5bd0ff5b | ||
|
44f36833cf | ||
|
789ea02096 | ||
|
7c27491dd6 | ||
|
720cc8f798 | ||
|
abda0e38af | ||
|
5cd4c347b0 | ||
|
1a4d8158ba | ||
|
8a65822b0b | ||
|
b7148adf20 | ||
|
64d38e9f03 | ||
|
3a387e65be | ||
|
56ba7c9a43 | ||
|
d203ec7b56 | ||
|
e2f79a3dae | ||
|
2d7be26ad5 | ||
|
350a8343e9 | ||
|
a3f8f9df10 | ||
|
35fd5b7ae4 | ||
|
2d237e7e8e | ||
|
74c7a4e027 | ||
|
f18c5161e0 | ||
|
eeeeeffd7b | ||
|
96955ffa9c | ||
|
9361b8b3e9 | ||
|
24dcb56466 | ||
|
728cbe991a | ||
|
854f5f0fc9 | ||
|
feba7b04fa | ||
|
0621307391 | ||
|
924eb6c462 | ||
|
52eef67e37 | ||
|
38d35185bc | ||
|
d8c29b26c1 | ||
|
e3f4eedd51 | ||
|
690da9ee74 | ||
|
1f7f1b0def | ||
|
1aa5ec1d40 | ||
|
a065a47b37 | ||
|
625cfdac75 | ||
|
4dbdd4a805 | ||
|
8a6af1720d | ||
|
0652f67a91 | ||
|
df52383ffb | ||
|
707ad09ba5 | ||
|
cf389bed4a | ||
|
ff5b23251b | ||
|
9925b26b9d | ||
|
93dbe80a77 | ||
|
27604289f4 | ||
|
3f36a18791 | ||
|
1e541cd65f | ||
|
5204a13685 | ||
|
3d3eaf3034 | ||
|
4fb44dbc47 | ||
|
784513dd18 | ||
|
865a55645c | ||
|
949bf1c1d7 | ||
|
19fe718cfb | ||
|
290579ac7f | ||
|
d7392f7b58 | ||
|
a3cebec2fd | ||
|
b81fd638d7 | ||
|
2344638da4 | ||
|
8be006fba4 | ||
|
53a4a47ce3 | ||
|
5988d0cffa | ||
|
b7640946ac | ||
|
d061b2f9f9 | ||
|
8c0046a622 | ||
|
586ffb833b | ||
|
9771e7001c | ||
|
8da9a81702 | ||
|
d97f1d8be2 | ||
|
dad61ec615 | ||
|
676fc63219 | ||
|
972e2b9575 | ||
|
aad15ccc6e | ||
|
5fc13bdccd | ||
|
95fec2984e | ||
|
64d1e58f97 | ||
|
4b3fbb878f | ||
|
26a09e6ec0 | ||
|
ceafed30f9 | ||
|
b8b2c9de61 | ||
|
f5fdf98c38 | ||
|
29986db8f8 | ||
|
1f4e3a9cde | ||
|
b6da773dde | ||
|
8020d4253b | ||
|
3c701fe98e | ||
|
97d1aa2b26 | ||
|
d05391e244 | ||
|
d1cec1ad18 | ||
|
fe5842e5f9 | ||
|
e0d8cd6bf6 | ||
|
8f5ffe47ff | ||
|
5acc1e661e | ||
|
a9c0ef571c | ||
|
7a28531f2f | ||
|
5de2bea1b4 | ||
|
7320b8d3c9 | ||
|
2f70e6f27a | ||
|
a9e871ee00 | ||
|
bc4bab9380 | ||
|
665d9079fa | ||
|
7b54a44fcf | ||
|
94148e4398 | ||
|
f8553162ca | ||
|
be532bf2fe | ||
|
e9b8265ca3 | ||
|
0f8b864321 | ||
|
e5bcfedbe9 | ||
|
a5f5fb2562 | ||
|
84de9c078d | ||
|
c7f5261036 | ||
|
6e35356a84 | ||
|
b2fe3e6738 | ||
|
774badfef4 | ||
|
c4e9516aa6 | ||
|
323089eb64 | ||
|
53289366a5 | ||
|
cda9a82906 | ||
|
2dbde6b9fb | ||
|
f8c1c3c1b4 | ||
|
238a1241d2 | ||
|
8a61ef072a | ||
|
4f178d2317 | ||
|
133e55105c | ||
|
5e5468af3b | ||
|
9b4972e46e | ||
|
23543ee031 | ||
|
75c7d40c44 | ||
|
44b8a5e80f | ||
|
77c8f22a79 | ||
|
386a0ca3c3 | ||
|
53a20d4421 | ||
|
478208b7c4 | ||
|
1159d0a212 | ||
|
8861b392a8 | ||
|
16bde80334 | ||
|
8a3fb32f36 | ||
|
48dcc15281 | ||
|
d7040e3933 | ||
|
ef579d4ccf | ||
|
785ee68a76 | ||
|
90fe9c6512 | ||
|
a9ade5a832 | ||
|
8d6e3a6a75 | ||
|
7a6689eb40 | ||
|
e6660e2460 | ||
|
28169b04f7 | ||
|
742cf748ac | ||
|
54c06cdb4c | ||
|
ef5f745da3 | ||
|
25025f2771 | ||
|
ebb8b34b31 | ||
|
9a5e4ee828 | ||
|
0a2dd29940 | ||
|
50dfce86c9 | ||
|
e55006e935 | ||
|
d8fed62f03 | ||
|
52a39bf31e | ||
|
d84254c30f | ||
|
18bb4eee96 | ||
|
86b9fe3ef9 | ||
|
2c15048ddb | ||
|
ce2ee42f71 | ||
|
c2c49dcb17 | ||
|
60de18391c | ||
|
c86f8b426b | ||
|
b3532e0a61 | ||
|
b3b60665e4 | ||
|
df08b055cf | ||
|
e822313e82 | ||
|
a9f25c9d76 | ||
|
0a8c268dcc | ||
|
a0e70279a8 | ||
|
25c9c22d8d | ||
|
d46d555b07 | ||
|
fb87f638f2 | ||
|
facc81d1f4 | ||
|
c1f9065c68 | ||
|
be84cc3082 | ||
|
a2571da1a1 | ||
|
6d6e476ac8 | ||
|
ae0c042ae6 | ||
|
867ec92d3a | ||
|
113586b5e0 | ||
|
c38f19e0a9 | ||
|
8ca85b1c64 | ||
|
08870f8ec9 | ||
|
94b217984c | ||
|
2f5a481cc3 | ||
|
1a4064429d | ||
|
1b22e1d812 | ||
|
297522cbdd | ||
|
be991fdacd | ||
|
be08214773 | ||
|
9e971ebeae | ||
|
f340db5795 | ||
|
ab852ceafa | ||
|
06a843e9b2 | ||
|
ebdc092688 | ||
|
27089d1ca1 | ||
|
1853585d22 | ||
|
0124d26086 | ||
|
0d68bea3dc | ||
|
54603b3607 | ||
|
c86aeca325 | ||
|
a4f124f24f | ||
|
090b377fa5 | ||
|
3a4d62d820 | ||
|
6053c8c136 | ||
|
c5a45ba7d5 | ||
|
56a0771cd1 | ||
|
8072e66d46 | ||
|
26153b3eb5 | ||
|
f2e10f21c7 | ||
|
d3ecf7aa88 | ||
|
ee8ffd458a | ||
|
8f15dba812 | ||
|
92ce195424 | ||
|
e725a2cec5 | ||
|
37de7a3505 | ||
|
e96794a420 | ||
|
120ef8e4dc | ||
|
db1954da25 | ||
|
e552dbb6ab | ||
|
298126864f | ||
|
d30cd8cc75 | ||
|
e6ee86930b | ||
|
0ea3c71df7 | ||
|
ef99bedf45 | ||
|
6e1a5aef2c | ||
|
70bd860287 | ||
|
0abda0098c | ||
|
a409a7e82b | ||
|
0e4f9e8579 | ||
|
0c932ba7dc | ||
|
cb48ba7173 | ||
|
dc4f8a6adb | ||
|
1f6d7a50b2 | ||
|
6fc3bdf58f | ||
|
87b33e8603 | ||
|
cc7eb84388 | ||
|
9e3f8ebd0a | ||
|
28bcbd321f | ||
|
9dd4503b23 | ||
|
185d1faadb | ||
|
7b004cb456 | ||
|
54c73eb34f | ||
|
3b03a0852a | ||
|
a00e6c5316 | ||
|
9d1a5b17b8 | ||
|
c5f80a105d | ||
|
c17f8df8f8 | ||
|
66c8390d54 | ||
|
dda9b1f087 | ||
|
683de28c64 | ||
|
51fa1a87b7 | ||
|
b9ac6a3d9d | ||
|
499974c27e | ||
|
72bd88cfa5 | ||
|
6980be3800 | ||
|
2933ea1684 | ||
|
cf2f23d747 | ||
|
45e9ad870f | ||
|
53b2c64747 | ||
|
359ca5a117 | ||
|
79baa49eaa | ||
|
2cda78ce0b | ||
|
6d1e61c410 | ||
|
86639acf70 | ||
|
3beee3f804 | ||
|
1ed8e7017e | ||
|
5514d2300b | ||
|
5bb0934710 | ||
|
cdd78af4bc | ||
|
d07e436065 | ||
|
b2a0964de2 | ||
|
69e6bb354d | ||
|
ec25886528 | ||
|
c2000a446b | ||
|
08ba0083be | ||
|
909b62be54 | ||
|
0facf35d60 | ||
|
a7c4813703 | ||
|
373e0a5eb7 | ||
|
124c57f9d9 | ||
|
fb73a793bd | ||
|
c22394b540 | ||
|
b1ff47022b | ||
|
82f1230db8 | ||
|
a3190f1504 | ||
|
44ee869e47 | ||
|
5d2d37a5f8 | ||
|
e3fc944709 | ||
|
6ee9db9a70 | ||
|
0d75edfb67 | ||
|
037314af8a | ||
|
2a283b4ef7 | ||
|
7ef556f22b | ||
|
6b566fd983 | ||
|
001925a4d4 | ||
|
3dee7b89d2 | ||
|
c955815aab | ||
|
3720bf8211 | ||
|
5f09aabf4c | ||
|
98751cf607 | ||
|
2ec3b59da2 | ||
|
56c923228d | ||
|
c122b9a843 | ||
|
15f51d4bf0 | ||
|
219105f999 |
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
bin/*
|
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
github: mikefarah
|
51
.github/ISSUE_TEMPLATE/bug_report_v3.md
vendored
Normal file
51
.github/ISSUE_TEMPLATE/bug_report_v3.md
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
---
|
||||||
|
name: Bug report - V3
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: bug, v3
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
Note that any how to questions should be posted in the discussion board and not raised as an issue.
|
||||||
|
|
||||||
|
Version of yq: 3.X.X
|
||||||
|
Operating system: mac/linux/windows/....
|
||||||
|
Installed via: docker/binary release/homebrew/snap/...
|
||||||
|
|
||||||
|
**Input Yaml**
|
||||||
|
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
|
||||||
|
data1.yml:
|
||||||
|
```yaml
|
||||||
|
this: should really work
|
||||||
|
```
|
||||||
|
|
||||||
|
data2.yml:
|
||||||
|
```yaml
|
||||||
|
but: it strangely didn't
|
||||||
|
```
|
||||||
|
|
||||||
|
**Command**
|
||||||
|
The command you ran:
|
||||||
|
```
|
||||||
|
yq merge data1.yml data2.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
**Actual behavior**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
cat: meow
|
||||||
|
```
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
this: should really work
|
||||||
|
but: it strangely didn't
|
||||||
|
```
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
51
.github/ISSUE_TEMPLATE/bug_report_v4.md
vendored
Normal file
51
.github/ISSUE_TEMPLATE/bug_report_v4.md
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
---
|
||||||
|
name: Bug report - V4
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: bug, v4
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
Note that any how to questions should be posted in the discussion board and not raised as an issue.
|
||||||
|
|
||||||
|
Version of yq: 4.X.X
|
||||||
|
Operating system: mac/linux/windows/....
|
||||||
|
Installed via: docker/binary release/homebrew/snap/...
|
||||||
|
|
||||||
|
**Input Yaml**
|
||||||
|
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
|
||||||
|
data1.yml:
|
||||||
|
```yaml
|
||||||
|
this: should really work
|
||||||
|
```
|
||||||
|
|
||||||
|
data2.yml:
|
||||||
|
```yaml
|
||||||
|
but: it strangely didn't
|
||||||
|
```
|
||||||
|
|
||||||
|
**Command**
|
||||||
|
The command you ran:
|
||||||
|
```
|
||||||
|
yq eval-all 'select(fileIndex==0) | .a.b.c' data1.yml data2.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
**Actual behavior**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
cat: meow
|
||||||
|
```
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
this: should really work
|
||||||
|
but: it strangely didn't
|
||||||
|
```
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
42
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
42
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
name: Feature request - V4
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: enhancement, v4
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Please describe your feature request.**
|
||||||
|
A clear and concise description of what the request is and what it would solve.
|
||||||
|
Eg. I wish I could use yq to [...]
|
||||||
|
|
||||||
|
Note:
|
||||||
|
- how to questions should be posted in the discussion board and not raised as an issue.
|
||||||
|
- V3 will no longer have any enhancements.
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
If we have data1.yml like:
|
||||||
|
(please keep to around 10 lines )
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
country: Australia
|
||||||
|
```
|
||||||
|
|
||||||
|
And we run a command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yq eval 'predictWeatherOf(.country)'
|
||||||
|
```
|
||||||
|
|
||||||
|
it could output
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
temp: 32
|
||||||
|
```
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
31
.github/workflows/go.yml
vendored
Normal file
31
.github/workflows/go.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
name: Build
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Set up Go 1.15
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: 1.15
|
||||||
|
id: go
|
||||||
|
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get dependencies
|
||||||
|
run: |
|
||||||
|
go get -v -t -d ./...
|
||||||
|
if [ -f Gopkg.toml ]; then
|
||||||
|
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||||
|
dep ensure
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Download deps
|
||||||
|
run: |
|
||||||
|
export PATH=${PATH}:`go env GOPATH`/bin
|
||||||
|
scripts/devtools.sh
|
||||||
|
make local build
|
70
.github/workflows/release.yml
vendored
Normal file
70
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
name: Release YQ
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publishGitRelease:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: '^1.15'
|
||||||
|
- name: Cross compile
|
||||||
|
run: |
|
||||||
|
sudo apt-get install rhash -y
|
||||||
|
go get github.com/mitchellh/gox
|
||||||
|
./scripts/xcompile.sh
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1.0.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
release_name: ${{ github.ref }}
|
||||||
|
draft: true
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
|
- uses: shogo82148/actions-upload-release-asset@v1
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: build/*
|
||||||
|
|
||||||
|
publishDocker:
|
||||||
|
environment: dockerhub
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: mikefarah/yq
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
with:
|
||||||
|
platforms: all
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
|
||||||
|
- name: Available platforms
|
||||||
|
run: echo ${{ steps.buildx.outputs.platforms }} && docker version
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
run: |
|
||||||
|
IMAGE_V_VERSION="$(git describe --tags --abbrev=0)"
|
||||||
|
IMAGE_VERSION=${IMAGE_V_VERSION:1}
|
||||||
|
|
||||||
|
SHORT_SHA1=$(git rev-parse --short HEAD)
|
||||||
|
PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64"
|
||||||
|
echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}"
|
||||||
|
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
||||||
|
docker buildx build --platform "${PLATFORMS}" -t "${IMAGE_NAME}:${IMAGE_VERSION}" -t "${IMAGE_NAME}:latest" -t "${IMAGE_NAME}:4" \
|
||||||
|
--push .
|
||||||
|
|
15
.gitignore
vendored
15
.gitignore
vendored
@ -6,7 +6,9 @@
|
|||||||
# Folders
|
# Folders
|
||||||
_obj
|
_obj
|
||||||
_test
|
_test
|
||||||
|
bin
|
||||||
build
|
build
|
||||||
|
build-done
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# Architecture specific extensions/prefixes
|
# Architecture specific extensions/prefixes
|
||||||
@ -20,8 +22,19 @@ _cgo_gotypes.go
|
|||||||
_cgo_export.*
|
_cgo_export.*
|
||||||
|
|
||||||
_testmain.go
|
_testmain.go
|
||||||
|
coverage.out
|
||||||
|
coverage.html
|
||||||
*.exe
|
*.exe
|
||||||
*.test
|
*.test
|
||||||
*.prof
|
*.prof
|
||||||
yaml
|
yaml
|
||||||
|
vendor/
|
||||||
|
tmp/
|
||||||
|
cover/
|
||||||
|
yq
|
||||||
|
|
||||||
|
# snapcraft
|
||||||
|
parts/
|
||||||
|
prime/
|
||||||
|
.snapcraft/
|
||||||
|
yq*.snap
|
||||||
|
76
CODE_OF_CONDUCT.md
Normal file
76
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to making participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||||
|
level of experience, education, socio-economic status, nationality, personal
|
||||||
|
appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces
|
||||||
|
when an individual is representing the project or its community. Examples of
|
||||||
|
representing a project or community include using an official project e-mail
|
||||||
|
address, posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event. Representation of a project may be
|
||||||
|
further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team at mikefarah@gmail.com. All
|
||||||
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||||
|
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see
|
||||||
|
https://www.contributor-covenant.org/faq
|
8
CONTRIBUTING.md
Normal file
8
CONTRIBUTING.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
1. Install (golang)[https://golang.org/]
|
||||||
|
1. Run `scripts/devtools.sh` to install the required devtools
|
||||||
|
2. Run `make [local] vendor` to install the vendor dependencies
|
||||||
|
2. Run `make [local] test` to ensure you can run the existing tests
|
||||||
|
3. Write unit tests - (see existing examples). Changes will not be accepted without corresponding unit tests.
|
||||||
|
4. Make the code changes.
|
||||||
|
5. `make [local] test` to lint code and run tests
|
||||||
|
6. Profit! ok no profit, but raise a PR and get kudos :)
|
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
FROM golang:1.15 as builder
|
||||||
|
|
||||||
|
WORKDIR /go/src/mikefarah/yq
|
||||||
|
|
||||||
|
# cache devtools
|
||||||
|
COPY ./scripts/devtools.sh /go/src/mikefarah/yq/scripts/devtools.sh
|
||||||
|
RUN ./scripts/devtools.sh
|
||||||
|
|
||||||
|
COPY . /go/src/mikefarah/yq
|
||||||
|
|
||||||
|
RUN CGO_ENABLED=0 make local build
|
||||||
|
|
||||||
|
# Choose alpine as a base image to make this useful for CI, as many
|
||||||
|
# CI tools expect an interactive shell inside the container
|
||||||
|
FROM alpine:3.12.3 as production
|
||||||
|
|
||||||
|
COPY --from=builder /go/src/mikefarah/yq/yq /usr/bin/yq
|
||||||
|
RUN chmod +x /usr/bin/yq
|
||||||
|
|
||||||
|
ARG VERSION=none
|
||||||
|
LABEL version=${VERSION}
|
||||||
|
|
||||||
|
WORKDIR /workdir
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/bin/yq"]
|
10
Dockerfile.dev
Normal file
10
Dockerfile.dev
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
FROM golang:1.15
|
||||||
|
|
||||||
|
COPY scripts/devtools.sh /opt/devtools.sh
|
||||||
|
|
||||||
|
RUN set -e -x \
|
||||||
|
&& /opt/devtools.sh
|
||||||
|
ENV PATH=/go/bin:$PATH
|
||||||
|
|
||||||
|
ENV CGO_ENABLED 0
|
||||||
|
ENV GOPATH /go:/yq
|
19
LICENSE
Normal file
19
LICENSE
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2017 Mike Farah
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
114
Makefile
Normal file
114
Makefile
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
SHELL := /bin/bash
|
||||||
|
.SHELLFLAGS := -o pipefail -euc
|
||||||
|
.DEFAULT_GOAL := install
|
||||||
|
|
||||||
|
include Makefile.variables
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
@echo 'Management commands for cicdtest:'
|
||||||
|
@echo
|
||||||
|
@echo 'Usage:'
|
||||||
|
@echo ' ## Develop / Test Commands'
|
||||||
|
@echo ' make build Build yq binary.'
|
||||||
|
@echo ' make install Install yq.'
|
||||||
|
@echo ' make xcompile Build cross-compiled binaries of yq.'
|
||||||
|
@echo ' make vendor Install dependencies to vendor directory.'
|
||||||
|
@echo ' make format Run code formatter.'
|
||||||
|
@echo ' make check Run static code analysis (lint).'
|
||||||
|
@echo ' make secure Run gosec.'
|
||||||
|
@echo ' make test Run tests on project.'
|
||||||
|
@echo ' make cover Run tests and capture code coverage metrics on project.'
|
||||||
|
@echo ' make clean Clean the directory tree of produced artifacts.'
|
||||||
|
@echo
|
||||||
|
@echo ' ## Utility Commands'
|
||||||
|
@echo ' make setup Configures Minishfit/Docker directory mounts.'
|
||||||
|
@echo
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
@rm -rf bin build cover *.out
|
||||||
|
|
||||||
|
## prefix before other make targets to run in your local dev environment
|
||||||
|
local: | quiet
|
||||||
|
@$(eval DOCKRUN= )
|
||||||
|
@mkdir -p tmp
|
||||||
|
@touch tmp/dev_image_id
|
||||||
|
quiet: # this is silly but shuts up 'Nothing to be done for `local`'
|
||||||
|
@:
|
||||||
|
|
||||||
|
prepare: tmp/dev_image_id
|
||||||
|
tmp/dev_image_id: Dockerfile.dev scripts/devtools.sh
|
||||||
|
@mkdir -p tmp
|
||||||
|
@docker rmi -f ${DEV_IMAGE} > /dev/null 2>&1 || true
|
||||||
|
@docker build -t ${DEV_IMAGE} -f Dockerfile.dev .
|
||||||
|
@docker inspect -f "{{ .ID }}" ${DEV_IMAGE} > tmp/dev_image_id
|
||||||
|
|
||||||
|
# ----------------------------------------------
|
||||||
|
# build
|
||||||
|
.PHONY: build
|
||||||
|
build: build/dev
|
||||||
|
|
||||||
|
.PHONY: build/dev
|
||||||
|
build/dev: test *.go
|
||||||
|
@mkdir -p bin/
|
||||||
|
${DOCKRUN} go build --ldflags "$(LDFLAGS)"
|
||||||
|
${DOCKRUN} bash ./scripts/acceptance.sh
|
||||||
|
|
||||||
|
## Compile the project for multiple OS and Architectures.
|
||||||
|
xcompile: check
|
||||||
|
@rm -rf build/
|
||||||
|
@mkdir -p build
|
||||||
|
${DOCKRUN} bash ./scripts/xcompile.sh
|
||||||
|
@find build -type d -exec chmod 755 {} \; || :
|
||||||
|
@find build -type f -exec chmod 755 {} \; || :
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: build
|
||||||
|
${DOCKRUN} go install
|
||||||
|
|
||||||
|
# Each of the fetch should be an entry within vendor.json; not currently included within project
|
||||||
|
.PHONY: vendor
|
||||||
|
vendor: tmp/dev_image_id
|
||||||
|
${DOCKRUN} go mod vendor
|
||||||
|
|
||||||
|
# ----------------------------------------------
|
||||||
|
# develop and test
|
||||||
|
|
||||||
|
.PHONY: format
|
||||||
|
format: vendor
|
||||||
|
${DOCKRUN} bash ./scripts/format.sh
|
||||||
|
|
||||||
|
.PHONY: check
|
||||||
|
check: format
|
||||||
|
${DOCKRUN} bash ./scripts/check.sh
|
||||||
|
|
||||||
|
.PHONY: secure
|
||||||
|
secure:
|
||||||
|
${DOCKRUN} bash ./scripts/secure.sh
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: check
|
||||||
|
${DOCKRUN} bash ./scripts/test.sh
|
||||||
|
|
||||||
|
.PHONY: cover
|
||||||
|
cover: check
|
||||||
|
@rm -rf cover/
|
||||||
|
@mkdir -p cover
|
||||||
|
${DOCKRUN} bash ./scripts/coverage.sh
|
||||||
|
@find cover -type d -exec chmod 755 {} \; || :
|
||||||
|
@find cover -type f -exec chmod 644 {} \; || :
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: release
|
||||||
|
release: xcompile
|
||||||
|
${DOCKRUN} bash ./scripts/publish.sh
|
||||||
|
|
||||||
|
# ----------------------------------------------
|
||||||
|
# utilities
|
||||||
|
|
||||||
|
.PHONY: setup
|
||||||
|
setup:
|
||||||
|
@bash ./scripts/setup.sh
|
38
Makefile.variables
Normal file
38
Makefile.variables
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
export PROJECT = yq
|
||||||
|
IMPORT_PATH := github.com/mikefarah/${PROJECT}
|
||||||
|
|
||||||
|
export GIT_COMMIT = $(shell git rev-parse --short HEAD)
|
||||||
|
export GIT_DIRTY = $(shell test -n "$$(git status --porcelain)" && echo "+CHANGES" || true)
|
||||||
|
export GIT_DESCRIBE = $(shell git describe --tags --always)
|
||||||
|
LDFLAGS :=
|
||||||
|
LDFLAGS += -X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}
|
||||||
|
LDFLAGS += -X main.GitDescribe=${GIT_DESCRIBE}
|
||||||
|
|
||||||
|
GITHUB_TOKEN ?=
|
||||||
|
|
||||||
|
# Windows environment?
|
||||||
|
CYG_CHECK := $(shell hash cygpath 2>/dev/null && echo 1)
|
||||||
|
ifeq ($(CYG_CHECK),1)
|
||||||
|
VBOX_CHECK := $(shell hash VBoxManage 2>/dev/null && echo 1)
|
||||||
|
|
||||||
|
# Docker Toolbox (pre-Windows 10)
|
||||||
|
ifeq ($(VBOX_CHECK),1)
|
||||||
|
ROOT := /${PROJECT}
|
||||||
|
else
|
||||||
|
# Docker Windows
|
||||||
|
ROOT := $(shell cygpath -m -a "$(shell pwd)")
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
# all non-windows environments
|
||||||
|
ROOT := $(shell pwd)
|
||||||
|
endif
|
||||||
|
|
||||||
|
DEV_IMAGE := ${PROJECT}_dev
|
||||||
|
|
||||||
|
DOCKRUN := docker run --rm \
|
||||||
|
-e LDFLAGS="${LDFLAGS}" \
|
||||||
|
-e GITHUB_TOKEN="${GITHUB_TOKEN}" \
|
||||||
|
-v ${ROOT}/vendor:/go/src \
|
||||||
|
-v ${ROOT}:/${PROJECT}/src/${IMPORT_PATH} \
|
||||||
|
-w /${PROJECT}/src/${IMPORT_PATH} \
|
||||||
|
${DEV_IMAGE}
|
295
README.md
295
README.md
@ -1,134 +1,211 @@
|
|||||||
# yaml
|
# yq
|
||||||
yaml is portable command line tool written in go
|
|
||||||
|
|
||||||
Allows you to read and update yaml files from bash (or whatever). All in a lovely dependency free binary!
|
   
|
||||||
|
|
||||||
[Download latest release](https://github.com/mikefarah/yaml/releases/latest)
|
|
||||||
|
|
||||||
or alternatively install using go get:
|
a lightweight and portable command-line YAML processor. `yq` uses [jq](https://github.com/stedolan/jq) like syntax but works with yaml files as well as json. It doesn't yet support everything `jq` does - but it does support the most common operations and functions, and more is being added continuously.
|
||||||
```
|
|
||||||
go get github.com/mikefarah/yaml
|
|
||||||
```
|
|
||||||
|
|
||||||
## Read examples
|
yq is written in go - so you can download a dependency free binary for your platform and you are good to go! If you prefer there are a variety of package managers that can be used as well as docker, all listed below.
|
||||||
```
|
|
||||||
yaml r <yaml file> <path>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Basic
|
## V4 released!
|
||||||
Given a sample.yaml file of:
|
V4 is now officially released, it's quite different from V3 (sorry for the migration), however it is much more similar to ```jq```, using a similar expression syntax and therefore support much more complex functionality!
|
||||||
```yaml
|
|
||||||
b:
|
If you've been using v3 and want/need to upgrade, checkout the [upgrade guide](https://mikefarah.gitbook.io/yq/v/v4.x/upgrading-from-v3).
|
||||||
c: 2
|
|
||||||
```
|
Support for v3 will cease August 2021, until then, critical bug and security fixes will still get applied if required.
|
||||||
then
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
### [Download the latest binary](https://github.com/mikefarah/yq/releases/latest)
|
||||||
|
|
||||||
|
### wget
|
||||||
|
Use wget to download the pre-compiled binaries:
|
||||||
|
|
||||||
|
#### Compressed via tar.gz
|
||||||
```bash
|
```bash
|
||||||
yaml r sample.yaml b.c
|
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\
|
||||||
|
tar xz && mv ${BINARY} /usr/bin/yq
|
||||||
```
|
```
|
||||||
will output the value of '2'.
|
|
||||||
|
|
||||||
### Reading from STDIN
|
#### Plain binary
|
||||||
Given a sample.yaml file of:
|
|
||||||
```bash
|
```bash
|
||||||
cat sample.yaml | yaml r - b.c
|
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq &&\
|
||||||
|
chmod +x /usr/bin/yq
|
||||||
```
|
```
|
||||||
will output the value of '2'.
|
|
||||||
|
|
||||||
### Splat
|
For instance, VERSION=v4.2.0 and BINARY=yq_linux_amd64
|
||||||
Given a sample.yaml file of:
|
|
||||||
```yaml
|
### MacOS / Linux via Homebrew:
|
||||||
---
|
Using [Homebrew](https://brew.sh/)
|
||||||
bob:
|
|
||||||
item1:
|
|
||||||
cats: bananas
|
|
||||||
item2:
|
|
||||||
cats: apples
|
|
||||||
```
|
```
|
||||||
then
|
brew install yq
|
||||||
|
```
|
||||||
|
|
||||||
|
or, for the (deprecated) v3 version:
|
||||||
|
|
||||||
|
```
|
||||||
|
brew install yq@3
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that for v3, as it is a versioned brew it will not add the `yq` command to your path automatically. Please follow the instructions given by brew upon installation.
|
||||||
|
|
||||||
|
### Linux via snap:
|
||||||
|
```
|
||||||
|
snap install yq
|
||||||
|
```
|
||||||
|
|
||||||
|
or, for the (deprecated) v3 version:
|
||||||
|
|
||||||
|
```
|
||||||
|
snap install yq --channel=v3/stable
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Snap notes
|
||||||
|
`yq` installs with [_strict confinement_](https://docs.snapcraft.io/snap-confinement/6233) in snap, this means it doesn't have direct access to root files. To read root files you can:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo cat /etc/myfile | yq e '.a.path' -
|
||||||
|
```
|
||||||
|
|
||||||
|
And to write to a root file you can either use [sponge](https://linux.die.net/man/1/sponge):
|
||||||
|
```
|
||||||
|
sudo cat /etc/myfile | yq e '.a.path = "value"' - | sudo sponge /etc/myfile
|
||||||
|
```
|
||||||
|
or write to a temporary file:
|
||||||
|
```
|
||||||
|
sudo cat /etc/myfile | yq e '.a.path = "value"' | sudo tee /etc/myfile.tmp
|
||||||
|
sudo mv /etc/myfile.tmp /etc/myfile
|
||||||
|
rm /etc/myfile.tmp
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run with Docker
|
||||||
|
|
||||||
|
#### Oneshot use:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yaml r sample.yaml bob.*.cats
|
docker run --rm -v "${PWD}":/workdir mikefarah/yq <command> [flags] [expression ]FILE...
|
||||||
```
|
|
||||||
will output
|
|
||||||
```yaml
|
|
||||||
- bananas
|
|
||||||
- apples
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Handling '.' in the yaml key
|
#### Run commands interactively:
|
||||||
Given a sample.yaml file of:
|
|
||||||
```yaml
|
|
||||||
b.x:
|
|
||||||
c: 2
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```bash
|
```bash
|
||||||
yaml r sample.yaml \"b.x\".c
|
docker run --rm -it -v "${PWD}":/workdir --entrypoint sh mikefarah/yq
|
||||||
```
|
|
||||||
will output the value of '2'.
|
|
||||||
|
|
||||||
### Arrays
|
|
||||||
You can give an index to access a specific element:
|
|
||||||
e.g.: given a sample file of
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
e:
|
|
||||||
- name: fred
|
|
||||||
value: 3
|
|
||||||
- name: sam
|
|
||||||
value: 4
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```
|
|
||||||
yaml r sample.yaml b.e[1].name
|
|
||||||
```
|
|
||||||
will output 'sam'
|
|
||||||
|
|
||||||
### Array Splat
|
|
||||||
e.g.: given a sample file of
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
e:
|
|
||||||
- name: fred
|
|
||||||
value: 3
|
|
||||||
- name: sam
|
|
||||||
value: 4
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```
|
|
||||||
yaml r sample.yaml b.e[*].name
|
|
||||||
```
|
|
||||||
will output:
|
|
||||||
```
|
|
||||||
- fred
|
|
||||||
- sam
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Update examples
|
It can be useful to have a bash function to avoid typing the whole docker command:
|
||||||
|
|
||||||
### Update to stdout
|
|
||||||
Given a sample.yaml file of:
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
c: 2
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```bash
|
```bash
|
||||||
yaml w sample.yaml b.c cat
|
yq() {
|
||||||
```
|
docker run --rm -i -v "${PWD}":/workdir mikefarah/yq "$@"
|
||||||
will output:
|
}
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
c: cat
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Updating yaml in-place
|
### Go Get:
|
||||||
Given a sample.yaml file of:
|
|
||||||
```yaml
|
|
||||||
b:
|
|
||||||
c: 2
|
|
||||||
```
|
```
|
||||||
then
|
GO111MODULE=on go get github.com/mikefarah/yq/v4
|
||||||
|
```
|
||||||
|
|
||||||
|
## Community Supported Installation methods
|
||||||
|
As these are supported by the community :heart: - however, they may be out of date with the officially supported releases.
|
||||||
|
|
||||||
|
# Webi
|
||||||
|
|
||||||
|
```
|
||||||
|
webi yq
|
||||||
|
```
|
||||||
|
|
||||||
|
See [webi](https://webinstall.dev/)
|
||||||
|
Supported by @adithyasunil26 (https://github.com/webinstall/webi-installers/tree/master/yq)
|
||||||
|
|
||||||
|
### Windows:
|
||||||
|
[](https://chocolatey.org/packages/yq)
|
||||||
|
[](https://chocolatey.org/packages/yq)
|
||||||
|
```
|
||||||
|
choco install yq
|
||||||
|
```
|
||||||
|
Supported by @chillum (https://chocolatey.org/packages/yq)
|
||||||
|
|
||||||
|
### Mac:
|
||||||
|
Using [MacPorts](https://www.macports.org/)
|
||||||
|
```
|
||||||
|
sudo port selfupdate
|
||||||
|
sudo port install yq
|
||||||
|
```
|
||||||
|
Supported by @herbygillot (https://ports.macports.org/maintainer/github/herbygillot)
|
||||||
|
|
||||||
|
### Alpine Linux
|
||||||
|
- Enable edge/community repo by adding ```$MIRROR/alpine/edge/community``` to ```/etc/apk/repositories```
|
||||||
|
- Update database index with ```apk update```
|
||||||
|
- Install yq with ```apk add yq```
|
||||||
|
|
||||||
|
Supported by Tuan Hoang
|
||||||
|
https://pkgs.alpinelinux.org/package/edge/community/x86/yq
|
||||||
|
|
||||||
|
|
||||||
|
### On Ubuntu 16.04 or higher from Debian package:
|
||||||
|
```sh
|
||||||
|
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
|
||||||
|
sudo add-apt-repository ppa:rmescandon/yq
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install yq -y
|
||||||
|
```
|
||||||
|
Supported by @rmescandon (https://launchpad.net/~rmescandon/+archive/ubuntu/yq)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- [Detailed documentation with many examples](https://mikefarah.gitbook.io/yq/)
|
||||||
|
- Written in portable go, so you can download a lovely dependency free binary
|
||||||
|
- Uses similar syntax as `jq` but works with YAML and JSON files
|
||||||
|
- Fully supports multi document yaml files
|
||||||
|
- Colorized yaml output
|
||||||
|
- [Deeply traverse yaml](https://mikefarah.gitbook.io/yq/operators/traverse-read)
|
||||||
|
- [Sort yaml by keys](https://mikefarah.gitbook.io/yq/operators/sort-keys)
|
||||||
|
- Manipulate yaml [comments](https://mikefarah.gitbook.io/yq/operators/comment-operators), [styling](https://mikefarah.gitbook.io/yq/operators/style), [tags](https://mikefarah.gitbook.io/yq/operators/tag) and [anchors and aliases](https://mikefarah.gitbook.io/yq/operators/anchor-and-alias-operators).
|
||||||
|
- [Update yaml inplace](https://mikefarah.gitbook.io/yq/v/v4.x/commands/evaluate#flags)
|
||||||
|
- [Complex expressions to select and update](https://mikefarah.gitbook.io/yq/operators/select#select-and-update-matching-values-in-map)
|
||||||
|
- Keeps yaml formatting and comments when updating (though there are issues with whitespace)
|
||||||
|
- [Convert to/from json to yaml](https://mikefarah.gitbook.io/yq/v/v4.x/usage/convert)
|
||||||
|
- [Pipe data in by using '-'](https://mikefarah.gitbook.io/yq/v/v4.x/commands/evaluate)
|
||||||
|
- [General shell completion scripts (bash/zsh/fish/powershell)](https://mikefarah.gitbook.io/yq/v/v4.x/commands/shell-completion)
|
||||||
|
- [Reduce](https://mikefarah.gitbook.io/yq/operators/reduce) to merge multiple files or sum an array or other fancy things.
|
||||||
|
|
||||||
|
## [Usage](https://mikefarah.gitbook.io/yq/)
|
||||||
|
|
||||||
|
Check out the [documentation](https://mikefarah.gitbook.io/yq/) for more detailed and advanced usage.
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage:
|
||||||
|
yq [flags]
|
||||||
|
yq [command]
|
||||||
|
|
||||||
|
Available Commands:
|
||||||
|
eval Apply expression to each document in each yaml file given in sequence
|
||||||
|
eval-all Loads _all_ yaml documents of _all_ yaml files and runs expression once
|
||||||
|
help Help about any command
|
||||||
|
shell-completion Generate completion script
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
-C, --colors force print with colors
|
||||||
|
-e, --exit-status set exit status if there are no matches or null or false is returned
|
||||||
|
-h, --help help for yq
|
||||||
|
-I, --indent int sets indent level for output (default 2)
|
||||||
|
-i, --inplace update the yaml file inplace of first yaml file given.
|
||||||
|
-M, --no-colors force print with no colors
|
||||||
|
-N, --no-doc Don't print document separators (---)
|
||||||
|
-n, --null-input Don't read input, simply evaluate the expression given. Useful for creating yaml docs from scratch.
|
||||||
|
-P, --prettyPrint pretty print, shorthand for '... style = ""'
|
||||||
|
-j, --tojson output as json. Set indent to 0 to print json in one line.
|
||||||
|
-v, --verbose verbose mode
|
||||||
|
-V, --version Print version information and quit
|
||||||
|
|
||||||
|
Use "yq [command] --help" for more information about a command.
|
||||||
|
```
|
||||||
|
|
||||||
|
Simple Example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yaml w -i sample.yaml b.c cat
|
yq e '.a.b | length' f1.yml f2.yml
|
||||||
```
|
```
|
||||||
will update the sample.yaml file so that the value of 'c' is cat.
|
|
||||||
|
## Known Issues / Missing Features
|
||||||
|
- `yq` attempts to preserve comment positions and whitespace as much as possible, but it does not handle all scenarios (see https://github.com/go-yaml/yaml/tree/v3 for details)
|
||||||
|
13
action.yml
Normal file
13
action.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
name: 'yq - portable yaml processor'
|
||||||
|
description: 'create, read, update, delete, merge, validate and do more with yaml'
|
||||||
|
icon: command
|
||||||
|
color: gray-dark
|
||||||
|
inputs:
|
||||||
|
cmd:
|
||||||
|
description: 'The Command which should be run'
|
||||||
|
required: true
|
||||||
|
runs:
|
||||||
|
using: 'docker'
|
||||||
|
image: 'github-action/Dockerfile'
|
||||||
|
args:
|
||||||
|
- ${{ inputs.cmd }}
|
83
cmd/commands_test.go
Normal file
83
cmd/commands_test.go
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
// import (
|
||||||
|
// "strings"
|
||||||
|
// "testing"
|
||||||
|
|
||||||
|
// "github.com/mikefarah/yq/v3/test"
|
||||||
|
// "github.com/spf13/cobra"
|
||||||
|
// )
|
||||||
|
|
||||||
|
// func getRootCommand() *cobra.Command {
|
||||||
|
// return New()
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func TestRootCmd(t *testing.T) {
|
||||||
|
// cmd := getRootCommand()
|
||||||
|
// result := test.RunCmd(cmd, "")
|
||||||
|
// if result.Error != nil {
|
||||||
|
// t.Error(result.Error)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if !strings.Contains(result.Output, "Usage:") {
|
||||||
|
// t.Error("Expected usage message to be printed out, but the usage message was not found.")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func TestRootCmd_Help(t *testing.T) {
|
||||||
|
// cmd := getRootCommand()
|
||||||
|
// result := test.RunCmd(cmd, "--help")
|
||||||
|
// if result.Error != nil {
|
||||||
|
// t.Error(result.Error)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if !strings.Contains(result.Output, "yq is a lightweight and portable command-line YAML processor. It aims to be the jq or sed of yaml files.") {
|
||||||
|
// t.Error("Expected usage message to be printed out, but the usage message was not found.")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func TestRootCmd_VerboseLong(t *testing.T) {
|
||||||
|
// cmd := getRootCommand()
|
||||||
|
// result := test.RunCmd(cmd, "--verbose")
|
||||||
|
// if result.Error != nil {
|
||||||
|
// t.Error(result.Error)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if !verbose {
|
||||||
|
// t.Error("Expected verbose to be true")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func TestRootCmd_VerboseShort(t *testing.T) {
|
||||||
|
// cmd := getRootCommand()
|
||||||
|
// result := test.RunCmd(cmd, "-v")
|
||||||
|
// if result.Error != nil {
|
||||||
|
// t.Error(result.Error)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if !verbose {
|
||||||
|
// t.Error("Expected verbose to be true")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func TestRootCmd_VersionShort(t *testing.T) {
|
||||||
|
// cmd := getRootCommand()
|
||||||
|
// result := test.RunCmd(cmd, "-V")
|
||||||
|
// if result.Error != nil {
|
||||||
|
// t.Error(result.Error)
|
||||||
|
// }
|
||||||
|
// if !strings.Contains(result.Output, "yq version") {
|
||||||
|
// t.Error("expected version message to be printed out, but the message was not found.")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func TestRootCmd_VersionLong(t *testing.T) {
|
||||||
|
// cmd := getRootCommand()
|
||||||
|
// result := test.RunCmd(cmd, "--version")
|
||||||
|
// if result.Error != nil {
|
||||||
|
// t.Error(result.Error)
|
||||||
|
// }
|
||||||
|
// if !strings.Contains(result.Output, "yq version") {
|
||||||
|
// t.Error("expected version message to be printed out, but the message was not found.")
|
||||||
|
// }
|
||||||
|
// }
|
19
cmd/constant.go
Normal file
19
cmd/constant.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
var unwrapScalar = true
|
||||||
|
|
||||||
|
var writeInplace = false
|
||||||
|
var outputToJSON = false
|
||||||
|
|
||||||
|
var exitStatus = false
|
||||||
|
var forceColor = false
|
||||||
|
var forceNoColor = false
|
||||||
|
var colorsEnabled = false
|
||||||
|
var indent = 2
|
||||||
|
var noDocSeparators = false
|
||||||
|
var nullInput = false
|
||||||
|
var verbose = false
|
||||||
|
var version = false
|
||||||
|
var prettyPrint = false
|
||||||
|
|
||||||
|
var completedSuccessfully = false
|
104
cmd/evaluate_all_command.go
Normal file
104
cmd/evaluate_all_command.go
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/mikefarah/yq/v4/pkg/yqlib"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func createEvaluateAllCommand() *cobra.Command {
|
||||||
|
var cmdEvalAll = &cobra.Command{
|
||||||
|
Use: "eval-all [expression] [yaml_file1]...",
|
||||||
|
Aliases: []string{"ea"},
|
||||||
|
Short: "Loads _all_ yaml documents of _all_ yaml files and runs expression once",
|
||||||
|
Example: `
|
||||||
|
# merges f2.yml into f1.yml (inplace)
|
||||||
|
yq eval-all --inplace 'select(fileIndex == 0) * select(fileIndex == 1)' f1.yml f2.yml
|
||||||
|
|
||||||
|
# use '-' as a filename to read from STDIN
|
||||||
|
cat file2.yml | yq ea '.a.b' file1.yml - file3.yml
|
||||||
|
`,
|
||||||
|
Long: "Evaluate All:\nUseful when you need to run an expression across several yaml documents or files. Consumes more memory than eval",
|
||||||
|
RunE: evaluateAll,
|
||||||
|
}
|
||||||
|
return cmdEvalAll
|
||||||
|
}
|
||||||
|
func evaluateAll(cmd *cobra.Command, args []string) error {
|
||||||
|
cmd.SilenceUsage = true
|
||||||
|
// 0 args, read std in
|
||||||
|
// 1 arg, null input, process expression
|
||||||
|
// 1 arg, read file in sequence
|
||||||
|
// 2+ args, [0] = expression, file the rest
|
||||||
|
|
||||||
|
var err error
|
||||||
|
stat, _ := os.Stdin.Stat()
|
||||||
|
pipingStdIn := (stat.Mode() & os.ModeCharDevice) == 0
|
||||||
|
|
||||||
|
out := cmd.OutOrStdout()
|
||||||
|
|
||||||
|
fileInfo, _ := os.Stdout.Stat()
|
||||||
|
|
||||||
|
if forceColor || (!forceNoColor && (fileInfo.Mode()&os.ModeCharDevice) != 0) {
|
||||||
|
colorsEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
firstFileIndex := -1
|
||||||
|
if !nullInput && len(args) == 1 {
|
||||||
|
firstFileIndex = 0
|
||||||
|
} else if len(args) > 1 {
|
||||||
|
firstFileIndex = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if writeInplace && (firstFileIndex == -1) {
|
||||||
|
return fmt.Errorf("Write inplace flag only applicable when giving an expression and at least one file")
|
||||||
|
}
|
||||||
|
|
||||||
|
if writeInplace {
|
||||||
|
// only use colors if its forced
|
||||||
|
colorsEnabled = forceColor
|
||||||
|
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[firstFileIndex])
|
||||||
|
out, err = writeInPlaceHandler.CreateTempFile()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// need to indirectly call the function so that completedSuccessfully is
|
||||||
|
// passed when we finish execution as opposed to now
|
||||||
|
defer func() { writeInPlaceHandler.FinishWriteInPlace(completedSuccessfully) }()
|
||||||
|
}
|
||||||
|
|
||||||
|
if nullInput && len(args) > 1 {
|
||||||
|
return errors.New("Cannot pass files in when using null-input flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
printer := yqlib.NewPrinter(out, outputToJSON, unwrapScalar, colorsEnabled, indent, !noDocSeparators)
|
||||||
|
|
||||||
|
allAtOnceEvaluator := yqlib.NewAllAtOnceEvaluator()
|
||||||
|
switch len(args) {
|
||||||
|
case 0:
|
||||||
|
if pipingStdIn {
|
||||||
|
err = allAtOnceEvaluator.EvaluateFiles(processExpression(""), []string{"-"}, printer)
|
||||||
|
} else {
|
||||||
|
cmd.Println(cmd.UsageString())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
if nullInput {
|
||||||
|
err = yqlib.NewStreamEvaluator().EvaluateNew(processExpression(args[0]), printer)
|
||||||
|
} else {
|
||||||
|
err = allAtOnceEvaluator.EvaluateFiles(processExpression(""), []string{args[0]}, printer)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
err = allAtOnceEvaluator.EvaluateFiles(processExpression(args[0]), args[1:], printer)
|
||||||
|
}
|
||||||
|
|
||||||
|
completedSuccessfully = err == nil
|
||||||
|
|
||||||
|
if err == nil && exitStatus && !printer.PrintedAnything() {
|
||||||
|
return errors.New("no matches found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
124
cmd/evalute_sequence_command.go
Normal file
124
cmd/evalute_sequence_command.go
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/mikefarah/yq/v4/pkg/yqlib"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func createEvaluateSequenceCommand() *cobra.Command {
|
||||||
|
var cmdEvalSequence = &cobra.Command{
|
||||||
|
Use: "eval [expression] [yaml_file1]...",
|
||||||
|
Aliases: []string{"e"},
|
||||||
|
Short: "Apply expression to each document in each yaml file given in sequence",
|
||||||
|
Example: `
|
||||||
|
# runs the expression against each file, in series
|
||||||
|
yq e '.a.b | length' f1.yml f2.yml
|
||||||
|
|
||||||
|
# prints out the file
|
||||||
|
yq e sample.yaml
|
||||||
|
|
||||||
|
# use '-' as a filename to read from STDIN
|
||||||
|
cat file2.yml | yq e '.a.b' file1.yml - file3.yml
|
||||||
|
|
||||||
|
# prints a new yaml document
|
||||||
|
yq e -n '.a.b.c = "cat"'
|
||||||
|
|
||||||
|
|
||||||
|
# updates file.yaml directly
|
||||||
|
yq e '.a.b = "cool"' -i file.yaml
|
||||||
|
`,
|
||||||
|
Long: "Evaluate Sequence:\nIterate over each yaml document, apply the expression and print the results, in sequence.",
|
||||||
|
RunE: evaluateSequence,
|
||||||
|
}
|
||||||
|
return cmdEvalSequence
|
||||||
|
}
|
||||||
|
|
||||||
|
func processExpression(expression string) string {
|
||||||
|
if prettyPrint && expression == "" {
|
||||||
|
return `... style=""`
|
||||||
|
} else if prettyPrint {
|
||||||
|
return fmt.Sprintf("%v | ... style= \"\"", expression)
|
||||||
|
}
|
||||||
|
return expression
|
||||||
|
}
|
||||||
|
|
||||||
|
func evaluateSequence(cmd *cobra.Command, args []string) error {
|
||||||
|
cmd.SilenceUsage = true
|
||||||
|
// 0 args, read std in
|
||||||
|
// 1 arg, null input, process expression
|
||||||
|
// 1 arg, read file in sequence
|
||||||
|
// 2+ args, [0] = expression, file the rest
|
||||||
|
|
||||||
|
var err error
|
||||||
|
stat, _ := os.Stdin.Stat()
|
||||||
|
pipingStdIn := (stat.Mode() & os.ModeCharDevice) == 0
|
||||||
|
|
||||||
|
out := cmd.OutOrStdout()
|
||||||
|
|
||||||
|
fileInfo, _ := os.Stdout.Stat()
|
||||||
|
|
||||||
|
if forceColor || (!forceNoColor && (fileInfo.Mode()&os.ModeCharDevice) != 0) {
|
||||||
|
colorsEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
firstFileIndex := -1
|
||||||
|
if !nullInput && len(args) == 1 {
|
||||||
|
firstFileIndex = 0
|
||||||
|
} else if len(args) > 1 {
|
||||||
|
firstFileIndex = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if writeInplace && (firstFileIndex == -1) {
|
||||||
|
return fmt.Errorf("Write inplace flag only applicable when giving an expression and at least one file")
|
||||||
|
}
|
||||||
|
|
||||||
|
if writeInplace {
|
||||||
|
// only use colors if its forced
|
||||||
|
colorsEnabled = forceColor
|
||||||
|
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[firstFileIndex])
|
||||||
|
out, err = writeInPlaceHandler.CreateTempFile()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// need to indirectly call the function so that completedSuccessfully is
|
||||||
|
// passed when we finish execution as opposed to now
|
||||||
|
defer func() { writeInPlaceHandler.FinishWriteInPlace(completedSuccessfully) }()
|
||||||
|
}
|
||||||
|
|
||||||
|
printer := yqlib.NewPrinter(out, outputToJSON, unwrapScalar, colorsEnabled, indent, !noDocSeparators)
|
||||||
|
|
||||||
|
streamEvaluator := yqlib.NewStreamEvaluator()
|
||||||
|
|
||||||
|
if nullInput && len(args) > 1 {
|
||||||
|
return errors.New("Cannot pass files in when using null-input flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch len(args) {
|
||||||
|
case 0:
|
||||||
|
if pipingStdIn {
|
||||||
|
err = streamEvaluator.EvaluateFiles(processExpression(""), []string{"-"}, printer)
|
||||||
|
} else {
|
||||||
|
cmd.Println(cmd.UsageString())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
if nullInput {
|
||||||
|
err = streamEvaluator.EvaluateNew(processExpression(args[0]), printer)
|
||||||
|
} else {
|
||||||
|
err = streamEvaluator.EvaluateFiles(processExpression(""), []string{args[0]}, printer)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
err = streamEvaluator.EvaluateFiles(processExpression(args[0]), args[1:], printer)
|
||||||
|
}
|
||||||
|
completedSuccessfully = err == nil
|
||||||
|
|
||||||
|
if err == nil && exitStatus && !printer.PrintedAnything() {
|
||||||
|
return errors.New("no matches found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
62
cmd/root.go
Normal file
62
cmd/root.go
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
logging "gopkg.in/op/go-logging.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
func New() *cobra.Command {
|
||||||
|
var rootCmd = &cobra.Command{
|
||||||
|
Use: "yq",
|
||||||
|
Short: "yq is a lightweight and portable command-line YAML processor.",
|
||||||
|
Long: `yq is a lightweight and portable command-line YAML processor. It aims to be the jq or sed of yaml files.`,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
if version {
|
||||||
|
cmd.Print(GetVersionDisplay())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
cmd.Println(cmd.UsageString())
|
||||||
|
return nil
|
||||||
|
|
||||||
|
},
|
||||||
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
cmd.SetOut(cmd.OutOrStdout())
|
||||||
|
var format = logging.MustStringFormatter(
|
||||||
|
`%{color}%{time:15:04:05} %{shortfunc} [%{level:.4s}]%{color:reset} %{message}`,
|
||||||
|
)
|
||||||
|
var backend = logging.AddModuleLevel(
|
||||||
|
logging.NewBackendFormatter(logging.NewLogBackend(os.Stderr, "", 0), format))
|
||||||
|
|
||||||
|
if verbose {
|
||||||
|
backend.SetLevel(logging.DEBUG, "")
|
||||||
|
} else {
|
||||||
|
backend.SetLevel(logging.ERROR, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
logging.SetBackend(backend)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose mode")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&outputToJSON, "tojson", "j", false, "output as json. Set indent to 0 to print json in one line.")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&nullInput, "null-input", "n", false, "Don't read input, simply evaluate the expression given. Useful for creating yaml docs from scratch.")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&noDocSeparators, "no-doc", "N", false, "Don't print document separators (---)")
|
||||||
|
|
||||||
|
rootCmd.PersistentFlags().IntVarP(&indent, "indent", "I", 2, "sets indent level for output")
|
||||||
|
rootCmd.Flags().BoolVarP(&version, "version", "V", false, "Print version information and quit")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace of first yaml file given.")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&unwrapScalar, "unwrapScalar", "", true, "unwrap scalar, print the value with no quotes, colors or comments")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&prettyPrint, "prettyPrint", "P", false, "pretty print, shorthand for '... style = \"\"'")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&exitStatus, "exit-status", "e", false, "set exit status if there are no matches or null or false is returned")
|
||||||
|
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&forceColor, "colors", "C", false, "force print with colors")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&forceNoColor, "no-colors", "M", false, "force print with no colors")
|
||||||
|
rootCmd.AddCommand(
|
||||||
|
createEvaluateSequenceCommand(),
|
||||||
|
createEvaluateAllCommand(),
|
||||||
|
completionCmd,
|
||||||
|
)
|
||||||
|
return rootCmd
|
||||||
|
}
|
61
cmd/shell-completion.go
Normal file
61
cmd/shell-completion.go
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var completionCmd = &cobra.Command{
|
||||||
|
Use: "shell-completion [bash|zsh|fish|powershell]",
|
||||||
|
Short: "Generate completion script",
|
||||||
|
Long: `To load completions:
|
||||||
|
|
||||||
|
Bash:
|
||||||
|
|
||||||
|
$ source <(yq shell-completion bash)
|
||||||
|
|
||||||
|
# To load completions for each session, execute once:
|
||||||
|
Linux:
|
||||||
|
$ yq shell-completion bash > /etc/bash_completion.d/yq
|
||||||
|
MacOS:
|
||||||
|
$ yq shell-completion bash > /usr/local/etc/bash_completion.d/yq
|
||||||
|
|
||||||
|
Zsh:
|
||||||
|
|
||||||
|
# If shell completion is not already enabled in your environment you will need
|
||||||
|
# to enable it. You can execute the following once:
|
||||||
|
|
||||||
|
$ echo "autoload -U compinit; compinit" >> ~/.zshrc
|
||||||
|
|
||||||
|
# To load completions for each session, execute once:
|
||||||
|
$ yq shell-completion zsh > "${fpath[1]}/_yq"
|
||||||
|
|
||||||
|
# You will need to start a new shell for this setup to take effect.
|
||||||
|
|
||||||
|
Fish:
|
||||||
|
|
||||||
|
$ yq shell-completion fish | source
|
||||||
|
|
||||||
|
# To load completions for each session, execute once:
|
||||||
|
$ yq shell-completion fish > ~/.config/fish/completions/yq.fish
|
||||||
|
`,
|
||||||
|
DisableFlagsInUseLine: true,
|
||||||
|
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
||||||
|
Args: cobra.ExactValidArgs(1),
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
var err error = nil
|
||||||
|
switch args[0] {
|
||||||
|
case "bash":
|
||||||
|
err = cmd.Root().GenBashCompletion(os.Stdout)
|
||||||
|
case "zsh":
|
||||||
|
err = cmd.Root().GenZshCompletion(os.Stdout)
|
||||||
|
case "fish":
|
||||||
|
err = cmd.Root().GenFishCompletion(os.Stdout, true)
|
||||||
|
case "powershell":
|
||||||
|
err = cmd.Root().GenPowerShellCompletion(os.Stdout)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
49
cmd/version.go
Normal file
49
cmd/version.go
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The git commit that was compiled. This will be filled in by the compiler.
|
||||||
|
var (
|
||||||
|
GitCommit string
|
||||||
|
GitDescribe string
|
||||||
|
|
||||||
|
// Version is main version number that is being run at the moment.
|
||||||
|
Version = "4.9.3"
|
||||||
|
|
||||||
|
// VersionPrerelease is a pre-release marker for the version. If this is "" (empty string)
|
||||||
|
// then it means that it is a final release. Otherwise, this is a pre-release
|
||||||
|
// such as "dev" (in development), "beta", "rc1", etc.
|
||||||
|
VersionPrerelease = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProductName is the name of the product
|
||||||
|
const ProductName = "yq"
|
||||||
|
|
||||||
|
// GetVersionDisplay composes the parts of the version in a way that's suitable
|
||||||
|
// for displaying to humans.
|
||||||
|
func GetVersionDisplay() string {
|
||||||
|
return fmt.Sprintf("%s version %s\n", ProductName, getHumanVersion())
|
||||||
|
}
|
||||||
|
|
||||||
|
func getHumanVersion() string {
|
||||||
|
version := Version
|
||||||
|
if GitDescribe != "" {
|
||||||
|
version = GitDescribe
|
||||||
|
}
|
||||||
|
|
||||||
|
release := VersionPrerelease
|
||||||
|
if release != "" {
|
||||||
|
if !strings.Contains(version, release) {
|
||||||
|
version += fmt.Sprintf("-%s", release)
|
||||||
|
}
|
||||||
|
if GitCommit != "" {
|
||||||
|
version += fmt.Sprintf(" (%s)", GitCommit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strip off any single quotes added by the git information.
|
||||||
|
return strings.Replace(version, "'", "", -1)
|
||||||
|
}
|
51
cmd/version_test.go
Normal file
51
cmd/version_test.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestGetVersionDisplay(t *testing.T) {
|
||||||
|
var expectedVersion = ProductName + " version " + Version
|
||||||
|
if VersionPrerelease != "" {
|
||||||
|
expectedVersion = expectedVersion + "-" + VersionPrerelease
|
||||||
|
}
|
||||||
|
expectedVersion = expectedVersion + "\n"
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Display Version",
|
||||||
|
want: expectedVersion,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
if got := GetVersionDisplay(); got != tt.want {
|
||||||
|
t.Errorf("%q. GetVersionDisplay() = %v, want %v", tt.name, got, tt.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_getHumanVersion(t *testing.T) {
|
||||||
|
GitDescribe = "e42813d"
|
||||||
|
GitCommit = "e42813d+CHANGES"
|
||||||
|
var wanted string
|
||||||
|
if VersionPrerelease == "" {
|
||||||
|
wanted = GitDescribe
|
||||||
|
} else {
|
||||||
|
wanted = "e42813d-" + VersionPrerelease + " (e42813d+CHANGES)"
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Git Variables defined",
|
||||||
|
want: wanted,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
if got := getHumanVersion(); got != tt.want {
|
||||||
|
t.Errorf("%q. getHumanVersion() = %v, want %v", tt.name, got, tt.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,83 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
// "fmt"
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
func write(context map[interface{}]interface{}, head string, tail []string, value interface{}) {
|
|
||||||
if len(tail) == 0 {
|
|
||||||
context[head] = value
|
|
||||||
} else {
|
|
||||||
// e.g. if updating a.b.c, we need to get the 'b' map...
|
|
||||||
toUpdate := readMap(context, head, tail[0:len(tail)-1]).(map[interface{}]interface{})
|
|
||||||
// and then set the 'c' key.
|
|
||||||
key := (tail[len(tail)-1])
|
|
||||||
toUpdate[key] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func readMap(context map[interface{}]interface{}, head string, tail []string) interface{} {
|
|
||||||
if head == "*" {
|
|
||||||
return readMapSplat(context, tail)
|
|
||||||
}
|
|
||||||
value := context[head]
|
|
||||||
return calculateValue(value, tail)
|
|
||||||
}
|
|
||||||
|
|
||||||
func readMapSplat(context map[interface{}]interface{}, tail []string) interface{} {
|
|
||||||
var newArray = make([]interface{}, len(context))
|
|
||||||
var i = 0
|
|
||||||
for _, value := range context {
|
|
||||||
if len(tail) > 0 {
|
|
||||||
newArray[i] = recurse(value, tail[0], tail[1:len(tail)])
|
|
||||||
} else {
|
|
||||||
newArray[i] = value
|
|
||||||
}
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
return newArray
|
|
||||||
}
|
|
||||||
|
|
||||||
func recurse(value interface{}, head string, tail []string) interface{} {
|
|
||||||
switch value.(type) {
|
|
||||||
case []interface{}:
|
|
||||||
if head == "*" {
|
|
||||||
return readArraySplat(value.([]interface{}), tail)
|
|
||||||
}
|
|
||||||
index, err := strconv.ParseInt(head, 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
die("Error accessing array: %v", err)
|
|
||||||
}
|
|
||||||
return readArray(value.([]interface{}), index, tail)
|
|
||||||
case map[interface{}]interface{}:
|
|
||||||
return readMap(value.(map[interface{}]interface{}), head, tail)
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func readArray(array []interface{}, head int64, tail []string) interface{} {
|
|
||||||
if head > int64(len(array)) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
value := array[head]
|
|
||||||
|
|
||||||
return calculateValue(value, tail)
|
|
||||||
}
|
|
||||||
|
|
||||||
func readArraySplat(array []interface{}, tail []string) interface{} {
|
|
||||||
var newArray = make([]interface{}, len(array))
|
|
||||||
for index, value := range array {
|
|
||||||
newArray[index] = calculateValue(value, tail)
|
|
||||||
}
|
|
||||||
return newArray
|
|
||||||
}
|
|
||||||
|
|
||||||
func calculateValue(value interface{}, tail []string) interface{} {
|
|
||||||
if len(tail) > 0 {
|
|
||||||
return recurse(value, tail[0], tail[1:len(tail)])
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
@ -1,143 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
"os"
|
|
||||||
"sort"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func parseData(rawData string) map[interface{}]interface{} {
|
|
||||||
var parsedData map[interface{}]interface{}
|
|
||||||
err := yaml.Unmarshal([]byte(rawData), &parsedData)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error parsing yaml: %v", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
return parsedData
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadMap_simple(t *testing.T) {
|
|
||||||
var data = parseData(`
|
|
||||||
---
|
|
||||||
b:
|
|
||||||
c: 2
|
|
||||||
`)
|
|
||||||
assertResult(t, 2, readMap(data, "b", []string{"c"}))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadMap_splat(t *testing.T) {
|
|
||||||
var data = parseData(`
|
|
||||||
---
|
|
||||||
mapSplat:
|
|
||||||
item1: things
|
|
||||||
item2: whatever
|
|
||||||
`)
|
|
||||||
assertResult(t, "[things whatever]", fmt.Sprintf("%v", readMap(data, "mapSplat", []string{"*"})))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadMap_deep_splat(t *testing.T) {
|
|
||||||
var data = parseData(`
|
|
||||||
---
|
|
||||||
mapSplatDeep:
|
|
||||||
item1:
|
|
||||||
cats: bananas
|
|
||||||
item2:
|
|
||||||
cats: apples
|
|
||||||
`)
|
|
||||||
|
|
||||||
var result = readMap(data, "mapSplatDeep", []string{"*", "cats"}).([]interface{})
|
|
||||||
var actual = []string{result[0].(string), result[1].(string)}
|
|
||||||
sort.Strings(actual)
|
|
||||||
assertResult(t, "[apples bananas]", fmt.Sprintf("%v", actual))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadMap_key_doesnt_exist(t *testing.T) {
|
|
||||||
var data = parseData(`
|
|
||||||
---
|
|
||||||
b:
|
|
||||||
c: 2
|
|
||||||
`)
|
|
||||||
assertResult(t, nil, readMap(data, "b.x.f", []string{"c"}))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadMap_recurse_against_string(t *testing.T) {
|
|
||||||
var data = parseData(`
|
|
||||||
---
|
|
||||||
a: cat
|
|
||||||
`)
|
|
||||||
assertResult(t, nil, readMap(data, "a", []string{"b"}))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadMap_with_array(t *testing.T) {
|
|
||||||
var data = parseData(`
|
|
||||||
---
|
|
||||||
b:
|
|
||||||
d:
|
|
||||||
- 3
|
|
||||||
- 4
|
|
||||||
`)
|
|
||||||
assertResult(t, 4, readMap(data, "b", []string{"d", "1"}))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadMap_with_array_out_of_bounds(t *testing.T) {
|
|
||||||
var data = parseData(`
|
|
||||||
---
|
|
||||||
b:
|
|
||||||
d:
|
|
||||||
- 3
|
|
||||||
- 4
|
|
||||||
`)
|
|
||||||
assertResult(t, nil, readMap(data, "b", []string{"d", "3"}))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadMap_with_array_splat(t *testing.T) {
|
|
||||||
var data = parseData(`
|
|
||||||
e:
|
|
||||||
-
|
|
||||||
name: Fred
|
|
||||||
thing: cat
|
|
||||||
-
|
|
||||||
name: Sam
|
|
||||||
thing: dog
|
|
||||||
`)
|
|
||||||
assertResult(t, "[Fred Sam]", fmt.Sprintf("%v", readMap(data, "e", []string{"*", "name"})))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWrite_simple(t *testing.T) {
|
|
||||||
var data = parseData(`
|
|
||||||
b:
|
|
||||||
c: 2
|
|
||||||
`)
|
|
||||||
|
|
||||||
write(data, "b", []string{"c"}, "4")
|
|
||||||
|
|
||||||
b := data["b"].(map[interface{}]interface{})
|
|
||||||
assertResult(t, "4", b["c"].(string))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWrite_with_no_tail(t *testing.T) {
|
|
||||||
var data = parseData(`
|
|
||||||
b:
|
|
||||||
c: 2
|
|
||||||
`)
|
|
||||||
write(data, "b", []string{}, "4")
|
|
||||||
|
|
||||||
b := data["b"]
|
|
||||||
assertResult(t, "4", fmt.Sprintf("%v", b))
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertResult(t *testing.T, expectedValue interface{}, actualValue interface{}) {
|
|
||||||
if expectedValue != actualValue {
|
|
||||||
t.Error("Expected <", expectedValue, "> but got <", actualValue, ">", fmt.Sprintf("%T", actualValue))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertResultWithContext(t *testing.T, expectedValue interface{}, actualValue interface{}, context interface{}) {
|
|
||||||
|
|
||||||
if expectedValue != actualValue {
|
|
||||||
t.Error(context)
|
|
||||||
t.Error(": expected <", expectedValue, "> but got <", actualValue, ">")
|
|
||||||
}
|
|
||||||
}
|
|
76
debian/changelog
vendored
Normal file
76
debian/changelog
vendored
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
yq (3.3.2) focal; urgency=medium
|
||||||
|
|
||||||
|
* Bug fix: existStatus bug (#459)
|
||||||
|
* Automatically makes a os temp directory if it does not exist (#461)
|
||||||
|
|
||||||
|
-- Roberto Mier Escandon <rmescandon@gmail.com> Fri, 07 Aug 2020 18:53:01 +0200
|
||||||
|
|
||||||
|
yq (3.3-0) focal; urgency=medium
|
||||||
|
|
||||||
|
* You can control string styles (quotes) using the new --style flag
|
||||||
|
* String values now always have quotes when outputting to json
|
||||||
|
* Negative array indices now traverse the array backwards
|
||||||
|
* Added a --stripComments flag to print yaml without any comments
|
||||||
|
* Bumped go to version 1.14
|
||||||
|
|
||||||
|
-- Roberto Mier Escandon <rmescandon@gmail.com> Thu, 30 Apr 2020 20:45:44 +0200
|
||||||
|
|
||||||
|
yq (3.1-2) eoan; urgency=medium
|
||||||
|
|
||||||
|
* Bug fix: yq 3 was removing empty inline-style objects and arrays (#355)
|
||||||
|
* Bug fix: Merge option returned different output when switching order of
|
||||||
|
merging files(#347)
|
||||||
|
* Bug fix: Add new object to existing array object was failing in 3.1.1 (#361)
|
||||||
|
* Bug fix: yq 3 empty keys did not allow merging of values (#356)
|
||||||
|
* Bug fix: keys quoted during merge (#363)
|
||||||
|
* Bug fix: Correct length with wc -l (#362)
|
||||||
|
* Bug fix: Write to empty document removed path (#359)
|
||||||
|
|
||||||
|
-- Roberto Mier Escandon <rmescandon@gmail.com> Mon, 24 Feb 2020 20:31:58 +0100
|
||||||
|
|
||||||
|
yq (3.1-1) eoan; urgency=medium
|
||||||
|
|
||||||
|
* Keeps yaml comments and formatting, can specify yaml tags when updating.
|
||||||
|
* Handles anchors
|
||||||
|
* Can print out matching paths and values when splatting
|
||||||
|
* JSON output works for all commands
|
||||||
|
* Yaml files with multiple documents are printed out as one JSON
|
||||||
|
document per line.
|
||||||
|
* Deep splat (**) to match arbitrary paths
|
||||||
|
* Update scripts file format has changed to be more powerful
|
||||||
|
* Reading and splatting, matching results are printed once per line
|
||||||
|
* Bugfixing
|
||||||
|
|
||||||
|
-- Roberto Mier Escandon <rmescandon@gmail.com> Tue, 11 Feb 2020 22:18:24 +0100
|
||||||
|
|
||||||
|
yq (2.2-1) bionic; urgency=medium
|
||||||
|
|
||||||
|
* Added Windows support for the "--inplace" command flag
|
||||||
|
* Prefix now supports arrays
|
||||||
|
* Add prefix command
|
||||||
|
* Bump Alpine version to 3.8
|
||||||
|
* Improved docker build process
|
||||||
|
* Lint fixes
|
||||||
|
* Build support for all linux architectures supported by gox
|
||||||
|
|
||||||
|
-- Roberto Mier Escandon <rmescandon@gmail.com> Sat, 19 Jan 2019 15:50:47 +0100
|
||||||
|
|
||||||
|
yq (2.1-0) bionic; urgency=medium
|
||||||
|
|
||||||
|
* Ability to read multiple documents in a single file
|
||||||
|
* Ability to append list items instead of overwriting
|
||||||
|
|
||||||
|
-- Roberto Mier EscandĂłn <rmescandon@gmail.com> Tue, 10 Jul 2018 14:02:42 +0200
|
||||||
|
|
||||||
|
yq (2.0-0) bionic; urgency=medium
|
||||||
|
|
||||||
|
* Release 2.0.0
|
||||||
|
|
||||||
|
-- Roberto Mier EscandĂłn <rmescandon@gmail.com> Wed, 20 Jun 2018 10:29:53 +0200
|
||||||
|
|
||||||
|
yq (1.15-0) bionic; urgency=medium
|
||||||
|
|
||||||
|
* Release 1.15
|
||||||
|
|
||||||
|
-- Roberto Mier EscandĂłn <rmescandon@gmail.com> Wed, 06 Jun 2018 11:32:03 +0200
|
||||||
|
|
1
debian/compat
vendored
Normal file
1
debian/compat
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
10
|
22
debian/control
vendored
Normal file
22
debian/control
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Source: yq
|
||||||
|
Section: devel
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: Roberto Mier EscandĂłn <rmescandon@gmail.com>
|
||||||
|
Build-Depends: debhelper (>=10),
|
||||||
|
dh-golang (>=1.34),
|
||||||
|
golang-1.13,
|
||||||
|
rsync
|
||||||
|
Standards-Version: 4.1.4
|
||||||
|
Homepage: https://github.com/mikefarah/yq.git
|
||||||
|
Vcs-Browser: https://github.com/mikefarah/yq.git
|
||||||
|
Vcs-Git: https://github.com/mikefarah/yq.git
|
||||||
|
XS-Go-Import-Path: github.com/mikefarah/yq
|
||||||
|
XSBC-Original-Maintainer: Roberto Mier EscandĂłn <rmescandon@gmail.com>
|
||||||
|
|
||||||
|
Package: yq
|
||||||
|
Architecture: any
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||||
|
Description: lightweight and portable command-line YAML processor
|
||||||
|
.
|
||||||
|
The aim of the project is to be the
|
||||||
|
[jq](https://github.com/stedolan/jq) or sed of yaml files.
|
24
debian/copyright
vendored
Normal file
24
debian/copyright
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Upstream-Name: yq
|
||||||
|
Source: https://github.com/mikefarah/yq.git
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2017 Mike Farah
|
||||||
|
License: Expat
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
.
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
2
debian/gbp.conf
vendored
Normal file
2
debian/gbp.conf
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[DEFAULT]
|
||||||
|
pristine-tar = True
|
57
debian/rules
vendored
Executable file
57
debian/rules
vendored
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Roberto Mier EscandĂłn <rmescandon@gmail.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License version 3 as
|
||||||
|
# published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
PROJECT := yq
|
||||||
|
OWNER := mikefarah
|
||||||
|
REPO := github.com
|
||||||
|
GOVERSION := 1.13
|
||||||
|
|
||||||
|
export DH_OPTIONS
|
||||||
|
export DH_GOPKG := ${REPO}/${OWNER}/${PROJECT}
|
||||||
|
export GOROOT := /usr/lib/go-${GOVERSION}
|
||||||
|
export GOPATH := ${CURDIR}/_build
|
||||||
|
export GOBIN := ${GOPATH}/bin
|
||||||
|
export PATH := ${GOROOT}/bin:${GOBIN}:${PATH}
|
||||||
|
export GOCACHE := /tmp/gocache
|
||||||
|
export GOFLAGS := -mod=vendor
|
||||||
|
|
||||||
|
SRCDIR := ${GOPATH}/src/${DH_GOPKG}
|
||||||
|
DESTDIR := ${CURDIR}/debian/${PROJECT}
|
||||||
|
BINDIR := /usr/bin
|
||||||
|
ASSETSDIR := /usr/share/${PROJECT}
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@ --builddirectory=${GOPATH} --buildsystem=golang
|
||||||
|
|
||||||
|
override_dh_auto_build:
|
||||||
|
mkdir -p ${SRCDIR}
|
||||||
|
mkdir -p ${GOBIN}
|
||||||
|
# copy project to local srcdir to build from there
|
||||||
|
rsync -avz --progress --exclude=_build --exclude=debian --exclude=tmp. --exclude=go.mod --exclude=docs . $(SRCDIR)
|
||||||
|
# build go code
|
||||||
|
(cd ${SRCDIR} && go install -buildmode=pie ./...)
|
||||||
|
|
||||||
|
override_dh_auto_test:
|
||||||
|
(cd ${SRCDIR} && go test -v ./...)
|
||||||
|
|
||||||
|
override_dh_auto_install:
|
||||||
|
cp ${GOBIN}/yq ${DESTDIR}/${BINDIR}
|
||||||
|
cp -f ${SRCDIR}/LICENSE ${DESTDIR}/${ASSETSDIR}
|
||||||
|
chmod a+x ${DESTDIR}/${BINDIR}/yq
|
||||||
|
|
||||||
|
override_dh_auto_clean:
|
||||||
|
dh_clean
|
||||||
|
rm -rf ${CURDIR}/_build
|
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
3.0 (native)
|
3
debian/yq.dirs
vendored
Normal file
3
debian/yq.dirs
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
usr/bin
|
||||||
|
usr/share/yq
|
||||||
|
usr/share/man/man1
|
11
examples/array.yaml
Normal file
11
examples/array.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
- become: true
|
||||||
|
gather_facts: false
|
||||||
|
hosts: lalaland
|
||||||
|
name: "Apply smth"
|
||||||
|
roles:
|
||||||
|
- lala
|
||||||
|
- land
|
||||||
|
serial: 1
|
||||||
|
- become: false
|
||||||
|
gather_facts: true
|
8
examples/bad.yaml
Normal file
8
examples/bad.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
b:
|
||||||
|
d: be gone
|
||||||
|
c: 2
|
||||||
|
e:
|
||||||
|
- name: Billy Bob # comment over here
|
||||||
|
|
||||||
|
---
|
||||||
|
[123123
|
4
examples/data1-no-comments.yaml
Normal file
4
examples/data1-no-comments.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
a: simple
|
||||||
|
b: [1, 2]
|
||||||
|
c:
|
||||||
|
test: 1
|
6
examples/data1.yaml
Normal file
6
examples/data1.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
a:
|
||||||
|
key1: "value1"
|
||||||
|
key2: 2.6
|
||||||
|
ab:
|
||||||
|
key1: 6
|
||||||
|
key2: "h"
|
7
examples/data2.yaml
Normal file
7
examples/data2.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
a: other # better than the original
|
||||||
|
b: [3, 4]
|
||||||
|
c:
|
||||||
|
toast: leave
|
||||||
|
test: 1
|
||||||
|
tell: 1
|
||||||
|
tasty.taco: cool
|
4
examples/data3.yaml
Normal file
4
examples/data3.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
a: "simple" # just the best
|
||||||
|
b: [1, 3]
|
||||||
|
c:
|
||||||
|
test: 1
|
2
examples/empty.yaml
Normal file
2
examples/empty.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# a: apple
|
||||||
|
# b: cat
|
7
examples/instruction_sample.yaml
Normal file
7
examples/instruction_sample.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
- command: update
|
||||||
|
path: b.c
|
||||||
|
value:
|
||||||
|
#great
|
||||||
|
things: frog # wow!
|
||||||
|
- command: delete
|
||||||
|
path: b.d
|
19
examples/merge-anchor.yaml
Normal file
19
examples/merge-anchor.yaml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
foo: &foo
|
||||||
|
a: foo_a
|
||||||
|
thing: foo_thing
|
||||||
|
c: foo_c
|
||||||
|
|
||||||
|
bar: &bar
|
||||||
|
b: bar_b
|
||||||
|
thing: bar_thing
|
||||||
|
c: bar_c
|
||||||
|
|
||||||
|
foobarList:
|
||||||
|
b: foobarList_b
|
||||||
|
<<: [*foo,*bar]
|
||||||
|
c: foobarList_c
|
||||||
|
|
||||||
|
foobar:
|
||||||
|
c: foobar_c
|
||||||
|
<<: *foo
|
||||||
|
thing: foobar_thing
|
5
examples/multiline-text.yaml
Normal file
5
examples/multiline-text.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
test: |
|
||||||
|
abcdefg
|
||||||
|
hijklmno
|
||||||
|
|
||||||
|
|
18
examples/multiple_docs.yaml
Normal file
18
examples/multiple_docs.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
commonKey: first document
|
||||||
|
a: Easy! as one two three
|
||||||
|
b:
|
||||||
|
c: 2
|
||||||
|
d: [3, 4]
|
||||||
|
e:
|
||||||
|
- name: fred
|
||||||
|
value: 3
|
||||||
|
- name: sam
|
||||||
|
value: 4
|
||||||
|
---
|
||||||
|
commonKey: second document
|
||||||
|
another:
|
||||||
|
document: here
|
||||||
|
---
|
||||||
|
commonKey: third document
|
||||||
|
wow:
|
||||||
|
- here is another
|
7
examples/multiple_docs_small.yaml
Normal file
7
examples/multiple_docs_small.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
a: Easy! as one two three
|
||||||
|
---
|
||||||
|
another:
|
||||||
|
document: here
|
||||||
|
---
|
||||||
|
- 1
|
||||||
|
- 2
|
2
examples/numbered_keys.yml
Normal file
2
examples/numbered_keys.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
5:
|
||||||
|
6: camel!
|
2
examples/order.yaml
Normal file
2
examples/order.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
version: 3
|
||||||
|
application: MyApp
|
6
examples/order.yml
Normal file
6
examples/order.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
test:
|
||||||
|
image: ubuntu:14.04
|
||||||
|
stdin_open: true
|
||||||
|
tty: true
|
1
examples/sample.json
Normal file
1
examples/sample.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"a":"Easy! as one two three","b":{"c":2,"d":[3,4],"e":[{"name":"fred","value":3},{"name":"sam","value":4}]},"ab":"must appear last"}
|
@ -1,9 +1,11 @@
|
|||||||
a: Easy! as one two three
|
# Some doc
|
||||||
|
|
||||||
|
a: true
|
||||||
b:
|
b:
|
||||||
c: 2
|
c: 2
|
||||||
d: [3, 4]
|
d: [3, 4, 5]
|
||||||
e:
|
e:
|
||||||
- name: fred
|
- name: fred
|
||||||
value: 3
|
value: 3
|
||||||
- name: sam
|
- name: sam
|
||||||
value: 4
|
value: 4
|
1
examples/sample_array.yaml
Normal file
1
examples/sample_array.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
[1,2,3]
|
2
examples/sample_array_2.yaml
Normal file
2
examples/sample_array_2.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
- 4
|
||||||
|
- 5
|
1
examples/sample_text.yaml
Normal file
1
examples/sample_text.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
hi
|
5
examples/simple-anchor-exploded.yaml
Normal file
5
examples/simple-anchor-exploded.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
foo:
|
||||||
|
a: 1
|
||||||
|
|
||||||
|
foobar:
|
||||||
|
a: 1
|
5
examples/simple-anchor.yaml
Normal file
5
examples/simple-anchor.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
foo: &foo
|
||||||
|
a: 1
|
||||||
|
|
||||||
|
foobar:
|
||||||
|
<<: *foo
|
5
github-action/Dockerfile
Normal file
5
github-action/Dockerfile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
FROM mikefarah/yq:4.9.3
|
||||||
|
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
4
github-action/entrypoint.sh
Executable file
4
github-action/entrypoint.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh -l
|
||||||
|
|
||||||
|
echo "$1"
|
||||||
|
eval $1
|
16
go.mod
Normal file
16
go.mod
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
module github.com/mikefarah/yq/v4
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/elliotchance/orderedmap v1.4.0
|
||||||
|
github.com/fatih/color v1.10.0
|
||||||
|
github.com/goccy/go-yaml v1.8.9
|
||||||
|
github.com/jinzhu/copier v0.2.8
|
||||||
|
github.com/spf13/cobra v1.1.3
|
||||||
|
github.com/timtadh/data-structures v0.5.3 // indirect
|
||||||
|
github.com/timtadh/lexmachine v0.2.2
|
||||||
|
golang.org/x/sys v0.0.0-20210317225723-c4fcb01b228e // indirect
|
||||||
|
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||||
|
)
|
||||||
|
|
||||||
|
go 1.15
|
328
go.sum
Normal file
328
go.sum
Normal file
@ -0,0 +1,328 @@
|
|||||||
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||||
|
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||||
|
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||||
|
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||||
|
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||||
|
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||||
|
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||||
|
cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
|
||||||
|
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||||
|
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||||
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
|
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||||
|
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||||
|
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||||
|
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||||
|
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||||
|
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||||
|
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
|
||||||
|
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||||
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
|
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||||
|
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
|
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
|
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||||
|
github.com/elliotchance/orderedmap v1.4.0 h1:wZtfeEONCbx6in1CZyE6bELEt/vFayMvsxqI5SgsR+A=
|
||||||
|
github.com/elliotchance/orderedmap v1.4.0/go.mod h1:wsDwEaX5jEoyhbs7x93zk2H/qv0zwuhg4inXhDkYqys=
|
||||||
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
|
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
|
||||||
|
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
|
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||||
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
|
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||||
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
|
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
|
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||||
|
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||||
|
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||||
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
|
github.com/goccy/go-yaml v1.8.9 h1:4AEXg2qx+/w29jXnXpMY6mTckmYu1TMoHteKuMf0HFg=
|
||||||
|
github.com/goccy/go-yaml v1.8.9/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
|
||||||
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
|
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
|
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
|
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
|
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||||
|
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||||
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
|
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||||
|
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||||
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||||
|
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
|
||||||
|
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||||
|
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||||
|
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||||
|
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||||
|
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||||
|
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||||
|
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||||
|
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||||
|
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
||||||
|
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
|
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
|
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||||
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
|
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
|
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||||
|
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||||
|
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||||
|
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||||
|
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||||
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
|
github.com/jinzhu/copier v0.2.8 h1:N8MbL5niMwE3P4dOwurJixz5rMkKfujmMRFmAanSzWE=
|
||||||
|
github.com/jinzhu/copier v0.2.8/go.mod h1:24xnZezI2Yqac9J61UC6/dG/k76ttpq0DdJI3QmUvro=
|
||||||
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
|
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||||
|
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||||
|
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||||
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||||
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||||
|
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
|
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
||||||
|
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||||
|
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
|
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||||
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
|
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||||
|
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||||
|
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
|
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||||
|
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||||
|
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||||
|
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
|
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||||
|
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||||
|
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||||
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||||
|
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||||
|
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||||
|
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||||
|
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||||
|
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||||
|
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||||
|
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
|
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||||
|
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||||
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||||
|
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
|
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||||
|
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||||
|
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||||
|
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
|
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||||
|
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
|
github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M=
|
||||||
|
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
|
||||||
|
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||||
|
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
|
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
|
github.com/timtadh/data-structures v0.5.3 h1:F2tEjoG9qWIyUjbvXVgJqEOGJPMIiYn7U5W5mE+i/vQ=
|
||||||
|
github.com/timtadh/data-structures v0.5.3/go.mod h1:9R4XODhJ8JdWFEI8P/HJKqxuJctfBQw6fDibMQny2oU=
|
||||||
|
github.com/timtadh/lexmachine v0.2.2 h1:g55RnjdYazm5wnKv59pwFcBJHOyvTPfDEoz21s4PHmY=
|
||||||
|
github.com/timtadh/lexmachine v0.2.2/go.mod h1:GBJvD5OAfRn/gnp92zb9KTgHLB7akKyxmVivoYCcjQI=
|
||||||
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||||
|
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||||
|
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||||
|
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||||
|
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||||
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
|
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
|
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||||
|
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||||
|
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||||
|
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
|
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||||
|
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||||
|
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||||
|
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||||
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210317225723-c4fcb01b228e h1:XNp2Flc/1eWQGk5BLzqTAN7fQIwIbfyVTuVxXxZh73M=
|
||||||
|
golang.org/x/sys v0.0.0-20210317225723-c4fcb01b228e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||||
|
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||||
|
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||||
|
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||||
|
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||||
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||||
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||||
|
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||||
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
|
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||||
|
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||||
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
|
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
|
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 h1:6D+BvnJ/j6e222UW8s2qTSe3wGBtvo0MbVQG/c5k8RE=
|
||||||
|
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473/go.mod h1:N1eN2tsCx0Ydtgjl4cqmbRCsY4/+z4cYDeqwZTk6zog=
|
||||||
|
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||||
|
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||||
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
|
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
7
mkdocs.yml
Normal file
7
mkdocs.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
docs_dir: mkdocs
|
||||||
|
site_dir: docs
|
||||||
|
site_name: Yq
|
||||||
|
theme: 'material'
|
||||||
|
repo_name: 'mikefarah/yq'
|
||||||
|
repo_url: 'https://github.com/mikefarah/yq'
|
||||||
|
|
@ -1,55 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
func parsePath(path string) []string {
|
|
||||||
return parsePathAccum([]string{}, path)
|
|
||||||
}
|
|
||||||
|
|
||||||
func parsePathAccum(paths []string, remaining string) []string {
|
|
||||||
head, tail := nextYamlPath(remaining)
|
|
||||||
if tail == "" {
|
|
||||||
return append(paths, head)
|
|
||||||
}
|
|
||||||
return parsePathAccum(append(paths, head), tail)
|
|
||||||
}
|
|
||||||
|
|
||||||
func nextYamlPath(path string) (pathElement string, remaining string) {
|
|
||||||
switch path[0] {
|
|
||||||
case '[':
|
|
||||||
// e.g [0].blah.cat -> we need to return "0" and "blah.cat"
|
|
||||||
return search(path[1:len(path)], []uint8{']'}, true)
|
|
||||||
case '"':
|
|
||||||
// e.g "a.b".blah.cat -> we need to return "a.b" and "blah.cat"
|
|
||||||
return search(path[1:len(path)], []uint8{'"'}, true)
|
|
||||||
default:
|
|
||||||
// e.g "a.blah.cat" -> return "a" and "blah.cat"
|
|
||||||
return search(path[0:len(path)], []uint8{'.', '['}, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func search(path string, matchingChars []uint8, skipNext bool) (pathElement string, remaining string) {
|
|
||||||
for i := 0; i < len(path); i++ {
|
|
||||||
var char = path[i]
|
|
||||||
if contains(matchingChars, char) {
|
|
||||||
var remainingStart = i + 1
|
|
||||||
if skipNext {
|
|
||||||
remainingStart = remainingStart + 1
|
|
||||||
} else if !skipNext && char != '.' {
|
|
||||||
remainingStart = i
|
|
||||||
}
|
|
||||||
if remainingStart > len(path) {
|
|
||||||
remainingStart = len(path)
|
|
||||||
}
|
|
||||||
return path[0:i], path[remainingStart:len(path)]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return path, ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func contains(matchingChars []uint8, candidate uint8) bool {
|
|
||||||
for _, a := range matchingChars {
|
|
||||||
if a == candidate {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
var parsePathsTests = []struct {
|
|
||||||
path string
|
|
||||||
expectedPaths []string
|
|
||||||
}{
|
|
||||||
{"a.b", []string{"a", "b"}},
|
|
||||||
{"a.b[0]", []string{"a", "b", "0"}},
|
|
||||||
}
|
|
||||||
|
|
||||||
func testParsePath(t *testing.T) {
|
|
||||||
for _, tt := range parsePathsTests {
|
|
||||||
assertResultWithContext(t, tt.expectedPaths, parsePath(tt.path), tt)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var nextYamlPathTests = []struct {
|
|
||||||
path string
|
|
||||||
expectedElement string
|
|
||||||
expectedRemaining string
|
|
||||||
}{
|
|
||||||
{"a.b", "a", "b"},
|
|
||||||
{"a", "a", ""},
|
|
||||||
{"a.b.c", "a", "b.c"},
|
|
||||||
{"\"a.b\".c", "a.b", "c"},
|
|
||||||
{"a.\"b.c\".d", "a", "\"b.c\".d"},
|
|
||||||
{"[1].a.d", "1", "a.d"},
|
|
||||||
{"a[0].c", "a", "[0].c"},
|
|
||||||
{"[0]", "0", ""},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNextYamlPath(t *testing.T) {
|
|
||||||
for _, tt := range nextYamlPathTests {
|
|
||||||
var element, remaining = nextYamlPath(tt.path)
|
|
||||||
assertResultWithContext(t, tt.expectedElement, element, tt)
|
|
||||||
assertResultWithContext(t, tt.expectedRemaining, remaining, tt)
|
|
||||||
}
|
|
||||||
}
|
|
70
pkg/yqlib/all_at_once_evaluator.go
Normal file
70
pkg/yqlib/all_at_once_evaluator.go
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"container/list"
|
||||||
|
|
||||||
|
yaml "gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// A yaml expression evaluator that runs the expression once against all files/nodes in memory.
|
||||||
|
type Evaluator interface {
|
||||||
|
EvaluateFiles(expression string, filenames []string, printer Printer) error
|
||||||
|
|
||||||
|
// EvaluateNodes takes an expression and one or more yaml nodes, returning a list of matching candidate nodes
|
||||||
|
EvaluateNodes(expression string, nodes ...*yaml.Node) (*list.List, error)
|
||||||
|
|
||||||
|
// EvaluateCandidateNodes takes an expression and list of candidate nodes, returning a list of matching candidate nodes
|
||||||
|
EvaluateCandidateNodes(expression string, inputCandidateNodes *list.List) (*list.List, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type allAtOnceEvaluator struct {
|
||||||
|
treeNavigator DataTreeNavigator
|
||||||
|
treeCreator ExpressionParser
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAllAtOnceEvaluator() Evaluator {
|
||||||
|
return &allAtOnceEvaluator{treeNavigator: NewDataTreeNavigator(), treeCreator: NewExpressionParser()}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *allAtOnceEvaluator) EvaluateNodes(expression string, nodes ...*yaml.Node) (*list.List, error) {
|
||||||
|
inputCandidates := list.New()
|
||||||
|
for _, node := range nodes {
|
||||||
|
inputCandidates.PushBack(&CandidateNode{Node: node})
|
||||||
|
}
|
||||||
|
return e.EvaluateCandidateNodes(expression, inputCandidates)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *allAtOnceEvaluator) EvaluateCandidateNodes(expression string, inputCandidates *list.List) (*list.List, error) {
|
||||||
|
node, err := e.treeCreator.ParseExpression(expression)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
context, err := e.treeNavigator.GetMatchingNodes(Context{MatchingNodes: inputCandidates}, node)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return context.MatchingNodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *allAtOnceEvaluator) EvaluateFiles(expression string, filenames []string, printer Printer) error {
|
||||||
|
fileIndex := 0
|
||||||
|
|
||||||
|
var allDocuments *list.List = list.New()
|
||||||
|
for _, filename := range filenames {
|
||||||
|
reader, err := readStream(filename)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fileDocuments, err := readDocuments(reader, filename, fileIndex)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
allDocuments.PushBackList(fileDocuments)
|
||||||
|
fileIndex = fileIndex + 1
|
||||||
|
}
|
||||||
|
matches, err := e.EvaluateCandidateNodes(expression, allDocuments)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return printer.PrintResults(matches)
|
||||||
|
}
|
40
pkg/yqlib/all_at_once_evaluator_test.go
Normal file
40
pkg/yqlib/all_at_once_evaluator_test.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/mikefarah/yq/v4/test"
|
||||||
|
)
|
||||||
|
|
||||||
|
var evaluateNodesScenario = []expressionScenario{
|
||||||
|
{
|
||||||
|
document: `a: hello`,
|
||||||
|
expression: `.a`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[a], (!!str)::hello\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
document: `a: hello`,
|
||||||
|
expression: `.`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[], (doc)::a: hello\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
document: `- a: "yes"`,
|
||||||
|
expression: `.[] | has("a")`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[0], (!!bool)::true\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAllAtOnceEvaluateNodes(t *testing.T) {
|
||||||
|
var evaluator = NewAllAtOnceEvaluator()
|
||||||
|
for _, tt := range evaluateNodesScenario {
|
||||||
|
node := test.ParseData(tt.document)
|
||||||
|
list, _ := evaluator.EvaluateNodes(tt.expression, &node)
|
||||||
|
test.AssertResultComplex(t, tt.expected, resultsToString(list))
|
||||||
|
}
|
||||||
|
}
|
101
pkg/yqlib/candidate_node.go
Normal file
101
pkg/yqlib/candidate_node.go
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
|
yaml "gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CandidateNode struct {
|
||||||
|
Node *yaml.Node // the actual node
|
||||||
|
Parent *CandidateNode // parent node
|
||||||
|
Path []interface{} /// the path we took to get to this node
|
||||||
|
Document uint // the document index of this node
|
||||||
|
Filename string
|
||||||
|
FileIndex int
|
||||||
|
// when performing op against all nodes given, this will treat all the nodes as one
|
||||||
|
// (e.g. top level cross document merge). This property does not propegate to child nodes.
|
||||||
|
EvaluateTogether bool
|
||||||
|
IsMapKey bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *CandidateNode) GetKey() string {
|
||||||
|
keyPrefix := ""
|
||||||
|
if n.IsMapKey {
|
||||||
|
keyPrefix = "key-"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%v%v - %v", keyPrefix, n.Document, n.Path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *CandidateNode) CreateChild(path interface{}, node *yaml.Node) *CandidateNode {
|
||||||
|
return &CandidateNode{
|
||||||
|
Node: node,
|
||||||
|
Path: n.createChildPath(path),
|
||||||
|
Parent: n,
|
||||||
|
Document: n.Document,
|
||||||
|
Filename: n.Filename,
|
||||||
|
FileIndex: n.FileIndex,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *CandidateNode) createChildPath(path interface{}) []interface{} {
|
||||||
|
if path == nil {
|
||||||
|
newPath := make([]interface{}, len(n.Path))
|
||||||
|
copy(newPath, n.Path)
|
||||||
|
return newPath
|
||||||
|
}
|
||||||
|
|
||||||
|
//don't use append as they may actually modify the path of the orignal node!
|
||||||
|
newPath := make([]interface{}, len(n.Path)+1)
|
||||||
|
copy(newPath, n.Path)
|
||||||
|
newPath[len(n.Path)] = path
|
||||||
|
return newPath
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *CandidateNode) Copy() (*CandidateNode, error) {
|
||||||
|
clone := &CandidateNode{}
|
||||||
|
err := copier.Copy(clone, n)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return clone, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// updates this candidate from the given candidate node
|
||||||
|
func (n *CandidateNode) UpdateFrom(other *CandidateNode) {
|
||||||
|
|
||||||
|
n.UpdateAttributesFrom(other)
|
||||||
|
n.Node.Content = other.Node.Content
|
||||||
|
n.Node.Value = other.Node.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode) {
|
||||||
|
log.Debug("UpdateAttributesFrom: n: %v other: %v", n.GetKey(), other.GetKey())
|
||||||
|
if n.Node.Kind != other.Node.Kind {
|
||||||
|
// clear out the contents when switching to a different type
|
||||||
|
// e.g. map to array
|
||||||
|
n.Node.Content = make([]*yaml.Node, 0)
|
||||||
|
n.Node.Value = ""
|
||||||
|
}
|
||||||
|
n.Node.Kind = other.Node.Kind
|
||||||
|
n.Node.Tag = other.Node.Tag
|
||||||
|
n.Node.Alias = other.Node.Alias
|
||||||
|
n.Node.Anchor = other.Node.Anchor
|
||||||
|
|
||||||
|
// merge will pickup the style of the new thing
|
||||||
|
// when autocreating nodes
|
||||||
|
if n.Node.Style == 0 {
|
||||||
|
n.Node.Style = other.Node.Style
|
||||||
|
}
|
||||||
|
|
||||||
|
if other.Node.FootComment != "" {
|
||||||
|
n.Node.FootComment = other.Node.FootComment
|
||||||
|
}
|
||||||
|
if other.Node.HeadComment != "" {
|
||||||
|
n.Node.HeadComment = other.Node.HeadComment
|
||||||
|
}
|
||||||
|
if other.Node.LineComment != "" {
|
||||||
|
n.Node.LineComment = other.Node.LineComment
|
||||||
|
}
|
||||||
|
}
|
61
pkg/yqlib/color_print.go
Normal file
61
pkg/yqlib/color_print.go
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
|
"github.com/goccy/go-yaml/lexer"
|
||||||
|
"github.com/goccy/go-yaml/printer"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Thanks @risentveber!
|
||||||
|
|
||||||
|
const escape = "\x1b"
|
||||||
|
|
||||||
|
func format(attr color.Attribute) string {
|
||||||
|
return fmt.Sprintf("%s[%dm", escape, attr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func colorizeAndPrint(yamlBytes []byte, writer io.Writer) error {
|
||||||
|
tokens := lexer.Tokenize(string(yamlBytes))
|
||||||
|
var p printer.Printer
|
||||||
|
p.Bool = func() *printer.Property {
|
||||||
|
return &printer.Property{
|
||||||
|
Prefix: format(color.FgHiMagenta),
|
||||||
|
Suffix: format(color.Reset),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.Number = func() *printer.Property {
|
||||||
|
return &printer.Property{
|
||||||
|
Prefix: format(color.FgHiMagenta),
|
||||||
|
Suffix: format(color.Reset),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.MapKey = func() *printer.Property {
|
||||||
|
return &printer.Property{
|
||||||
|
Prefix: format(color.FgCyan),
|
||||||
|
Suffix: format(color.Reset),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.Anchor = func() *printer.Property {
|
||||||
|
return &printer.Property{
|
||||||
|
Prefix: format(color.FgHiYellow),
|
||||||
|
Suffix: format(color.Reset),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.Alias = func() *printer.Property {
|
||||||
|
return &printer.Property{
|
||||||
|
Prefix: format(color.FgHiYellow),
|
||||||
|
Suffix: format(color.Reset),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.String = func() *printer.Property {
|
||||||
|
return &printer.Property{
|
||||||
|
Prefix: format(color.FgGreen),
|
||||||
|
Suffix: format(color.Reset),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := writer.Write([]byte(p.PrintTokens(tokens) + "\n"))
|
||||||
|
return err
|
||||||
|
}
|
68
pkg/yqlib/context.go
Normal file
68
pkg/yqlib/context.go
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"container/list"
|
||||||
|
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Context struct {
|
||||||
|
MatchingNodes *list.List
|
||||||
|
Variables map[string]*list.List
|
||||||
|
DontAutoCreate bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) SingleReadonlyChildContext(candidate *CandidateNode) Context {
|
||||||
|
list := list.New()
|
||||||
|
list.PushBack(candidate)
|
||||||
|
newContext := n.ChildContext(list)
|
||||||
|
newContext.DontAutoCreate = true
|
||||||
|
return newContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) SingleChildContext(candidate *CandidateNode) Context {
|
||||||
|
list := list.New()
|
||||||
|
list.PushBack(candidate)
|
||||||
|
return n.ChildContext(list)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) GetVariable(name string) *list.List {
|
||||||
|
if n.Variables == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return n.Variables[name]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) SetVariable(name string, value *list.List) {
|
||||||
|
if n.Variables == nil {
|
||||||
|
n.Variables = make(map[string]*list.List)
|
||||||
|
}
|
||||||
|
n.Variables[name] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) ChildContext(results *list.List) Context {
|
||||||
|
clone := Context{}
|
||||||
|
err := copier.Copy(&clone, n)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Error cloning context :(")
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
clone.MatchingNodes = results
|
||||||
|
return clone
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) Clone() Context {
|
||||||
|
clone := Context{}
|
||||||
|
err := copier.Copy(&clone, n)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Error cloning context :(")
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return clone
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) ReadOnlyClone() Context {
|
||||||
|
clone := n.Clone()
|
||||||
|
clone.DontAutoCreate = true
|
||||||
|
return clone
|
||||||
|
}
|
41
pkg/yqlib/data_tree_navigator.go
Normal file
41
pkg/yqlib/data_tree_navigator.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
logging "gopkg.in/op/go-logging.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DataTreeNavigator interface {
|
||||||
|
// given the context and a expressionNode,
|
||||||
|
// this will process the against the given expressionNode and return
|
||||||
|
// a new context of matching candidates
|
||||||
|
GetMatchingNodes(context Context, expressionNode *ExpressionNode) (Context, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type dataTreeNavigator struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDataTreeNavigator() DataTreeNavigator {
|
||||||
|
return &dataTreeNavigator{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *dataTreeNavigator) GetMatchingNodes(context Context, expressionNode *ExpressionNode) (Context, error) {
|
||||||
|
if expressionNode == nil {
|
||||||
|
log.Debugf("getMatchingNodes - nothing to do")
|
||||||
|
return context, nil
|
||||||
|
}
|
||||||
|
log.Debugf("Processing Op: %v", expressionNode.Operation.toString())
|
||||||
|
if log.IsEnabledFor(logging.DEBUG) {
|
||||||
|
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
|
||||||
|
log.Debug(NodeToString(el.Value.(*CandidateNode)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Debug(">>")
|
||||||
|
handler := expressionNode.Operation.OperationType.Handler
|
||||||
|
if handler != nil {
|
||||||
|
return handler(d, context, expressionNode)
|
||||||
|
}
|
||||||
|
return Context{}, fmt.Errorf("Unknown operator %v", expressionNode.Operation.OperationType)
|
||||||
|
|
||||||
|
}
|
1
pkg/yqlib/doc/.gitignore
vendored
Normal file
1
pkg/yqlib/doc/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.zip
|
239
pkg/yqlib/doc/Add.md
Normal file
239
pkg/yqlib/doc/Add.md
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
Add behaves differently according to the type of the LHS:
|
||||||
|
- arrays: concatenate
|
||||||
|
- number scalars: arithmetic addition
|
||||||
|
- string scalars: concatenate
|
||||||
|
|
||||||
|
Use `+=` as append assign for things like increment. Note that `.a += .x` is equivalent to running `.a = .a + .x`.
|
||||||
|
|
||||||
|
## Concatenate and assign arrays
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
val: thing
|
||||||
|
b:
|
||||||
|
- cat
|
||||||
|
- dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.b += ["cow"]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
val: thing
|
||||||
|
b:
|
||||||
|
- cat
|
||||||
|
- dog
|
||||||
|
- cow
|
||||||
|
```
|
||||||
|
|
||||||
|
## Concatenate arrays
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
b:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a + .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
```
|
||||||
|
|
||||||
|
## Concatenate null to array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a + null' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add new object to array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- dog: woof
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a + {"cat": "meow"}' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- dog: woof
|
||||||
|
- cat: meow
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add string to array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a + "hello"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- hello
|
||||||
|
```
|
||||||
|
|
||||||
|
## Append to array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
b:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a = .a + .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
b:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
```
|
||||||
|
|
||||||
|
## Relative append
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
a1:
|
||||||
|
b:
|
||||||
|
- cat
|
||||||
|
a2:
|
||||||
|
b:
|
||||||
|
- dog
|
||||||
|
a3: {}
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a[].b += ["mouse"]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
a1:
|
||||||
|
b:
|
||||||
|
- cat
|
||||||
|
- mouse
|
||||||
|
a2:
|
||||||
|
b:
|
||||||
|
- dog
|
||||||
|
- mouse
|
||||||
|
a3: {b: [mouse]}
|
||||||
|
```
|
||||||
|
|
||||||
|
## String concatenation
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: meow
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a = .a + .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: catmeow
|
||||||
|
b: meow
|
||||||
|
```
|
||||||
|
|
||||||
|
## Number addition - float
|
||||||
|
If the lhs or rhs are floats then the expression will be calculated with floats.
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: 3
|
||||||
|
b: 4.9
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a = .a + .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: 7.9
|
||||||
|
b: 4.9
|
||||||
|
```
|
||||||
|
|
||||||
|
## Number addition - int
|
||||||
|
If both the lhs and rhs are ints then the expression will be calculated with ints.
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: 3
|
||||||
|
b: 4
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a = .a + .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: 7
|
||||||
|
b: 4
|
||||||
|
```
|
||||||
|
|
||||||
|
## Increment numbers
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: 3
|
||||||
|
b: 5
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] += 1' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: 4
|
||||||
|
b: 6
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add to null
|
||||||
|
Adding to null simply returns the rhs
|
||||||
|
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input 'null + "cat"'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
cat
|
||||||
|
```
|
||||||
|
|
73
pkg/yqlib/doc/Alternative (Default value).md
Normal file
73
pkg/yqlib/doc/Alternative (Default value).md
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
This operator is used to provide alternative (or default) values when a particular expression is either null or false.
|
||||||
|
|
||||||
|
## LHS is defined
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: bridge
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a // "hello"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
bridge
|
||||||
|
```
|
||||||
|
|
||||||
|
## LHS is not defined
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a // "hello"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
hello
|
||||||
|
```
|
||||||
|
|
||||||
|
## LHS is null
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: ~
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a // "hello"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
hello
|
||||||
|
```
|
||||||
|
|
||||||
|
## LHS is false
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: false
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a // "hello"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
hello
|
||||||
|
```
|
||||||
|
|
||||||
|
## RHS is an expression
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: false
|
||||||
|
b: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a // .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
cat
|
||||||
|
```
|
||||||
|
|
301
pkg/yqlib/doc/Anchor and Alias Operators.md
Normal file
301
pkg/yqlib/doc/Anchor and Alias Operators.md
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
Use the `alias` and `anchor` operators to read and write yaml aliases and anchors. The `explode` operator normalises a yaml file (dereference (or expands) aliases and remove anchor names).
|
||||||
|
|
||||||
|
`yq` supports merge aliases (like `<<: *blah`) however this is no longer in the standard yaml spec (1.2) and so `yq` will automatically add the `!!merge` tag to these nodes as it is effectively a custom tag.
|
||||||
|
|
||||||
|
|
||||||
|
## Merge one map
|
||||||
|
see https://yaml.org/type/merge.html
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- &CENTER
|
||||||
|
x: 1
|
||||||
|
y: 2
|
||||||
|
- &LEFT
|
||||||
|
x: 0
|
||||||
|
y: 2
|
||||||
|
- &BIG
|
||||||
|
r: 10
|
||||||
|
- &SMALL
|
||||||
|
r: 1
|
||||||
|
- !!merge <<: *CENTER
|
||||||
|
r: 10
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[4] | explode(.)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
x: 1
|
||||||
|
y: 2
|
||||||
|
r: 10
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge multiple maps
|
||||||
|
see https://yaml.org/type/merge.html
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- &CENTER
|
||||||
|
x: 1
|
||||||
|
y: 2
|
||||||
|
- &LEFT
|
||||||
|
x: 0
|
||||||
|
y: 2
|
||||||
|
- &BIG
|
||||||
|
r: 10
|
||||||
|
- &SMALL
|
||||||
|
r: 1
|
||||||
|
- !!merge <<:
|
||||||
|
- *CENTER
|
||||||
|
- *BIG
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[4] | explode(.)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
r: 10
|
||||||
|
x: 1
|
||||||
|
y: 2
|
||||||
|
```
|
||||||
|
|
||||||
|
## Override
|
||||||
|
see https://yaml.org/type/merge.html
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- &CENTER
|
||||||
|
x: 1
|
||||||
|
y: 2
|
||||||
|
- &LEFT
|
||||||
|
x: 0
|
||||||
|
y: 2
|
||||||
|
- &BIG
|
||||||
|
r: 10
|
||||||
|
- &SMALL
|
||||||
|
r: 1
|
||||||
|
- !!merge <<:
|
||||||
|
- *BIG
|
||||||
|
- *LEFT
|
||||||
|
- *SMALL
|
||||||
|
x: 1
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[4] | explode(.)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
r: 10
|
||||||
|
x: 1
|
||||||
|
y: 2
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get anchor
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: &billyBob cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a | anchor' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
billyBob
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set anchor
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a anchor = "foobar"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: &foobar cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set anchor relatively using assign-update
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a anchor |= .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: &cat
|
||||||
|
b: cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get alias
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
b: &billyBob meow
|
||||||
|
a: *billyBob
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a | alias' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
billyBob
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set alias
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
b: &meow purr
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a alias = "meow"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
b: &meow purr
|
||||||
|
a: *meow
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set alias to blank does nothing
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
b: &meow purr
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a alias = ""' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
b: &meow purr
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set alias relatively using assign-update
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
b: &meow purr
|
||||||
|
a:
|
||||||
|
f: meow
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a alias |= .f' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
b: &meow purr
|
||||||
|
a: *meow
|
||||||
|
```
|
||||||
|
|
||||||
|
## Explode alias and anchor
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
f:
|
||||||
|
a: &a cat
|
||||||
|
b: *a
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'explode(.f)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
f:
|
||||||
|
a: cat
|
||||||
|
b: cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Explode with no aliases or anchors
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: mike
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'explode(.a)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: mike
|
||||||
|
```
|
||||||
|
|
||||||
|
## Explode with alias keys
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
f:
|
||||||
|
a: &a cat
|
||||||
|
*a: b
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'explode(.f)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
f:
|
||||||
|
a: cat
|
||||||
|
cat: b
|
||||||
|
```
|
||||||
|
|
||||||
|
## Explode with merge anchors
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
foo: &foo
|
||||||
|
a: foo_a
|
||||||
|
thing: foo_thing
|
||||||
|
c: foo_c
|
||||||
|
bar: &bar
|
||||||
|
b: bar_b
|
||||||
|
thing: bar_thing
|
||||||
|
c: bar_c
|
||||||
|
foobarList:
|
||||||
|
b: foobarList_b
|
||||||
|
!!merge <<:
|
||||||
|
- *foo
|
||||||
|
- *bar
|
||||||
|
c: foobarList_c
|
||||||
|
foobar:
|
||||||
|
c: foobar_c
|
||||||
|
!!merge <<: *foo
|
||||||
|
thing: foobar_thing
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'explode(.)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
foo:
|
||||||
|
a: foo_a
|
||||||
|
thing: foo_thing
|
||||||
|
c: foo_c
|
||||||
|
bar:
|
||||||
|
b: bar_b
|
||||||
|
thing: bar_thing
|
||||||
|
c: bar_c
|
||||||
|
foobarList:
|
||||||
|
b: bar_b
|
||||||
|
thing: foo_thing
|
||||||
|
c: foobarList_c
|
||||||
|
a: foo_a
|
||||||
|
foobar:
|
||||||
|
c: foo_c
|
||||||
|
a: foo_a
|
||||||
|
thing: foobar_thing
|
||||||
|
```
|
||||||
|
|
184
pkg/yqlib/doc/Assign (Update).md
Normal file
184
pkg/yqlib/doc/Assign (Update).md
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
|
||||||
|
## Create yaml file
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input '.a.b = "cat" | .x = "frog"'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: cat
|
||||||
|
x: frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update node to be the child value
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
g: foof
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a |= .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
g: foof
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update node from another file
|
||||||
|
Note this will also work when the second file is a scalar (string/number)
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: apples
|
||||||
|
```
|
||||||
|
And another sample another.yml file of:
|
||||||
|
```yaml
|
||||||
|
b: bob
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval-all 'select(fileIndex==0).a = select(fileIndex==1) | select(fileIndex==0)' sample.yml another.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: bob
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update node to be the sibling value
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: child
|
||||||
|
b: sibling
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a = .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: sibling
|
||||||
|
b: sibling
|
||||||
|
```
|
||||||
|
|
||||||
|
## Updated multiple paths
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: fieldA
|
||||||
|
b: fieldB
|
||||||
|
c: fieldC
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '(.a, .c) |= "potatoe"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: potatoe
|
||||||
|
b: fieldB
|
||||||
|
c: potatoe
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update string value
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: apple
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.b = "frog"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update string value via |=
|
||||||
|
Note there is no difference between `=` and `|=` when the RHS is a scalar
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: apple
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.b |= "frog"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update selected results
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: apple
|
||||||
|
c: cactus
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '(.a[] | select(. == "apple")) = "frog"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: frog
|
||||||
|
c: cactus
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update array values
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- candy
|
||||||
|
- apple
|
||||||
|
- sandy
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '(.[] | select(. == "*andy")) = "bogs"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- bogs
|
||||||
|
- apple
|
||||||
|
- bogs
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update empty object
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.b |= "bogs"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
{a: {b: bogs}}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update empty object and array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.b.[0] |= "bogs"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
{a: {b: [bogs]}}
|
||||||
|
```
|
||||||
|
|
220
pkg/yqlib/doc/Boolean Operators.md
Normal file
220
pkg/yqlib/doc/Boolean Operators.md
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
The `or` and `and` operators take two parameters and return a boolean result.
|
||||||
|
|
||||||
|
`not` flips a boolean from true to false, or vice versa.
|
||||||
|
|
||||||
|
`any` will return `true` if there are any `true` values in a array sequence, and `all` will return true if _all_ elements in an array are true.
|
||||||
|
|
||||||
|
`any_c(condition)` and `all_c(condition)` are like `any` and `all` but they take a condition expression that is used against each element to determine if it's `true`. Note: in `jq` you can simply pass a condition to `any` or `all` and it simply works - `yq` isn't that clever..yet
|
||||||
|
|
||||||
|
These are most commonly used with the `select` operator to filter particular nodes.
|
||||||
|
|
||||||
|
## `or` example
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input 'true or false'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
## `and` example
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input 'true and false'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Matching nodes with select, equals and or
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- a: bird
|
||||||
|
b: dog
|
||||||
|
- a: frog
|
||||||
|
b: bird
|
||||||
|
- a: cat
|
||||||
|
b: fly
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '[.[] | select(.a == "cat" or .b == "dog")]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- a: bird
|
||||||
|
b: dog
|
||||||
|
- a: cat
|
||||||
|
b: fly
|
||||||
|
```
|
||||||
|
|
||||||
|
## `any` returns true if any boolean in a given array is true
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- false
|
||||||
|
- true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'any' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
## `any` returns false for an empty array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
[]
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'any' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
## `any_c` returns true if any element in the array is true for the given condition.
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- rad
|
||||||
|
- awesome
|
||||||
|
b:
|
||||||
|
- meh
|
||||||
|
- whatever
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] |= any_c(. == "awesome")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: true
|
||||||
|
b: false
|
||||||
|
```
|
||||||
|
|
||||||
|
## `all` returns true if all booleans in a given array are true
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- true
|
||||||
|
- true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'all' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
## `all` returns true for an empty array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
[]
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'all' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
## `all_c` returns true if all elements in the array are true for the given condition.
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- rad
|
||||||
|
- awesome
|
||||||
|
b:
|
||||||
|
- meh
|
||||||
|
- 12
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] |= all_c(tag == "!!str")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: true
|
||||||
|
b: false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Not true is false
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input 'true | not'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Not false is true
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input 'false | not'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
## String values considered to be true
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input '"cat" | not'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Empty string value considered to be true
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input '"" | not'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Numbers are considered to be true
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input '1 | not'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Zero is considered to be true
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input '0 | not'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Null is considered to be false
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input '~ | not'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
41
pkg/yqlib/doc/Collect into Array.md
Normal file
41
pkg/yqlib/doc/Collect into Array.md
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# Collect into Array
|
||||||
|
|
||||||
|
This creates an array using the expression between the square brackets.
|
||||||
|
|
||||||
|
|
||||||
|
## Collect empty
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input '[]'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
[]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Collect single
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input '["cat"]'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Collect many
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '[.a, .b]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- cat
|
||||||
|
- dog
|
||||||
|
```
|
||||||
|
|
151
pkg/yqlib/doc/Comment Operators.md
Normal file
151
pkg/yqlib/doc/Comment Operators.md
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
Use these comment operators to set or retrieve comments.
|
||||||
|
|
||||||
|
Like the `=` and `|=` assign operators, the same syntax applies when updating comments:
|
||||||
|
|
||||||
|
|
||||||
|
### plain form: `=`
|
||||||
|
This will assign the LHS nodes comments to the expression on the RHS. The RHS is run against the matching nodes in the pipeline
|
||||||
|
|
||||||
|
### relative form: `|=`
|
||||||
|
Similar to the plain form, however the RHS evaluates against each matching LHS node! This is useful if you want to set the comments as a relative expression of the node, for instance its value or path.
|
||||||
|
|
||||||
|
|
||||||
|
## Set line comment
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a lineComment="single"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat # single
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use update assign to perform relative updates
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.. lineComment |= .' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat # cat
|
||||||
|
b: dog # dog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set head comment
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '. headComment="single"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
# single
|
||||||
|
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set foot comment, using an expression
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '. footComment=.a' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
|
||||||
|
# cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Remove comment
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat # comment
|
||||||
|
b: dog # leave this
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a lineComment=""' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: dog # leave this
|
||||||
|
```
|
||||||
|
|
||||||
|
## Remove (strip) all comments
|
||||||
|
Note the use of `...` to ensure key nodes are included.
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat # comment
|
||||||
|
# great
|
||||||
|
b: # key comment
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '... comments=""' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b:
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get line comment
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat # meow
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a | lineComment' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
meow
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get head comment
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat # meow
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '. | headComment' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get foot comment
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat # meow
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '. | footComment' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
|
||||||
|
```
|
||||||
|
|
79
pkg/yqlib/doc/Create, Collect into Object.md
Normal file
79
pkg/yqlib/doc/Create, Collect into Object.md
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
This is used to construct objects (or maps). This can be used against existing yaml, or to create fresh yaml documents.
|
||||||
|
## Collect empty object
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input '{}'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Wrap (prefix) existing object
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
name: Mike
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '{"wrap": .}' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
wrap:
|
||||||
|
name: Mike
|
||||||
|
```
|
||||||
|
|
||||||
|
## Using splat to create multiple objects
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
name: Mike
|
||||||
|
pets:
|
||||||
|
- cat
|
||||||
|
- dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '{.name: .pets.[]}' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
Mike: cat
|
||||||
|
Mike: dog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Working with multiple documents
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
name: Mike
|
||||||
|
pets:
|
||||||
|
- cat
|
||||||
|
- dog
|
||||||
|
---
|
||||||
|
name: Rosey
|
||||||
|
pets:
|
||||||
|
- monkey
|
||||||
|
- sheep
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '{.name: .pets.[]}' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
Mike: cat
|
||||||
|
Mike: dog
|
||||||
|
Rosey: monkey
|
||||||
|
Rosey: sheep
|
||||||
|
```
|
||||||
|
|
||||||
|
## Creating yaml from scratch
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input '{"wrap": "frog"}'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
wrap: frog
|
||||||
|
```
|
||||||
|
|
117
pkg/yqlib/doc/Delete.md
Normal file
117
pkg/yqlib/doc/Delete.md
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
Deletes matching entries in maps or arrays.
|
||||||
|
## Delete entry in map
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'del(.b)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Delete nested entry in map
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
a1: fred
|
||||||
|
a2: frood
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'del(.a.a1)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
a2: frood
|
||||||
|
```
|
||||||
|
|
||||||
|
## Delete entry in array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'del(.[1])' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- 1
|
||||||
|
- 3
|
||||||
|
```
|
||||||
|
|
||||||
|
## Delete nested entry in array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- a: cat
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'del(.[0].a)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- b: dog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Delete no matches
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'del(.c)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Delete matching entries
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: dog
|
||||||
|
c: bat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'del( .[] | select(. == "*at") )' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Recursively delete matching keys
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
name: frog
|
||||||
|
b:
|
||||||
|
name: blog
|
||||||
|
age: 12
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'del(.. | select(has("name")).name)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
age: 12
|
||||||
|
```
|
||||||
|
|
88
pkg/yqlib/doc/Document Index.md
Normal file
88
pkg/yqlib/doc/Document Index.md
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
Use the `documentIndex` operator (or the `di` shorthand) to select nodes of a particular document.
|
||||||
|
## Retrieve a document index
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
---
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a | documentIndex' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
0
|
||||||
|
---
|
||||||
|
1
|
||||||
|
```
|
||||||
|
|
||||||
|
## Retrieve a document index, shorthand
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
---
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a | di' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
0
|
||||||
|
---
|
||||||
|
1
|
||||||
|
```
|
||||||
|
|
||||||
|
## Filter by document index
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
---
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'select(documentIndex == 1)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Filter by document index shorthand
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
---
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'select(di == 1)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Print Document Index with matches
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
---
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a | ({"match": ., "doc": documentIndex})' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
match: cat
|
||||||
|
doc: 0
|
||||||
|
match: frog
|
||||||
|
doc: 1
|
||||||
|
```
|
||||||
|
|
100
pkg/yqlib/doc/Entries.md
Normal file
100
pkg/yqlib/doc/Entries.md
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
Similar to the same named functions in `jq` these functions convert to/from an object and an array of key-value pairs. This is most useful for performing operations on keys of maps.
|
||||||
|
## to_entries Map
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: 1
|
||||||
|
b: 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'to_entries' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- key: a
|
||||||
|
value: 1
|
||||||
|
- key: b
|
||||||
|
value: 2
|
||||||
|
```
|
||||||
|
|
||||||
|
## to_entries Array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- a
|
||||||
|
- b
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'to_entries' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- key: 0
|
||||||
|
value: a
|
||||||
|
- key: 1
|
||||||
|
value: b
|
||||||
|
```
|
||||||
|
|
||||||
|
## to_entries null
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
null
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'to_entries' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
## from_entries map
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: 1
|
||||||
|
b: 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'to_entries | from_entries' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: 1
|
||||||
|
b: 2
|
||||||
|
```
|
||||||
|
|
||||||
|
## from_entries with numeric key indexes
|
||||||
|
from_entries always creates a map, even for numeric keys
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- a
|
||||||
|
- b
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'to_entries | from_entries' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
0: a
|
||||||
|
1: b
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use with_entries to update keys
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: 1
|
||||||
|
b: 2
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'with_entries(.key |= "KEY_" + .)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
KEY_a: 1
|
||||||
|
KEY_b: 2
|
||||||
|
```
|
||||||
|
|
78
pkg/yqlib/doc/Env Variable Operators.md
Normal file
78
pkg/yqlib/doc/Env Variable Operators.md
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
This operator is used to handle environment variables usage in path expressions. While environment variables can, of course, be passed in via your CLI with string interpolation, this often comes with complex quote escaping and can be tricky to write and read. Note that there are two forms, `env` which will parse the environment variable as a yaml (be it a map, array, string, number of boolean) and `strenv` which will always parse the argument as a string.
|
||||||
|
|
||||||
|
|
||||||
|
## Read string environment variable
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
myenv="cat meow" yq eval --null-input '.a = env(myenv)'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat meow
|
||||||
|
```
|
||||||
|
|
||||||
|
## Read boolean environment variable
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
myenv="true" yq eval --null-input '.a = env(myenv)'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Read numeric environment variable
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
myenv="12" yq eval --null-input '.a = env(myenv)'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: 12
|
||||||
|
```
|
||||||
|
|
||||||
|
## Read yaml environment variable
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
myenv="{b: fish}" yq eval --null-input '.a = env(myenv)'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: {b: fish}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Read boolean environment variable as a string
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
myenv="true" yq eval --null-input '.a = strenv(myenv)'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: "true"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Read numeric environment variable as a string
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
myenv="12" yq eval --null-input '.a = strenv(myenv)'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: "12"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dynamic key lookup with environment variable
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
cat: meow
|
||||||
|
dog: woof
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
myenv="cat" yq eval '.[env(myenv)]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
meow
|
||||||
|
```
|
||||||
|
|
123
pkg/yqlib/doc/Equals.md
Normal file
123
pkg/yqlib/doc/Equals.md
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
This is a boolean operator that will return ```true``` if the LHS is equal to the RHS and ``false`` otherwise.
|
||||||
|
|
||||||
|
```
|
||||||
|
.a == .b
|
||||||
|
```
|
||||||
|
|
||||||
|
It is most often used with the select operator to find particular nodes:
|
||||||
|
|
||||||
|
```
|
||||||
|
select(.a == .b)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Match string
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- cat
|
||||||
|
- goat
|
||||||
|
- dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] | (. == "*at")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
true
|
||||||
|
true
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Don't match string
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- cat
|
||||||
|
- goat
|
||||||
|
- dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] | (. != "*at")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
false
|
||||||
|
false
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Match number
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
- 5
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] | (. == 4)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
false
|
||||||
|
true
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dont match number
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
- 5
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] | (. != 4)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
true
|
||||||
|
false
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Match nulls
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input 'null == ~'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Non exisitant key doesn't equal a value
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'select(.b != "thing")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Two non existant keys are equal
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'select(.b == .c)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
|
71
pkg/yqlib/doc/File Operators.md
Normal file
71
pkg/yqlib/doc/File Operators.md
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
File operators are most often used with merge when needing to merge specific files together. Note that when doing this, you will need to use `eval-all` to ensure all yaml documents are loaded into memory before performing the merge (as opposed to `eval` which runs the expression once per document).
|
||||||
|
|
||||||
|
Note that the `fileIndex` operator has a short alias of `fi`.
|
||||||
|
|
||||||
|
## Merging files
|
||||||
|
Note the use of eval-all to ensure all documents are loaded into memory.
|
||||||
|
```bash
|
||||||
|
yq eval-all 'select(fi == 0) * select(filename == "file2.yaml")' file1.yaml file2.yaml
|
||||||
|
```
|
||||||
|
## Get filename
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'filename' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
sample.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get file index
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'fileIndex' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
0
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get file indices of multiple documents
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
And another sample another.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval-all 'fileIndex' sample.yml another.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
0
|
||||||
|
---
|
||||||
|
1
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get file index alias
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'fi' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
0
|
||||||
|
```
|
||||||
|
|
67
pkg/yqlib/doc/Has.md
Normal file
67
pkg/yqlib/doc/Has.md
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
This is operation that returns true if the key exists in a map (or index in an array), false otherwise.
|
||||||
|
## Has map key
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- a: yes
|
||||||
|
- a: ~
|
||||||
|
- a:
|
||||||
|
- b: nope
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] | has("a")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
true
|
||||||
|
true
|
||||||
|
true
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Select, checking for existence of deep paths
|
||||||
|
Simply pipe in parent expressions into `has`
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- a:
|
||||||
|
b:
|
||||||
|
c: cat
|
||||||
|
- a:
|
||||||
|
b:
|
||||||
|
d: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] | select(.a.b | has("c"))' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b:
|
||||||
|
c: cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Has array index
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- []
|
||||||
|
- [1]
|
||||||
|
- [1, 2]
|
||||||
|
- [1, null]
|
||||||
|
- [1, 2, 3]
|
||||||
|
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] | has(1)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
false
|
||||||
|
false
|
||||||
|
true
|
||||||
|
true
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
35
pkg/yqlib/doc/Keys.md
Normal file
35
pkg/yqlib/doc/Keys.md
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# Keys
|
||||||
|
|
||||||
|
Use the `keys` operator to return map keys or array indices.
|
||||||
|
## Map keys
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
dog: woof
|
||||||
|
cat: meow
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'keys' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- dog
|
||||||
|
- cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Array keys
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- apple
|
||||||
|
- banana
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'keys' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- 0
|
||||||
|
- 1
|
||||||
|
```
|
||||||
|
|
68
pkg/yqlib/doc/Length.md
Normal file
68
pkg/yqlib/doc/Length.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
Returns the lengths of the nodes. Length is defined according to the type of the node.
|
||||||
|
|
||||||
|
## String length
|
||||||
|
returns length of string
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a | length' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
3
|
||||||
|
```
|
||||||
|
|
||||||
|
## null length
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: null
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a | length' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
0
|
||||||
|
```
|
||||||
|
|
||||||
|
## Map length
|
||||||
|
returns number of entries
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
c: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'length' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
2
|
||||||
|
```
|
||||||
|
|
||||||
|
## Array length
|
||||||
|
returns number of elements
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- 2
|
||||||
|
- 4
|
||||||
|
- 6
|
||||||
|
- 8
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'length' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
4
|
||||||
|
```
|
||||||
|
|
366
pkg/yqlib/doc/Multiply (Merge).md
Normal file
366
pkg/yqlib/doc/Multiply (Merge).md
Normal file
@ -0,0 +1,366 @@
|
|||||||
|
Like the multiple operator in jq, depending on the operands, this multiply operator will do different things. Currently numbers, arrays and objects are supported.
|
||||||
|
|
||||||
|
## Objects and arrays - merging
|
||||||
|
Objects are merged deeply matching on matching keys. By default, array values override and are not deeply merged.
|
||||||
|
|
||||||
|
Note that when merging objects, this operator returns the merged object (not the parent). This will be clearer in the examples below.
|
||||||
|
|
||||||
|
### Merge Flags
|
||||||
|
You can control how objects are merged by using one or more of the following flags. Multiple flags can be used together, e.g. `.a *+? .b`. See examples below
|
||||||
|
|
||||||
|
- `+` to append arrays
|
||||||
|
- `?` to only merge existing fields
|
||||||
|
- `d` to deeply merge arrays
|
||||||
|
|
||||||
|
### Merging files
|
||||||
|
Note the use of `eval-all` to ensure all documents are loaded into memory.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' file1.yaml file2.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Multiply integers
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input '3 * 4'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
12
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge objects together, returning merged result only
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
field: me
|
||||||
|
fieldA: cat
|
||||||
|
b:
|
||||||
|
field:
|
||||||
|
g: wizz
|
||||||
|
fieldB: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a * .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
field:
|
||||||
|
g: wizz
|
||||||
|
fieldA: cat
|
||||||
|
fieldB: dog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge objects together, returning parent object
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
field: me
|
||||||
|
fieldA: cat
|
||||||
|
b:
|
||||||
|
field:
|
||||||
|
g: wizz
|
||||||
|
fieldB: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '. * {"a":.b}' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
field:
|
||||||
|
g: wizz
|
||||||
|
fieldA: cat
|
||||||
|
fieldB: dog
|
||||||
|
b:
|
||||||
|
field:
|
||||||
|
g: wizz
|
||||||
|
fieldB: dog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge keeps style of LHS
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: {things: great}
|
||||||
|
b:
|
||||||
|
also: "me"
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '. * {"a":.b}' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: {things: great, also: "me"}
|
||||||
|
b:
|
||||||
|
also: "me"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge arrays
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
b:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
- 5
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '. * {"a":.b}' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
- 5
|
||||||
|
b:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
- 5
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge, only existing fields
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
thing: one
|
||||||
|
cat: frog
|
||||||
|
b:
|
||||||
|
missing: two
|
||||||
|
thing: two
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a *? .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
thing: two
|
||||||
|
cat: frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge, appending arrays
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
array:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- animal: dog
|
||||||
|
value: coconut
|
||||||
|
b:
|
||||||
|
array:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
- animal: cat
|
||||||
|
value: banana
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a *+ .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
array:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- animal: dog
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
- animal: cat
|
||||||
|
value: banana
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge, only existing fields, appending arrays
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
thing:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
b:
|
||||||
|
thing:
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
another:
|
||||||
|
- 1
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a *?+ .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
thing:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge, deeply merging arrays
|
||||||
|
Merging arrays deeply means arrays are merge like objects, with indexes as their key. In this case, we merge the first item in the array, and do nothing with the second.
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- name: fred
|
||||||
|
age: 12
|
||||||
|
- name: bob
|
||||||
|
age: 32
|
||||||
|
b:
|
||||||
|
- name: fred
|
||||||
|
age: 34
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a *d .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- name: fred
|
||||||
|
age: 34
|
||||||
|
- name: bob
|
||||||
|
age: 32
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge arrays of objects together, matching on a key
|
||||||
|
It's a complex command, the trickyness comes from needing to have the right context in the expressions.
|
||||||
|
First we save the second array into a variable '$two' which lets us reference it later.
|
||||||
|
We then need to update the first array. We will use the relative update (|=) because we need to update relative to the current element of the array in the LHS in the RHS expression.
|
||||||
|
We set the current element of the first array as $cur. Now we multiply (merge) $cur with the matching entry in $two, by passing $two through a select filter.
|
||||||
|
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- a: apple
|
||||||
|
b: appleB
|
||||||
|
- a: kiwi
|
||||||
|
b: kiwiB
|
||||||
|
- a: banana
|
||||||
|
b: bananaB
|
||||||
|
```
|
||||||
|
And another sample another.yml file of:
|
||||||
|
```yaml
|
||||||
|
- a: banana
|
||||||
|
c: bananaC
|
||||||
|
- a: apple
|
||||||
|
b: appleB2
|
||||||
|
- a: dingo
|
||||||
|
c: dingoC
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval-all '(select(fi==1) | .[]) as $two | select(fi==0) | .[] |= (. as $cur | $cur * ($two | select(.a == $cur.a)))' sample.yml another.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- a: apple
|
||||||
|
b: appleB2
|
||||||
|
- a: kiwi
|
||||||
|
b: kiwiB
|
||||||
|
- a: banana
|
||||||
|
b: bananaB
|
||||||
|
c: bananaC
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge to prefix an element
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '. * {"a": {"c": .a}}' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
c: cat
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge with simple aliases
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: &cat
|
||||||
|
c: frog
|
||||||
|
b:
|
||||||
|
f: *cat
|
||||||
|
c:
|
||||||
|
g: thongs
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.c * .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
g: thongs
|
||||||
|
f: *cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge copies anchor names
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
c: &cat frog
|
||||||
|
b:
|
||||||
|
f: *cat
|
||||||
|
c:
|
||||||
|
g: thongs
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.c * .a' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
g: thongs
|
||||||
|
c: &cat frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge with merge anchors
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
foo: &foo
|
||||||
|
a: foo_a
|
||||||
|
thing: foo_thing
|
||||||
|
c: foo_c
|
||||||
|
bar: &bar
|
||||||
|
b: bar_b
|
||||||
|
thing: bar_thing
|
||||||
|
c: bar_c
|
||||||
|
foobarList:
|
||||||
|
b: foobarList_b
|
||||||
|
!!merge <<:
|
||||||
|
- *foo
|
||||||
|
- *bar
|
||||||
|
c: foobarList_c
|
||||||
|
foobar:
|
||||||
|
c: foobar_c
|
||||||
|
!!merge <<: *foo
|
||||||
|
thing: foobar_thing
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.foobar * .foobarList' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
c: foobarList_c
|
||||||
|
<<:
|
||||||
|
- *foo
|
||||||
|
- *bar
|
||||||
|
thing: foobar_thing
|
||||||
|
b: foobarList_b
|
||||||
|
```
|
||||||
|
|
92
pkg/yqlib/doc/Path.md
Normal file
92
pkg/yqlib/doc/Path.md
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
The path operator can be used to get the traversal paths of matching nodes in an expression. The path is returned as an array, which if traversed in order will lead to the matching node.
|
||||||
|
|
||||||
|
You can get the key/index of matching nodes by using the `path` operator to return the path array then piping that through `.[-1]` to get the last element of that array, the key.
|
||||||
|
|
||||||
|
## Map path
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.b | path' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- a
|
||||||
|
- b
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get map key
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.b | path | .[-1]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
b
|
||||||
|
```
|
||||||
|
|
||||||
|
## Array path
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- cat
|
||||||
|
- dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.[] | select(. == "dog") | path' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- a
|
||||||
|
- 1
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get array index
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- cat
|
||||||
|
- dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.[] | select(. == "dog") | path | .[-1]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
1
|
||||||
|
```
|
||||||
|
|
||||||
|
## Print path and value
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
- cat
|
||||||
|
- dog
|
||||||
|
- frog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.[] | select(. == "*og") | [{"path":path, "value":.}]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- path:
|
||||||
|
- a
|
||||||
|
- 1
|
||||||
|
value: dog
|
||||||
|
- path:
|
||||||
|
- a
|
||||||
|
- 2
|
||||||
|
value: frog
|
||||||
|
```
|
||||||
|
|
35
pkg/yqlib/doc/Pipe.md
Normal file
35
pkg/yqlib/doc/Pipe.md
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
Pipe the results of an expression into another. Like the bash operator.
|
||||||
|
|
||||||
|
## Simple Pipe
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a | .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Multiple updates
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cow
|
||||||
|
b: sheep
|
||||||
|
c: same
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a = "cat" | .b = "dog"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: dog
|
||||||
|
c: same
|
||||||
|
```
|
||||||
|
|
154
pkg/yqlib/doc/Recursive Descent (Glob).md
Normal file
154
pkg/yqlib/doc/Recursive Descent (Glob).md
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
This operator recursively matches (or globs) all children nodes given of a particular element, including that node itself. This is most often used to apply a filter recursively against all matches. It can be used in either the
|
||||||
|
|
||||||
|
## match values form `..`
|
||||||
|
This will, like the `jq` equivalent, recursively match all _value_ nodes. Use it to find/manipulate particular values.
|
||||||
|
|
||||||
|
For instance to set the `style` of all _value_ nodes in a yaml doc, excluding map keys:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yq eval '.. style= "flow"' file.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
## match values and map keys form `...`
|
||||||
|
The also includes map keys in the results set. This is particularly useful in YAML as unlike JSON, map keys can have their own styling, tags and use anchors and aliases.
|
||||||
|
|
||||||
|
For instance to set the `style` of all nodes in a yaml doc, including the map keys:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yq eval '... style= "flow"' file.yaml
|
||||||
|
```
|
||||||
|
## Recurse map (values only)
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '..' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: frog
|
||||||
|
frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Recursively find nodes with keys
|
||||||
|
Note that this example has wrapped the expression in `[]` to show that there are two matches returned. You do not have to wrap in `[]` in your path expression.
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
name: frog
|
||||||
|
b:
|
||||||
|
name: blog
|
||||||
|
age: 12
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '[.. | select(has("name"))]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- name: frog
|
||||||
|
b:
|
||||||
|
name: blog
|
||||||
|
age: 12
|
||||||
|
- name: blog
|
||||||
|
age: 12
|
||||||
|
```
|
||||||
|
|
||||||
|
## Recursively find nodes with values
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
nameA: frog
|
||||||
|
b:
|
||||||
|
nameB: frog
|
||||||
|
age: 12
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.. | select(. == "frog")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
frog
|
||||||
|
frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Recurse map (values and keys)
|
||||||
|
Note that the map key appears in the results
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: frog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '...' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: frog
|
||||||
|
a
|
||||||
|
frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Aliases are not traversed
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: &cat
|
||||||
|
c: frog
|
||||||
|
b: *cat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '[..]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- a: &cat
|
||||||
|
c: frog
|
||||||
|
b: *cat
|
||||||
|
- &cat
|
||||||
|
c: frog
|
||||||
|
- frog
|
||||||
|
- *cat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge docs are not traversed
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
foo: &foo
|
||||||
|
a: foo_a
|
||||||
|
thing: foo_thing
|
||||||
|
c: foo_c
|
||||||
|
bar: &bar
|
||||||
|
b: bar_b
|
||||||
|
thing: bar_thing
|
||||||
|
c: bar_c
|
||||||
|
foobarList:
|
||||||
|
b: foobarList_b
|
||||||
|
!!merge <<:
|
||||||
|
- *foo
|
||||||
|
- *bar
|
||||||
|
c: foobarList_c
|
||||||
|
foobar:
|
||||||
|
c: foobar_c
|
||||||
|
!!merge <<: *foo
|
||||||
|
thing: foobar_thing
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.foobar | [..]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- c: foobar_c
|
||||||
|
!!merge <<: *foo
|
||||||
|
thing: foobar_thing
|
||||||
|
- foobar_c
|
||||||
|
- *foo
|
||||||
|
- foobar_thing
|
||||||
|
```
|
||||||
|
|
76
pkg/yqlib/doc/Reduce.md
Normal file
76
pkg/yqlib/doc/Reduce.md
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
Reduce is a powerful way to process a collection of data into a new form.
|
||||||
|
|
||||||
|
```
|
||||||
|
<exp> as $<name> ireduce (<init>; <block>)
|
||||||
|
```
|
||||||
|
|
||||||
|
e.g.
|
||||||
|
|
||||||
|
```
|
||||||
|
.[] as $item ireduce (0; . + $item)
|
||||||
|
```
|
||||||
|
|
||||||
|
On the LHS we are configuring the collection of items that will be reduced `<exp>` as well as what each element will be called `$<name>`. Note that the array has been splatted into its individual elements.
|
||||||
|
|
||||||
|
On the RHS there is `<init>`, the starting value of the accumulator and `<block>`, the expression that will update the accumulator for each element in the collection. Note that within the block expression, `.` will evaluate to the current value of the accumulator.
|
||||||
|
|
||||||
|
## yq vs jq syntax
|
||||||
|
Reduce syntax in `yq` is a little different from `jq` - as `yq` (currently) isn't as sophisticated as `jq` and its only supports infix notation (e.g. a + b, where the operator is in the middle of the two parameters) - where as `jq` uses a mix of infix notation with _prefix_ notation (e.g. `reduce a b` is like writing `+ a b`).
|
||||||
|
|
||||||
|
To that end, the reduce operator is called `ireduce` for backwards compatability if a `jq` like prefix version of `reduce` is ever added.
|
||||||
|
|
||||||
|
|
||||||
|
## Sum numbers
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- 10
|
||||||
|
- 2
|
||||||
|
- 5
|
||||||
|
- 3
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] as $item ireduce (0; . + $item)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
20
|
||||||
|
```
|
||||||
|
|
||||||
|
## Merge all yaml files together
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
```
|
||||||
|
And another sample another.yml file of:
|
||||||
|
```yaml
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval-all '. as $item ireduce ({}; . * $item )' sample.yml another.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Convert an array to an object
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- name: Cathy
|
||||||
|
has: apples
|
||||||
|
- name: Bob
|
||||||
|
has: bananas
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] as $item ireduce ({}; .[$item | .name] = ($item | .has) )' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
Cathy: apples
|
||||||
|
Bob: bananas
|
||||||
|
```
|
||||||
|
|
38
pkg/yqlib/doc/Select.md
Normal file
38
pkg/yqlib/doc/Select.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
Select is used to filter arrays and maps by a boolean expression.
|
||||||
|
## Select elements from array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- cat
|
||||||
|
- goat
|
||||||
|
- dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] | select(. == "*at")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
cat
|
||||||
|
goat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Select and update matching values in map
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
things: cat
|
||||||
|
bob: goat
|
||||||
|
horse: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '(.a.[] | select(. == "*at")) |= "rabbit"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
things: rabbit
|
||||||
|
bob: rabbit
|
||||||
|
horse: dog
|
||||||
|
```
|
||||||
|
|
68
pkg/yqlib/doc/Sort Keys.md
Normal file
68
pkg/yqlib/doc/Sort Keys.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
The Sort Keys operator sorts maps by their keys (based on their string value). This operator does not do anything to arrays or scalars (so you can easily recursively apply it to all maps).
|
||||||
|
|
||||||
|
Sort is particularly useful for diffing two different yaml documents:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yq eval -i 'sortKeys(..)' file1.yml
|
||||||
|
yq eval -i 'sortKeys(..)' file2.yml
|
||||||
|
diff file1.yml file2.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Sort keys of map
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
c: frog
|
||||||
|
a: blah
|
||||||
|
b: bing
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'sortKeys(.)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: blah
|
||||||
|
b: bing
|
||||||
|
c: frog
|
||||||
|
```
|
||||||
|
|
||||||
|
## Sort keys recursively
|
||||||
|
Note the array elements are left unsorted, but maps inside arrays are sorted
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
bParent:
|
||||||
|
c: dog
|
||||||
|
array:
|
||||||
|
- 3
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
aParent:
|
||||||
|
z: donkey
|
||||||
|
x:
|
||||||
|
- c: yum
|
||||||
|
b: delish
|
||||||
|
- b: ew
|
||||||
|
a: apple
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'sortKeys(..)' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
aParent:
|
||||||
|
x:
|
||||||
|
- b: delish
|
||||||
|
c: yum
|
||||||
|
- a: apple
|
||||||
|
b: ew
|
||||||
|
z: donkey
|
||||||
|
bParent:
|
||||||
|
array:
|
||||||
|
- 3
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
c: dog
|
||||||
|
```
|
||||||
|
|
31
pkg/yqlib/doc/Split into Documents.md
Normal file
31
pkg/yqlib/doc/Split into Documents.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Split into Documents
|
||||||
|
|
||||||
|
This operator splits all matches into separate documents
|
||||||
|
|
||||||
|
## Split empty
|
||||||
|
Running
|
||||||
|
```bash
|
||||||
|
yq eval --null-input 'splitDoc'
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Split array
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- a: cat
|
||||||
|
- b: dog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] | splitDoc' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
---
|
||||||
|
b: dog
|
||||||
|
```
|
||||||
|
|
88
pkg/yqlib/doc/String Operators.md
Normal file
88
pkg/yqlib/doc/String Operators.md
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
# String Operators
|
||||||
|
|
||||||
|
## Join strings
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
- cat
|
||||||
|
- meow
|
||||||
|
- 1
|
||||||
|
- null
|
||||||
|
- true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'join("; ")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
cat; meow; 1; ; true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Substitute / Replace string
|
||||||
|
This uses golang regex, described [here](https://github.com/google/re2/wiki/Syntax)
|
||||||
|
Note the use of `|=` to run in context of the current string value.
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: dogs are great
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a |= sub("dogs", "cats")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cats are great
|
||||||
|
```
|
||||||
|
|
||||||
|
## Substitute / Replace string with regex
|
||||||
|
This uses golang regex, described [here](https://github.com/google/re2/wiki/Syntax)
|
||||||
|
Note the use of `|=` to run in context of the current string value.
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: heat
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] |= sub("(a)", "${1}r")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cart
|
||||||
|
b: heart
|
||||||
|
```
|
||||||
|
|
||||||
|
## Split strings
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
cat; meow; 1; ; true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'split("; ")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- cat
|
||||||
|
- meow
|
||||||
|
- "1"
|
||||||
|
- ""
|
||||||
|
- "true"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Split strings one match
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
word
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval 'split("; ")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- word
|
||||||
|
```
|
||||||
|
|
239
pkg/yqlib/doc/Style.md
Normal file
239
pkg/yqlib/doc/Style.md
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
The style operator can be used to get or set the style of nodes (e.g. string style, yaml style)
|
||||||
|
## Update and set style of a particular node (simple)
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: thing
|
||||||
|
c: something
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.b = "new" | .a.b style="double"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: "new"
|
||||||
|
c: something
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update and set style of a particular node using path variables
|
||||||
|
You can use a variable to re-use a path
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: thing
|
||||||
|
c: something
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a.b as $x | $x = "new" | $x style="double"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a:
|
||||||
|
b: "new"
|
||||||
|
c: something
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set tagged style
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: 5
|
||||||
|
c: 3.2
|
||||||
|
e: true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.. style="tagged"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
!!map
|
||||||
|
a: !!str cat
|
||||||
|
b: !!int 5
|
||||||
|
c: !!float 3.2
|
||||||
|
e: !!bool true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set double quote style
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: 5
|
||||||
|
c: 3.2
|
||||||
|
e: true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.. style="double"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: "cat"
|
||||||
|
b: "5"
|
||||||
|
c: "3.2"
|
||||||
|
e: "true"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set double quote style on map keys too
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: 5
|
||||||
|
c: 3.2
|
||||||
|
e: true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '... style="double"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
"a": "cat"
|
||||||
|
"b": "5"
|
||||||
|
"c": "3.2"
|
||||||
|
"e": "true"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set single quote style
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: 5
|
||||||
|
c: 3.2
|
||||||
|
e: true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.. style="single"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: 'cat'
|
||||||
|
b: '5'
|
||||||
|
c: '3.2'
|
||||||
|
e: 'true'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set literal quote style
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: 5
|
||||||
|
c: 3.2
|
||||||
|
e: true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.. style="literal"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: |-
|
||||||
|
cat
|
||||||
|
b: |-
|
||||||
|
5
|
||||||
|
c: |-
|
||||||
|
3.2
|
||||||
|
e: |-
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set folded quote style
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: 5
|
||||||
|
c: 3.2
|
||||||
|
e: true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.. style="folded"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: >-
|
||||||
|
cat
|
||||||
|
b: >-
|
||||||
|
5
|
||||||
|
c: >-
|
||||||
|
3.2
|
||||||
|
e: >-
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set flow quote style
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: 5
|
||||||
|
c: 3.2
|
||||||
|
e: true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.. style="flow"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
{a: cat, b: 5, c: 3.2, e: true}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Reset style - or pretty print
|
||||||
|
Set empty (default) quote style, note the usage of `...` to match keys too. Note that there is a `--prettyPrint/-P` short flag for this.
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
"b": 5
|
||||||
|
'c': 3.2
|
||||||
|
"e": true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '... style=""' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: 5
|
||||||
|
c: 3.2
|
||||||
|
e: true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set style relatively with assign-update
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: single
|
||||||
|
b: double
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] style |= .' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: 'single'
|
||||||
|
b: "double"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Read style
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
{a: "cat", b: 'thing'}
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.. | style' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
flow
|
||||||
|
double
|
||||||
|
single
|
||||||
|
```
|
||||||
|
|
71
pkg/yqlib/doc/Subtract.md
Normal file
71
pkg/yqlib/doc/Subtract.md
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
|
||||||
|
## Number subtraction - float
|
||||||
|
If the lhs or rhs are floats then the expression will be calculated with floats.
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: 3
|
||||||
|
b: 4.5
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a = .a - .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: -1.5
|
||||||
|
b: 4.5
|
||||||
|
```
|
||||||
|
|
||||||
|
## Number subtraction - float
|
||||||
|
If the lhs or rhs are floats then the expression will be calculated with floats.
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: 3
|
||||||
|
b: 4.5
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a = .a - .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: -1.5
|
||||||
|
b: 4.5
|
||||||
|
```
|
||||||
|
|
||||||
|
## Number subtraction - int
|
||||||
|
If both the lhs and rhs are ints then the expression will be calculated with ints.
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: 3
|
||||||
|
b: 4
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a = .a - .b' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: -1
|
||||||
|
b: 4
|
||||||
|
```
|
||||||
|
|
||||||
|
## Decrement numbers
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: 3
|
||||||
|
b: 5
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.[] -= 1' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: 2
|
||||||
|
b: 4
|
||||||
|
```
|
||||||
|
|
58
pkg/yqlib/doc/Tag.md
Normal file
58
pkg/yqlib/doc/Tag.md
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
The tag operator can be used to get or set the tag of nodes (e.g. `!!str`, `!!int`, `!!bool`).
|
||||||
|
## Get tag
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: 5
|
||||||
|
c: 3.2
|
||||||
|
e: true
|
||||||
|
f: []
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.. | tag' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
!!map
|
||||||
|
!!str
|
||||||
|
!!int
|
||||||
|
!!float
|
||||||
|
!!bool
|
||||||
|
!!seq
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set custom tag
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: str
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.a tag = "!!mikefarah"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: !!mikefarah str
|
||||||
|
```
|
||||||
|
|
||||||
|
## Find numbers and convert them to strings
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: 5
|
||||||
|
c: 3.2
|
||||||
|
e: true
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '(.. | select(tag == "!!int")) tag= "!!str"' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: cat
|
||||||
|
b: "5"
|
||||||
|
c: 3.2
|
||||||
|
e: true
|
||||||
|
```
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user