Compare commits

..
1303 Commits
Author SHA1 Message Date
Mike Farah d8f8661567 Fixing from review 2022-08-01 10:16:59 +10:00
Mike Farah 9628aaf8c5 Added CSV roundtrip 2022-08-01 10:05:26 +10:00
Mike Farah cb0bae128f Adding CSV decoder 2022-07-31 17:35:36 +10:00
Mike Farah 183a42c249 WIP: adding CSV decoder 2022-07-31 17:31:27 +10:00
Mike Farah 4508bc2dc2 Updating release notes for next release 2022-07-29 10:28:06 +10:00
Mike Farah 8c3a8c085e Fixes xml decode missing tags #1284 2022-07-29 10:26:50 +10:00
Mike FarahandGitHub b9a1ef89fe Added NDJSON decoder (#1281) 2022-07-27 12:26:22 +10:00
Mike Farah c2c48bbe1d Bumping version 2022-07-15 10:27:18 +10:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
97f89c0edb Bump golang from 1.18.3 to 1.18.4 (#1273)
Bumps golang from 1.18.3 to 1.18.4.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-14 15:38:26 +10:00
Mike FarahandGitHub 03ba38eaff Using new lexer by alecthomas! (#1270) 2022-07-13 14:45:28 +10:00
Mike Farah f393cf37c2 Dont clobber anchor when adding nodes - fixes #1269 2022-07-13 11:12:15 +10:00
Mike Farah f3a8c4b2ec Added contributing guide on documentation 2022-07-07 11:53:23 +10:00
Mike Farah 86c2b03630 Added error operator for custom validation #1259 2022-06-25 12:46:24 +10:00
Daniel CarboneandGitHub 98b411f82e adding support for --wrapScalar=false in properties encoder (#1241)
* adding support for --wrapScalar=false in properties encoder

* altering encoder and decoder tests somewhat

* adding .idea

* Revert "altering encoder and decoder tests somewhat"

This reverts commit e3655130e2.

* adding test scenario for encoding with wrapped scalars
2022-06-25 12:22:03 +10:00
Mike Farah 06d2aaad80 Adding acceptance test for #1257, fixed panic 2022-06-25 12:15:28 +10:00
HayamaandGitHub 9b47a29864 hotfix: fix panic multiply assign (#1257) 2022-06-25 12:08:52 +10:00
Mike Farah b669844ef7 Bumping version 2022-06-23 19:45:54 +10:00
Mike Farah ad4e7c9d8a Updating release notes for next release 2022-06-23 19:44:18 +10:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
c5f83e4730 Bump github.com/spf13/cobra from 1.4.0 to 1.5.0 (#1250)
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.4.0...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-23 19:23:45 +10:00
Mike Farah be05df03b5 Fixing usage of quoted numeric keys #1247 2022-06-23 19:22:11 +10:00
Mike Farah c7c11ef68b Updating release notes for next release 2022-06-23 14:33:00 +10:00
SandroandGitHub 7fe937c61e Map -r to --unwrapScalar to be more a drop in replacement for jq (#1245) 2022-06-23 14:31:31 +10:00
Mike Farah dfd396b480 When split expression includes an extension, dont add .yml automatically 2022-06-23 14:31:09 +10:00
Mike Farah f63d76f006 updating release notes for next release 2022-06-16 10:37:21 -07:00
Mike Farah 2bc7dcfcca Handle xml namespaces by default 2022-06-15 17:12:57 -07:00
Mike Farah 60c037f57e Can add string to scalars in any order #1234 2022-06-15 17:09:17 -07:00
rndmitandGitHub b9309a42a4 XML decoder additions (#1239)
* Add xml-keep-namespace and xml-raw-token features

* Add tests

* Change flags usage strings

* Append docs
2022-06-15 09:40:31 +10:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
98193a7a9d Bump golang from 1.18.2 to 1.18.3 (#1233)
Bumps golang from 1.18.2 to 1.18.3.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-03 11:02:38 +10:00
Mike Farah 8d3be1a23c Length (and some other operators) should not include head/foot comments #1231 2022-05-31 16:28:53 +10:00
Mike Farah 70403375d7 Bumping version 2022-05-28 13:38:53 +10:00
Mike Farah 9eaec6f0f5 Bumped go-yaml! 2022-05-28 13:32:35 +10:00
Mike Farah 439bcaad25 Added multiple object example from PR #1226 2022-05-27 11:22:10 +10:00
Mike Farah 294da55012 Fixed base64/xml decode an empty string #1209 2022-05-27 11:18:38 +10:00
Mike Farah 8d32e6a82c Fixed base64 decode an empty string #1209 2022-05-27 10:56:43 +10:00
Mike Farah 1e27e39927 Fixing typos (prefer UK english) 2022-05-25 11:02:18 +10:00
Mike Farah 5126f3dfee Fixed doc 2022-05-25 10:54:56 +10:00
Mike Farah 6bce23d9c2 Improved handling of trailing document comments 2022-05-25 10:54:03 +10:00
Christoph StäblerandGitHub dee592eb3b Fix typo (#1222) 2022-05-24 18:18:27 +10:00
Mike Farah 451d8643ee Updating merge docs 2022-05-24 16:16:58 +10:00
Mike Farah fbe49c3700 Added colors to json output #1208 2022-05-22 21:19:59 +10:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
7d28e4e0de Bump golang from 1.18.1 to 1.18.2 (#1211)
Bumps golang from 1.18.1 to 1.18.2.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-12 18:57:45 +10:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
9f0f29f0fc Bump docker/setup-buildx-action from 1 to 2 (#1212)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 1 to 2.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-12 18:57:36 +10:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3c46c9ff1e Bump docker/setup-qemu-action from 1 to 2 (#1213)
Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 1 to 2.
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: docker/setup-qemu-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-12 18:57:27 +10:00
Mike Farah c05995b301 Added codeql badge 2022-05-06 13:54:49 +10:00
Mike Farah 72cdde78f6 Fixing issues found by codeql 2022-05-06 13:46:14 +10:00
NaveenandGitHub 1aeb8e3025 chore: Enable codeql action (#1202)
This action runs GitHub's industry-leading semantic code analysis engine, CodeQL, against a repository's source code to find security vulnerabilities.

https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning-with-codeql

https://github.com/ossf/scorecard/blob/main/docs/checks.md#sast
2022-05-06 13:43:51 +10:00
Mike Farah 689c535a29 Updated unique docs 2022-04-29 12:16:57 +10:00
Mike Farah 1425d0720e Bumping version 2022-04-29 11:57:37 +10:00
Mike Farah 55c5497fab Can specify a split expression file #1194 2022-04-29 11:08:41 +10:00
Mike Farah 67c79b7cb1 Fixes append map bug when key matches value in existing map #1200 2022-04-28 14:45:45 +10:00
Mike Farah 26529fae94 Nicer error message when trying to use merge anchor tags other than maps #1184 2022-04-27 14:46:52 +10:00
Mike Farah 70ad7a35a8 Don't automatically read stdin when the null input flag is used 2022-04-27 09:24:25 +10:00
Mike Farah 90261a2fdd Added type as an alias for tag #1195 2022-04-27 09:11:43 +10:00
Mike Farah 3ad5355777 Fixes bug when using inplace with no expression and multiple files #1193 2022-04-27 09:08:50 +10:00
Mike Farah ed5b811f37 Bumping version 2022-04-15 08:51:55 +10:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
22a2ccfdf4 Bump actions/setup-go from 2 to 3 (#1183)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-15 08:27:51 +10:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
691e52e408 Bump golang from 1.18.0 to 1.18.1 (#1182)
Bumps golang from 1.18.0 to 1.18.1.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-15 08:27:40 +10:00
Mike Farah b11075ec98 now assumes yaml idiomatic formatting when adding to empty maps/arrays 2022-04-15 08:27:22 +10:00
Mike Farah ea66a73f43 Fixed sort dropping head comment #1181 2022-04-14 12:19:15 +10:00
Mike Farah 6f9f80cc48 Fixes with operation bug #1174 2022-04-14 12:03:18 +10:00
Mike Farah 13a27e8b2d Fixing docker release 2022-04-12 12:38:09 +10:00
Mike Farah bcff465f11 Fixing docker release 2022-04-12 10:20:23 +10:00
Mike Farah 270d8bd51a Releasing 4.24.3 2022-04-12 09:49:13 +10:00
Mike Farah 2ef367b2b0 Trying new release process 2022-04-12 09:36:52 +10:00
Mike Farah 454e563a0e Trying new release process 2022-04-12 09:35:18 +10:00
Mike Farah 217744bc9a Pulled out docker build 2022-04-12 09:27:35 +10:00
Mike Farah 34ffb94d98 Moving alpline-publusher out of yq (gosec) 2022-04-12 09:22:30 +10:00
RomanandGitHub 6f4702a230 Added action to automatically prepare a branch for the alpine package update (#1171) 2022-04-12 08:51:27 +10:00
NaveenandGitHub b1f77d975e Set permissions for GitHub actions (#1168)
- Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions

https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

[Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)

 Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
2022-04-09 14:55:43 +10:00
Mike Farah 523b8335d8 Fixing string docs 2022-04-01 13:21:55 +11:00
Mike Farah 5d225b9454 Updating readme 2022-03-29 13:15:27 +11:00
Mike Farah 0956eefb1a Fixed help links 2022-03-29 11:08:50 +11:00
Mike Farah a9ed08a5f8 Fixed compare docs 2022-03-29 11:01:02 +11:00
Benjamin WuethrichandGitHub ae71824adc Fix Markdown link formatting (#1157)
* Fix Markdown link formatting

* Fix parens
2022-03-29 10:23:32 +11:00
Mike Farah 186b319093 Added from_props 2022-03-28 19:48:30 +11:00
Mike Farah bc2118736b v4.24.2 2022-03-28 14:36:27 +11:00
Mike Farah 1780027421 Bumping version 2022-03-28 14:24:28 +11:00
Mike Farah 3cd999bb87 Bumping to go1.18, bumping dev tools 2022-03-28 14:18:55 +11:00
Mike Farah bbeae229ca Disable strict XML parsing by default #1155 2022-03-28 14:05:10 +11:00
Mike Farah 3a1e2c7518 Fixed silently ignored error in xml decoder 2022-03-27 11:42:07 +11:00
Mike Farah fb148c305a Added comparison ops (>,>=...) 2022-03-24 11:38:05 +11:00
Mike Farah 897604142f Better string docs 2022-03-23 10:28:45 +11:00
Mike Farah 03f57b7034 Bumping version 2022-03-20 13:03:40 +11:00
Mike FarahandGitHub 005b097cee Boolean fix (#1148)
* Fixing booleans

* Fixed "and", "or" evaluating RHS when not required
2022-03-20 12:55:58 +11:00
Mike Farah e08b6803f5 Simplify json > yaml cli example 2022-03-20 10:58:37 +11:00
Mike FarahandGitHub 78e9cc7998 Envsubst params (#1147)
* Can give envsubst optional arguments
2022-03-20 10:56:50 +11:00
justin-f-perezandGitHub 1a964c5055 update cli help (#1146)
- remove duplicate comment
- add common use case (json -> idiomatic yml)
2022-03-20 10:54:24 +11:00
Mike Farah 0ffee92175 Fixed += with multiple matches #1145 2022-03-19 18:42:12 +11:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
99cd9e8aae Bump github.com/spf13/cobra from 1.3.0 to 1.4.0 (#1143)
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Changelog](https://github.com/spf13/cobra/blob/v1.4.0/CHANGELOG.md)
- [Commits](https://github.com/spf13/cobra/compare/v1.3.0...v1.4.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-17 21:00:40 +11:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
8cb2422b57 Bump golang from 1.17 to 1.18.0 (#1144)
Bumps golang from 1.17 to 1.18.0.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-17 20:59:46 +11:00
Mike Farah 4bb2fa1652 Updated equals doc 2022-03-16 10:16:49 +11:00
Mike Farah d27fb0ec78 Update multiply docs 2022-03-16 10:04:45 +11:00
Mikhail KatychevandGitHub 406bbb8ca4 handled EvaluateNodes panic (#1140) 2022-03-15 13:28:52 +11:00
Mike Farah 3924ed8a35 Bumping version 2022-03-10 13:50:53 +11:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
b1fee26a7f Bump actions/checkout from 2 to 3 (#1130)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-10 13:43:36 +11:00
Mike Farah 58be9829f9 Added pick operator 2022-03-10 13:39:51 +11:00
Mike Farah 33a29817d7 Can load expressions from file #1120 2022-03-01 11:50:09 +11:00
Mike Farah edbdb16ab7 Fixes auto expansion of properties #1127 2022-03-01 11:29:11 +11:00
Mike Farah 2e731c310f Updated readme 2022-02-27 12:23:36 +11:00
Mike Farah 79f2e1558c Fixed release notes 2022-02-27 12:08:04 +11:00
Mike Farah f0b37ea06d Bumping version 2022-02-27 12:03:10 +11:00
Mike Farah 8698433d44 Added line and column operators 2022-02-27 11:56:46 +11:00
Mike Farah ff047d0748 Fixes #1123 2022-02-27 11:39:31 +11:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
6c220d4562 Bump github.com/magiconair/properties from 1.8.5 to 1.8.6 (#1121)
Bumps [github.com/magiconair/properties](https://github.com/magiconair/properties) from 1.8.5 to 1.8.6.
- [Release notes](https://github.com/magiconair/properties/releases)
- [Changelog](https://github.com/magiconair/properties/blob/main/CHANGELOG.md)
- [Commits](https://github.com/magiconair/properties/compare/v1.8.5...v1.8.6)

---
updated-dependencies:
- dependency-name: github.com/magiconair/properties
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-25 08:58:01 +11:00
Mike Farah 0e0183b9ea Update load docs 2022-02-23 09:40:05 +11:00
Mike Farah 61978b34df Added load_base64 2022-02-23 09:38:17 +11:00
Mike Farah d9bca65626 Added base64 support 2022-02-23 09:26:35 +11:00
Mike Farah d7b158f855 Added string case operators 2022-02-22 16:17:23 +11:00
Mike Farah 71706af3d4 String op can now run on custom types 2022-02-22 14:50:45 +11:00
Mike Farah 8142e94349 Added reverse op 2022-02-22 14:15:31 +11:00
Mike Farah 2752544bc8 Fixed readme 2022-02-20 14:40:39 +11:00
Mike Farah 558a18029a Bumping version 2022-02-20 14:34:55 +11:00
Mike Farah 665f6b0267 Fixed self assigned issue #1107 2022-02-20 14:29:52 +11:00
Mike Farah fc447b46ce Fixed bad cature groups with multiple matches #1114 2022-02-20 13:28:13 +11:00
Mike Farah 304fc462a4 No longer auto-read from STDIN if there are files given (#1115) 2022-02-20 13:15:21 +11:00
Mike Farah 75fffc17e1 Added support for load_props, added missing load_xml tests 2022-02-15 14:51:22 +11:00
Mike Farah e1b5e90adf Update readme 2022-02-15 14:13:55 +11:00
Mike Farah 6374098cdc Bumping version 2022-02-15 13:40:47 +11:00
Mike FarahandGitHub b35893d783 Date Time Ops (#1110)
* Added datetime operators

* Added date subtract support
2022-02-14 15:37:43 +11:00
whi-twandGitHub 4b2b47af48 Fix zsh completion (#1108)
4ec533b introduced a bug which causes the 'hidden' cli parameter
`__complete` to be ignored.

Add a check for this parameter, so that it can pass to `cobra`

Signed-off-by: Tom Whitwell <tom@whi.tw>
2022-02-14 08:03:24 +11:00
Mike Farah a5f6a80cf6 Added snake_case version of camelCase operators (snake case now prefered) 2022-02-11 09:05:17 +11:00
Mike FarahandGitHub a9c3617b4f Decoder Properties (#1099)
* Decoder Properties

* Added properties round trip test

* Fixed property decode for github actions

* Refactored XML test to use common functions

* Switched formatScenario parameter order for more readablity
2022-02-10 12:02:53 +11:00
Mike Farah 4d4bd5114d Removed temporary file 2022-02-09 11:49:41 +11:00
Mike Farah bfaafa66f9 Fixed SEGV error #1096 2022-02-09 11:47:21 +11:00
Mike Farah 26356ff4be Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
Mike Farah 06e944dcb6 Added github action fix for parsing xml 2022-02-07 11:26:48 +11:00
Mike Farah 2891c6948d Added expression argument to forcibly set expression if required 2022-02-07 09:27:52 +11:00
Mike Farah 703418d0c4 Automatically add "-" when piping and its missing 2022-02-07 09:09:11 +11:00
Mike Farah 75960c6484 Allow multiple files with no expression 2022-02-07 08:23:53 +11:00
Mike Farah 5ac3c57510 Fixed bug - ignore path expressions that match a directory 2022-02-07 08:04:26 +11:00
Mike Farah 926a68181b Bumping version 2022-02-06 14:39:56 +11:00
Mike Farah 1f367ac200 Added notification banner to docs 2022-02-06 14:39:46 +11:00
Mike Farah de38abb121 Updating release notes for next release 2022-02-04 09:27:43 +11:00
Mike Farah d00153de71 Adding to array copies styling of previous elements #722 2022-02-04 09:24:48 +11:00
Mike Farah 992fe066aa Improved property conversion docs 2022-02-01 15:34:17 +11:00
Mike Farah b80080a26d Parameterised merge array by key example 2022-02-01 15:11:39 +11:00
Mike Farah 0afb59c65e Tests can have multiple env variables 2022-02-01 14:58:53 +11:00
Mike Farah 535799462f Added eval operator 2022-02-01 14:47:51 +11:00
Mike Farah 77204551ab Fixed typo in readme 2022-01-31 08:21:36 +11:00
Mike Farah 772d369058 Added notice for older versions of yq 2022-01-28 13:02:25 +11:00
Mike Farah 9b7c80a76b Bumbing version 2022-01-28 10:06:25 +11:00
Mike Farah a6fc7aa881 Updating docs 2022-01-28 10:06:25 +11:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
6f27cb93d1 Bump github.com/a8m/envsubst from 1.2.0 to 1.3.0 (#1089)
Bumps [github.com/a8m/envsubst](https://github.com/a8m/envsubst) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/a8m/envsubst/releases)
- [Commits](https://github.com/a8m/envsubst/compare/v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/a8m/envsubst
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-27 16:21:31 +11:00
Mike Farah b2a93930d0 Preparing release notes 2022-01-27 16:00:02 +11:00
Mike Farah dedd1ca892 Fixing github build 2022-01-27 15:54:26 +11:00
Mike Farah 01b4917f26 Debug github build 2022-01-27 14:22:01 +11:00
Mike Farah 25e374f4ee Debug github build 2022-01-27 14:00:55 +11:00
Mike Farah 3ba728d40c Working around github strangeness 2022-01-27 13:54:29 +11:00
Mike Farah 8761920f58 Debug github build 2022-01-27 13:24:05 +11:00
Mike Farah 394be5c65a Debug github build 2022-01-27 12:47:06 +11:00
Mike Farah 4ec533bc1b No longer have to specify eval! 2022-01-27 12:07:41 +11:00
Mike Farah fc276ff450 Smarter behaviour when piping data in with one argument 2022-01-27 10:18:46 +11:00
Mike Farah c3d815998a Auto style when adding to empty maps/arrays 2022-01-27 09:58:13 +11:00
Mike Farah 71242b0c8e Fix Seg Fault on bad split expression input #1086 2022-01-27 09:29:41 +11:00
Mike Farah a9e7f669d0 Merged envsubst into env operators 2022-01-27 09:20:53 +11:00
Samuel Cormier-IijimaandGitHub 8195ff8b9b Add a new envsubst operator to replace environment variables in strings (#1082) 2022-01-25 19:33:30 +11:00
Mike Farah 9b1a7bf451 Added support for adding objects 2022-01-23 11:35:44 +11:00
Mike Farah 9b66e0a094 Include zip file checksums in release 2022-01-23 10:45:18 +11:00
Mike Farah 6e33132de9 Added support for *= 2022-01-22 16:40:17 +11:00
Mike Farah a6c79f3410 Multiply, substract with custom types 2022-01-22 16:12:59 +11:00
Mike Farah 50df792e49 Auto cast for add 2022-01-22 13:17:16 +11:00
Mike Farah 6f24e878aa Updated README, better xml docs 2022-01-22 12:35:33 +11:00
Mike Farah a0ba208669 Bumping release 2022-01-22 11:57:19 +11:00
Mike Farah d5b0154747 Fixing manpage path issue 2022-01-22 11:56:21 +11:00
Phil MillerandGitHub 7d2ddc1cde fixes path in scripts/generate-man-page-md.sh (#1075) 2022-01-22 11:51:16 +11:00
Mike Farah 02252e8e69 Bumping version 2022-01-22 11:48:08 +11:00
Mike Farah 2526b03d67 Added JSON conversion tests and doc generation 2022-01-21 20:26:19 +11:00
Eng Zer JunandGitHub e347090571 refactor: move from io/ioutil to io and os packages (#1068)
* refactor: move from io/ioutil to io and os packages

The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* build: update snapcraft `go-channel` to 1.17

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-01-21 19:50:53 +11:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
f8bcaca4c9 Bump github.com/jinzhu/copier from 0.3.4 to 0.3.5 (#1071)
Bumps [github.com/jinzhu/copier](https://github.com/jinzhu/copier) from 0.3.4 to 0.3.5.
- [Release notes](https://github.com/jinzhu/copier/releases)
- [Commits](https://github.com/jinzhu/copier/compare/v0.3.4...v0.3.5)

---
updated-dependencies:
- dependency-name: github.com/jinzhu/copier
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-21 18:36:33 +11:00
Mike Farah de0716e875 Tweaking select docs 2022-01-15 18:22:26 +11:00
Mike Farah 21cdbab0d7 Improving select docs (#839) 2022-01-15 18:18:52 +11:00
Mike Farah 1fba46f2f7 Updated readme as per #1051 recommendations 2022-01-15 17:54:08 +11:00
Mike Farah dfe4308304 Preparing release notes 2022-01-15 17:45:45 +11:00
Mike Farah 8c94a96ee0 New merge flag (n) to only merge in new fields (#1038) 2022-01-15 15:48:34 +11:00
Mike FarahandGitHub ec8ef312ef Added XML encoding/decoding (#1067)
* Added XML encoding/decoding

* Minor fixes

* Improve yq doc

* Lint
2022-01-15 11:57:59 +11:00
Mike Farah 606ef91cc6 Better fix #1062 (return error instead of panic) 2022-01-14 15:40:24 +11:00
Mike Farah 78b45a3eb0 Fixed #1062 2022-01-14 15:22:55 +11:00
Mike Farah 84ddf1862f Fixed #1048 2022-01-14 14:55:25 +11:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2d7c63e4e4 Bump github.com/goccy/go-yaml from 1.9.4 to 1.9.5 (#1065)
Bumps [github.com/goccy/go-yaml](https://github.com/goccy/go-yaml) from 1.9.4 to 1.9.5.
- [Release notes](https://github.com/goccy/go-yaml/releases)
- [Changelog](https://github.com/goccy/go-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/goccy/go-yaml/compare/v1.9.4...v1.9.5)

---
updated-dependencies:
- dependency-name: github.com/goccy/go-yaml
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-14 13:33:30 +11:00
HélioandGitHub eac75f7dad Arch Linux install instructions (#1059) 2022-01-03 09:20:38 +11:00
robertomierandGitHub 5e30f3ba90 Update changelog for version v4.16.2 (#1046)
* Update changelog for version v4.16.2

* fix: remove useless changelog comments from debian changelog
2022-01-03 09:20:13 +11:00
robertomierandGitHub 0b49bebad9 chore: script to build the deb sources (#1045)
* chore: script to build the deb sources

now it includes the man files. This script makes only sense executing
on the machine having the gpg key needed to sign and push to ppa

* fix: dput dependency and proper configuration
2021-12-23 11:43:21 +11:00
Mike Farah c48b1612df Updating cli docs 2021-12-21 17:07:32 +11:00
Mike Farah 6763ae6e7b Added xml acceptance tests 2021-12-21 17:05:33 +11:00
Mike Farah ca1c5dab59 Can encode in XML! 2021-12-21 16:59:09 +11:00
Mike Farah 2ee9c65bc2 Added global xml prefs for simplicity 2021-12-21 16:52:54 +11:00
Mike Farah 6bcbd873a6 wip 2021-12-21 16:19:27 +11:00
Mike Farah ae8df5ea87 wip 2021-12-21 16:08:37 +11:00
Mike Farah 851a43b9b6 wip 2021-12-21 15:56:08 +11:00
Mike FarahandGitHub df32baedf1 Added XML decoder (#1044) 2021-12-21 15:02:07 +11:00
Mike Farah 915e9de437 Bumping version 2021-12-21 09:41:46 +11:00
Mike Farah 8c2dd1af07 Bump golang compiler #1037 2021-12-21 09:38:28 +11:00
Matthieu MORELandGitHub 59752fb36d enable more linters (#1043)
* enable revive linter

* enable gochecknoinits linter

* enable unconvert linter

* enable unparam linter

* enable asciicheck linter

* enable depguard linter

* enable nakedret linter

* enable megacheck linter

* enable nolintlint linter

* enable predeclared linter

* Update go.yml

* Update go.yml
2021-12-21 09:30:08 +11:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
d8abcce633 Bump github.com/spf13/cobra from 1.2.1 to 1.3.0 (#1039)
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.2.1 to 1.3.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Changelog](https://github.com/spf13/cobra/blob/master/CHANGELOG.md)
- [Commits](https://github.com/spf13/cobra/compare/v1.2.1...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-16 14:55:07 +11:00
Mike Farah ae60fb8e38 Improved extract-checksum.sh 2021-12-10 16:57:04 +11:00
Mike Farah 9e4116d845 Added script for extracting checksums 2021-12-10 15:02:59 +11:00
Mike Farah ffd1f022aa Report while filename failed to parse #1030 2021-12-06 17:25:32 +11:00
Mike Farah c17cf82791 Improving docs 2021-12-05 13:03:38 +11:00
Mike Farah b4db4496d5 Improved tips and tricks 2021-12-05 11:12:09 +11:00
Mike Farah 8b04d972f3 Improved error message 2021-12-05 10:58:26 +11:00
Mike Farah d0fda699e4 Bumping version 2021-12-04 14:00:27 +11:00
Mike Farah fa06f0aabf Updated release notes 2021-12-04 13:59:19 +11:00
Mike Farah e22df34158 Added sort_by operator 2021-12-04 13:54:12 +11:00
Mike Farah 2f05f7390f wip 2021-12-04 13:25:32 +11:00
Mike Farah 055e441686 Updated release notes 2021-12-03 09:24:22 +11:00
Mike Farah dba41ffed7 Assignment op no longer clobbers anchor (#1029) 2021-12-03 09:23:24 +11:00
Mike Farah 7d89102477 Recording release notes for next release 2021-12-02 20:09:37 +11:00
Mike Farah adb6144606 Fixed docker permission issue #1014 2021-12-02 20:06:51 +11:00
Mike Farah 855b3c4b47 Cleanup test 2021-12-02 20:06:51 +11:00
Mike Farah df5128fa36 Added encoder tests 2021-12-02 20:06:51 +11:00
Mike Farah f62cfe5ec9 Added encoder tests 2021-12-02 20:06:51 +11:00
Mike Farah d0419ceedf Added csv, tsv output formats 2021-12-02 20:06:51 +11:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3126724eaf Bump github.com/jinzhu/copier from 0.3.2 to 0.3.4 (#1027)
Bumps [github.com/jinzhu/copier](https://github.com/jinzhu/copier) from 0.3.2 to 0.3.4.
- [Release notes](https://github.com/jinzhu/copier/releases)
- [Commits](https://github.com/jinzhu/copier/compare/v0.3.2...v0.3.4)

---
updated-dependencies:
- dependency-name: github.com/jinzhu/copier
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-02 19:45:09 +11:00
Daniel J WalshandGitHub a0c2e6faf5 Add support for Podman as well as Docker (#1026)
Would like to see this package work on systems without Docker installed
which have Podman.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-12-02 10:01:44 +11:00
Mike Farah 14f8f92b76 Added map, map_values 2021-12-01 10:32:36 +11:00
Mike Farah 54b355bffb Added another test 2021-12-01 09:14:18 +11:00
Mike Farah 1c50ae4e6a Added another test 2021-11-30 13:22:18 +11:00
Mike Farah feb97c9872 Fixed collect op when working with multiple nodes 2021-11-30 13:19:44 +11:00
d41b44dc42 Add accessor for the yq logger instance (#1013)
Allow consumers of yqlib to customize the logger instance.

Closes #432

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>

Co-authored-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Co-authored-by: Rob Ferguson <robert.j.ferguson@nasa.gov>
2021-11-30 10:51:49 +11:00
Mike Farah 176fec639d Better merge example 2021-11-29 21:28:25 +11:00
Mike Farah f5f148cadb Better formatting of merge arrays example 2021-11-29 21:06:09 +11:00
Mike Farah 418bd1a806 Added credit for merge by array example 2021-11-29 20:56:04 +11:00
Mike Farah 4c7c0b83aa Better merge array by key example 2021-11-29 20:53:36 +11:00
Mike Farah 51e946e6ff Better merge array by key example 2021-11-29 20:46:12 +11:00
Mike Farah 8c5d1e0252 gci linter 2021-11-26 20:24:21 +11:00
Matthieu MORELandMike Farah 8fdf6414c1 update Golangci version to v1.43.0 2021-11-26 20:15:59 +11:00
Mike Farah cbb7fc9192 updated readme 2021-11-26 09:54:01 +11:00
Matthieu MORELandMike Farah 15d7c9e118 enable misspell linter 2021-11-25 22:01:30 +11:00
Paul SandMike Farah 3e82171f18 Clean up errored file?
Probably a leftover of shell testing?
2021-11-25 10:46:47 +11:00
Rob FergusonandMike Farah 46d1d6825f Include version query for tools 2021-11-25 10:46:39 +11:00
Mike Farah c2952d49e5 Attempt to fix golint problem 2021-11-24 11:12:47 +11:00
Mike Farah 7f5bf4b326 Bumping version 2021-11-24 10:59:31 +11:00
Mike Farah 7e09a66b0b Fixing comments 2021-11-24 10:59:19 +11:00
Mike Farah c2808dc6c1 Update release notes 2021-11-24 10:41:25 +11:00
Mike Farah 733e63d1fb Added more tests 2021-11-24 10:16:48 +11:00
Mike Farah b44fecdfa5 Added key operator 2021-11-24 09:57:35 +11:00
Mike Farah 7f629d5e36 Added errorlint to devtools 2021-11-24 09:27:17 +11:00
Matthieu MORELandMike Farah 8711042c98 enable errorlint linter 2021-11-24 09:14:02 +11:00
Ben BurkeandMike Farah 3f4bbf748d add labels, quote some values
apply some standard labels from <https://github.com/opencontainers/image-spec/blob/main/annotations.md>

quotes some secrets in case they might contain shell special characters
2021-11-22 09:47:28 +11:00
Ben BurkeandMike Farah 183007d120 simplify prod stage, move version label to action 2021-11-22 09:47:28 +11:00
AJ ONealandMike Farah 207d863edf Update install-man-page.sh 2021-11-21 17:46:49 +11:00
AJ ONealandMike Farah 2e18e2f669 feature: detect MANPATh and install there 2021-11-21 17:46:49 +11:00
Mike Farah 3d620100f8 Improved load doc 2021-11-18 17:34:08 +11:00
Mike Farah a804e7370f Minor improvement on handling front matter 2021-11-16 16:34:39 +11:00
Mike Farah fb648ceb79 Load file acceptance test 2021-11-16 16:21:08 +11:00
Mike Farah 356eff3b0b wip 2021-11-16 16:21:08 +11:00
Matthieu MORELandMike Farah 76841fab3b Update check.sh 2021-11-16 16:20:50 +11:00
Matthieu MORELandMike Farah 38855bf646 lint : define golangci configuration file
This put everything concerning golangci following [this](https://golangci-lint.run/usage/configuration/).
This way, anyone running golangci with a command line or with it's favorite Ide will use the same configuration for the current project.
2021-11-16 16:20:50 +11:00
Mike Farah a17c97b515 Bumping version 2021-11-14 11:09:53 +11:00
Mike Farah 33871bf007 Fixed header preprocessing! 2021-11-14 10:59:50 +11:00
Mike Farah 11b6261e8b remove leading content indicator 2021-11-14 10:59:50 +11:00
Mike Farah 5df71162c9 fixed printer test 2021-11-14 10:59:50 +11:00
Mike Farah 63f54563ea wip 2021-11-14 10:59:50 +11:00
Mike Farah d912d7d178 wip 2021-11-14 10:59:50 +11:00
Mike Farah bff4c9e586 Fixing bad label in github action 2021-11-10 13:27:55 +11:00
Mike Farah d7a34843af Include secure as part of build process 2021-11-10 13:27:55 +11:00
Mike Farah ac57667887 Include secure as part of build process 2021-11-10 13:27:55 +11:00
Mike Farah 69e1a9e468 add build check to PRs 2021-11-10 13:27:55 +11:00
Matthieu MORELandMike Farah e7d4dc9581 Update go.yml 2021-11-09 08:25:26 +11:00
Matthieu MORELandMike Farah b086bee7c3 Update dependabot.yml 2021-11-09 08:25:26 +11:00
dependabot[bot]Mike Farahdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
e650883cb6 Bump github.com/spf13/cobra from 1.1.3 to 1.2.1
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.1.3 to 1.2.1.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Changelog](https://github.com/spf13/cobra/blob/master/CHANGELOG.md)
- [Commits](https://github.com/spf13/cobra/compare/v1.1.3...v1.2.1)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-09 08:25:26 +11:00
dependabot[bot]Mike Farahdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
8b2c036eba Bump github.com/fatih/color from 1.10.0 to 1.13.0
Bumps [github.com/fatih/color](https://github.com/fatih/color) from 1.10.0 to 1.13.0.
- [Release notes](https://github.com/fatih/color/releases)
- [Commits](https://github.com/fatih/color/compare/v1.10.0...v1.13.0)

---
updated-dependencies:
- dependency-name: github.com/fatih/color
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-09 08:25:26 +11:00
dependabot[bot]Mike Farahdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
543da3ac2b Bump github.com/jinzhu/copier from 0.2.8 to 0.3.2
Bumps [github.com/jinzhu/copier](https://github.com/jinzhu/copier) from 0.2.8 to 0.3.2.
- [Release notes](https://github.com/jinzhu/copier/releases)
- [Commits](https://github.com/jinzhu/copier/compare/v0.2.8...v0.3.2)

---
updated-dependencies:
- dependency-name: github.com/jinzhu/copier
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-09 08:25:26 +11:00
dependabot[bot]Mike Farahdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
b175260731 Bump github.com/goccy/go-yaml from 1.8.9 to 1.9.4
Bumps [github.com/goccy/go-yaml](https://github.com/goccy/go-yaml) from 1.8.9 to 1.9.4.
- [Release notes](https://github.com/goccy/go-yaml/releases)
- [Changelog](https://github.com/goccy/go-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/goccy/go-yaml/compare/v1.8.9...v1.9.4)

---
updated-dependencies:
- dependency-name: github.com/goccy/go-yaml
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-09 08:25:26 +11:00
dependabot[bot]Mike Farahdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Matthieu MOREL
bf02a865bd Bump actions/setup-go from 1 to 2.1.4
* Bump actions/setup-go from 1 to 2.1.4

Bumps [actions/setup-go](https://github.com/actions/setup-go) from 1 to 2.1.4.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v1...v2.1.4)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matthieu MOREL <mmorel-35@users.noreply.github.com>
2021-11-09 08:25:26 +11:00
dependabot[bot]Mike Farahdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
9f9590d5c0 Bump actions/create-release from 1.0.0 to 1.1.4
Bumps [actions/create-release](https://github.com/actions/create-release) from 1.0.0 to 1.1.4.
- [Release notes](https://github.com/actions/create-release/releases)
- [Commits](https://github.com/actions/create-release/compare/v1.0.0...v1.1.4)

---
updated-dependencies:
- dependency-name: actions/create-release
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-09 08:25:26 +11:00
Matthieu MORELandMike Farah 241d0d768c Create dependabot.yml 2021-11-09 08:25:26 +11:00
Mike Farah 40ec63cb56 github action no longer uses data1.yml 2021-11-03 22:37:07 +11:00
Mike Farah 86c75f6837 Updating release instructions 2021-11-03 22:37:07 +11:00
Mike Farah 8343ff6a59 Tweaking docs 2021-11-03 22:37:07 +11:00
Mike Farah b1292270bb Updating README 2021-11-03 22:37:07 +11:00
Mike Farah 0557439765 Update document generation script 2021-11-03 22:37:07 +11:00
Mike Farah de90b3e85e gitbook wip 2021-11-03 22:37:07 +11:00
Mike Farah 2ace48c70d Bumping version 2021-10-30 14:08:13 +11:00
Mike Farah d4b9781ee6 Fixed acceptance tests 2021-10-30 14:00:28 +11:00
Mike Farah 08fc058934 Fix JSON encoding removing null #985 2021-10-30 13:37:21 +11:00
Mike Farah 2b3d0552a6 Refactored command logic 2021-10-30 13:04:05 +11:00
Mike Farah 0b2688c0f1 Split printer 2021-10-30 10:04:41 +11:00
Mike Farah 65fd001575 Improving docs 2021-10-28 09:15:28 +11:00
Mike Farah d508ac3fa4 Fixed flatten error message 2021-10-26 15:43:43 +11:00
Mike Farah 80084e89cc Added flatten operator 2021-10-26 15:42:25 +11:00
Mike Farah 2491051fd9 Added group_by operator 2021-10-26 15:13:26 +11:00
Mike Farah d390fdc641 better docs 2021-10-26 14:33:57 +11:00
Mike Farah 91717b3c5d Can specify indent in encode ops 2021-10-24 11:35:40 +11:00
Mike Farah 587af7f722 Fixed newline handling in encoder/decoder 2021-10-22 15:21:01 +11:00
Mike Farah a1af1b95d0 better docs 2021-10-22 14:55:58 +11:00
Mike Farah b1e64a0d80 Fixed newline handling when decoding/encoding 2021-10-22 14:53:39 +11:00
Mike Farah 7288d34778 Added decoder op 2021-10-22 12:37:47 +11:00
Mike Farah cdc5ef7b15 Added encoder op 2021-10-22 12:00:47 +11:00
Mike Farah 7d0376b8ee Removing no longer needed github action 2021-10-21 20:09:47 +11:00
Mike Farah 57f058555c Bumping version 2021-10-21 20:08:32 +11:00
Mike Farah d22de94e8c Updated github action release to generate man page 2021-10-21 19:59:35 +11:00
Mike Farah e8b30b1dbf Man page release workflow wip 2021-10-20 19:22:53 +11:00
Mike Farah 9c98d3effe Man page release workflow wip 2021-10-20 18:45:14 +11:00
Mike Farah ee376fdfd2 Man page release workflow wip 2021-10-20 15:01:08 +11:00
Mike Farah e5f389d0c2 Added test release flow 2021-10-20 11:11:52 +11:00
Mike Farah 7b92aa0fcf Bumping go-lang, docker versions 2021-10-20 10:58:54 +11:00
Mike Farah 5819dd0853 Fixed expression parsing bug #970 2021-10-18 11:47:03 +11:00
Mike Farah bc04873292 Man page 2021-10-18 11:03:53 +11:00
Mike Farah 7fdd205858 Updated Readme 2021-10-15 11:47:54 +11:00
Mike Farah 67541a2fe9 Keep flag, it is needed in corner cases 2021-10-15 11:47:00 +11:00
Mike Farah 0064b68ed9 Revert "Removed leadingContentPreProcessing flag - header preprocessing is stable"
This reverts commit 4ce9433468.
2021-10-15 11:47:00 +11:00
Mike Farah e741e6d52f Man page wip 2021-10-15 10:39:33 +11:00
Mike Farah 948399f163 Man page wip 2021-10-15 09:59:08 +11:00
Mike Farah 0436b77d91 Man page wip 2021-10-15 09:51:42 +11:00
Mike Farah 4ce9433468 Removed leadingContentPreProcessing flag - header preprocessing is stable 2021-10-15 08:53:00 +11:00
Peter MatseykanetsandMike Farah dd259b4957 Make deepMatch report in linear time
The current implementation of the deepMatch() has the exponential runtime.
Given the long enough input and the pattern with multiple wildcards
it takes a while if ever to complete which can potentially be used
maliciously to cause a denial of service (cpu and memory consumption).

E.g. running this in the root of this repository
time yq eval '.jobs.publishDocker.steps.[] | select (.run == "****outputs")' .github/workflows/release.yml
gives on my laptop
25.11s user 0.06s system 99% cpu 25.182 total

Whereas the updated implementation gives
0.01s user 0.01s system 36% cpu 0.049 total

There are numerous similar CVEs reported for glob evaluation in
different shells/ftp-servers/libraries.

The replacement implementation with the linear runtime is shamelessly taken
verbatim from the briliant article by Russ Cox https://research.swtch.com/glob
2021-10-14 18:45:25 +11:00
Chris KerrandMike Farah 2da2001651 Update README with recently added / changed options
In particular, remove reference to the deprecated `--tojson` option.
2021-10-14 18:40:58 +11:00
Mike Farah d363963f98 Bump version 2021-10-11 14:50:17 +11:00
Mike Farah ed4d888bfa Speed up multiply 2021-10-11 14:46:46 +11:00
Mike Farah 79bc1f95cb Slight performance improvement to context.ChildContext 2021-10-11 12:56:27 +11:00
Mike Farah 4a4aae00af Sped up explode operator 2021-10-11 10:41:15 +11:00
Mike Farah 839f795710 Fixed select bug (#958) 2021-10-07 15:04:36 +11:00
Emmanuel BourgandMike Farah e87808683a Skip the tests if the nocheck Debian build option is specified 2021-10-07 13:44:16 +11:00
Emmanuel BourgandMike Farah bec30e910f Fix a typo in root.go 2021-10-07 13:43:57 +11:00
Mike Farah b8aeb76f29 Bump version 2021-10-02 15:14:45 +10:00
Mike Farah 989b11764d Updating to go 1.17 to fix CVE #944 2021-10-02 15:12:57 +10:00
Mike Farah e052ff8025 New release with docker build fixes 2021-09-20 11:58:21 +10:00
Mike Farah 111c1a0e4a Fixed docker timeout - simplify docker builds 2021-09-20 11:57:05 +10:00
Mike Farah 222bfd3d17 Bumping version 2021-09-20 10:40:27 +10:00
Mike Farah 4123669efe Help text tweak 2021-09-20 09:57:41 +10:00
Mike Farah 7caefc8521 minor readme cleanup 2021-09-20 09:55:35 +10:00
Roberto Mier EscandonandMike Farah 91018683bf Bump deb to version 4.13.0 2021-09-17 08:44:13 +10:00
Mike Farah 282d047dc2 Added STDIN example to the top 2021-09-17 08:38:10 +10:00
Mike Farah b68e6adce9 Added STDIN example to the top 2021-09-17 08:37:28 +10:00
Mike Farah 43e40a6dda Updating with documentation 2021-09-16 10:55:26 +10:00
Mike Farah 2292f0ffb4 Fixed with semicolon space issue 2021-09-15 22:24:03 +10:00
Mike Farah 3339562aa2 Bumping version 2021-09-15 15:19:19 +10:00
Mike Farah 2db8140d7f Added contains operator 2021-09-15 15:18:10 +10:00
Mike Farah 5f154eb1b6 Update release notes 2021-09-12 21:59:57 +10:00
Mike Farah 084a0f6f1e Merge branch 'subtract' 2021-09-12 21:59:07 +10:00
Mike Farah 457c977e61 Update release notes 2021-09-12 21:53:50 +10:00
Mike Farah 6002604251 Added with operator 2021-09-12 21:52:02 +10:00
Mike Farah 0c3334d838 Draft release notes 2021-09-12 17:01:11 +10:00
Mike Farah b2ee131a4c Updated var to work like jq #934 2021-09-12 16:55:55 +10:00
Mike Farah 1cfbbde796 Added missing closing bracket error check 2021-09-12 15:49:50 +10:00
YABATANIEN, MurichadukeandMike Farah 25ba763b08 supports multiline output 2021-09-12 13:09:54 +10:00
Mike Farah 13c42db238 Adding subtraction support for arrays 2021-09-07 16:58:34 +10:00
Mike Farah 6ba8dc75a6 Bumping version 2021-09-05 11:11:51 +10:00
Mike Farah 3543a2dbdc Fixed union infinite loop #930 2021-09-05 11:07:40 +10:00
Mike Farah 8941573c1a Fixing alternative op bug #930 2021-09-02 15:36:23 +10:00
Mike Farah eea2c97cd8 Can process hex numbers 2021-09-02 15:26:44 +10:00
Mike Farah f848e334ee Clarifying readme 2021-08-27 12:30:22 +10:00
Mike Farah b72d225092 Bumping version 2021-08-27 09:33:57 +10:00
Mike Farah cb95ab1494 Fixed merge comment issue #919 2021-08-26 16:31:26 +10:00
Mike Farah 063d40de25 Fixing pipeline 2021-08-25 10:09:44 +10:00
Mike Farah fe12407c93 Bumping version 2021-08-20 16:03:59 +10:00
Mike Farah d18aa3e9e0 Added shorthand output formats 2021-08-20 15:46:33 +10:00
Mike Farah 10d4eb3381 Updated to use -o for output format 2021-08-20 13:35:57 +10:00
Mike Farah 043e9128d7 Pretty Print tests 2021-08-20 12:23:35 +10:00
Mike Farah 43f47c4ed9 wip - pretty print 1.1 compat mode 2021-08-20 12:23:35 +10:00
Mike Farah 4ba96d902b Fixed document header/footer comment handling when merging 2021-08-17 09:54:12 +10:00
Mike Farah d2e89f7c72 Updated README to include instructions on docker 2021-08-15 21:22:39 +10:00
Mike Farah 9de0d0aae1 Adding string readme 2021-08-01 18:47:04 +10:00
Mike Farah 669f6cf127 Added properties encoder test 2021-07-27 21:51:27 +10:00
Mike Farah 8c1a96d121 Properties encoder wip 2021-07-25 18:08:33 +10:00
Mike Farah b64982a487 Properties encoder wip 2021-07-25 11:43:51 +10:00
Mike Farah 9fd467590f Add github action docs to readme 2021-07-25 10:51:13 +10:00
Mike Farah 39090fcf58 updating readme 2021-07-25 10:47:53 +10:00
Mike Farah f89a133558 Version bump 2021-07-24 15:08:30 +10:00
Mike Farah d079c5709e bad github action now fails properly 2021-07-24 15:07:05 +10:00
Mike Farah 192a5ed0d2 testing bad github action fails 2021-07-24 15:06:23 +10:00
Mike Farah bdf4ad4432 testing bad github action fails 2021-07-24 15:05:42 +10:00
Mike Farah eeac03a437 Fixed merging arrays with merge anchors #899 2021-07-22 20:58:58 +10:00
Mike Farah 9ec20f8ba2 Added more tests 2021-07-20 11:14:54 +10:00
Mike Farah b2380399a8 Added more tests 2021-07-20 11:12:41 +10:00
Mike Farah 66b248ac18 Version bump 2021-07-20 11:05:22 +10:00
Mike Farah 3b91ad5764 Handle leading comment with no new-line 2021-07-20 11:01:56 +10:00
Mike Farah 8508d3309b More efficient front matter processor 2021-07-20 10:38:42 +10:00
Mike Farah 4e628327c4 Better way of processing leading content 2021-07-20 10:19:55 +10:00
Mike Farah bbebebe30c Fixed for most cases, except strip comments 2021-07-20 09:18:40 +10:00
Mike Farah 38dd4175fb Added more tests 2021-07-19 20:18:42 +10:00
Mike Farah dafa114e65 Added printer tests 2021-07-19 20:12:04 +10:00
Mike Farah 519cf1dcd7 wip 2021-07-19 19:58:47 +10:00
Mike Farah 3a6f73e836 wip 2021-07-19 19:52:51 +10:00
Mike Farah 85bbbbeed4 shellcheck 2021-07-18 17:05:12 +10:00
Mike Farah 7474ac62ef Now using shunit2 for acceptance tests 2021-07-18 16:55:08 +10:00
Mike Farah 4c288e8d90 Removed blank file disclaimer 2021-07-18 15:39:28 +10:00
Mike Farah 102e7e7ab0 Version bump 2021-07-18 13:45:21 +10:00
Mike Farah 9c8253b582 Front matter processor seems to be working! 2021-07-18 13:17:35 +10:00
Mike Farah 555ad0762c Added front-matter handler 2021-07-18 12:28:46 +10:00
Mike Farah f6e2ab5cef Remember comments in empty files 2021-07-16 22:08:22 +10:00
Mike Farah 28a8721f49 Handle empty files 2021-07-16 21:08:20 +10:00
Mike Farah a13617407e Fixed EOF bug when processing empty files 2021-07-16 20:56:22 +10:00
Mike Farah 171ca2e053 Improving reg ex doc 2021-07-16 10:18:25 +10:00
Mike Farah 2f0fe8aa13 Increment version 2021-07-16 10:09:12 +10:00
Mike Farah b76c9f6e57 added more readme disclaimers 2021-07-16 10:06:28 +10:00
Mike Farah 8e72f65ddc fixing github flow 2021-07-16 09:59:47 +10:00
Mike Farah 19baeec5c9 set github default user 2021-07-16 09:58:40 +10:00
Mike Farah 19fb1044b7 testing github action 2021-07-16 09:44:50 +10:00
Mike Farah d74bb8e28d Adding magic to detect leading seperators 2021-07-15 11:34:49 +10:00
Mike Farah 5c0a5bd9d3 Added capture regex operator 2021-07-11 11:08:18 +10:00
Mike Farah 3394feee0d Added test for #878 2021-07-09 15:58:33 +10:00
Mike Farah b9d01f1e95 Added test operator 2021-07-09 15:54:56 +10:00
Mike Farah 69c45ff64a Added match operator 2021-07-09 15:33:41 +10:00
Mike Farah 573618e4ce (wip) regex match op 2021-07-09 14:58:31 +10:00
Mike Farah cc7ea83506 (wip) regex match op 2021-07-09 14:58:31 +10:00
Mike Farah cae3d95fdc Clean up cli help doc, add github and doc links 2021-07-09 14:58:09 +10:00
Mike Farah 21e2fdaea2 Bump version 2021-07-08 10:27:57 +10:00
Mike Farah bae319ab7f Revert usage of filepath.Clean (azure compatability issues) 2021-07-08 10:26:35 +10:00
Mike Farah 38ce8618e1 Revert "Fix for gosec rule G304 - sanitize filepaths"
This reverts commit ffb6cbf769.
2021-07-08 10:14:01 +10:00
Mike Farah 90708c010c Updated docker instructions 2021-07-08 10:02:23 +10:00
Mike Farah b4ce50b705 Fixed secure script to run against all files 2021-07-07 20:06:14 +10:00
Mike Farah aba950a751 Bump version 2021-07-07 20:01:41 +10:00
Mike Farah cce3af001a Extract out compound assign logic, use it add and subtract ops 2021-07-07 20:00:46 +10:00
Mike Farah b4b2e1217a Added another |= example 2021-07-07 19:53:33 +10:00
Mike Farah b0074f5eba Fixes #870 2021-07-07 19:22:55 +10:00
Mike Farah 542efd8928 Update append array docs 2021-07-07 15:36:43 +10:00
Mike Farah ce3e347157 Fixed append array issue https://github.com/mikefarah/yq/issues/874 2021-07-07 15:30:45 +10:00
Mike Farah d1b6a6fdd9 Fixed merge bug https://github.com/mikefarah/yq/issues/880 2021-07-07 14:29:24 +10:00
Roberto Mier EscandonandMike Farah f285a684ec Update debian pkg files to version 4.9.6 2021-07-07 13:52:42 +10:00
Monica DebbelerandMike Farah ffb6cbf769 Fix for gosec rule G304 - sanitize filepaths 2021-07-07 13:52:11 +10:00
Monica DebbelerandMike Farah f67a83a5bc Fix for gosec rule G104 - handle errors 2021-07-07 13:50:04 +10:00
Mike Farah 6658a93e7d powershell issues 2021-06-25 13:20:13 +10:00
Andrew StribblehillandMike Farah d61b9cab65 Checksum archives as well as binaries
Often, checksums are based on the archive files. This gives some measure of confidence that the file won't exploit a tar or zip vulnerability.
2021-06-22 08:47:43 +10:00
Daniel VystrcilandMike Farah 5df0e49b1e Update Dockerfile
Adding group:user to fix (CIS_Docker_v1.2.0 - 4.1) Image should be created with a non-root user
2021-06-18 12:18:47 +10:00
Mike Farah 4a08ca6e29 Updating release instructions 2021-06-18 12:13:15 +10:00
Mike Farah 4bb2d04d43 Increment version 2021-06-12 16:40:42 +10:00
Alec ThomasandMike Farah 9e61f88dba Add darwin/arm64 builds 2021-06-12 16:39:06 +10:00
Mike Farah da47318f42 Fixed newline issue https://github.com/mikefarah/yq/issues/855 2021-06-12 08:26:27 +10:00
Mike Farah 88bee2809f Fixed issue on creating objects using [] 2021-06-11 14:27:44 +10:00
Daniel VystrcilandMike Farah 01267d062b Update Dockerfile
Alpine 3.15.5 has fixes for CVE-2021-30139, CVE-2021-28831, CVE-2021-23840, and CVE-2021-3450
2021-06-10 10:56:43 +10:00
Mike Farah cb912ca188 Added more tests 2021-06-10 09:53:50 +10:00
Mike Farah 58c63ed121 Bumping version 2021-06-10 09:37:08 +10:00
Mike Farah d1548ead71 Fixed alternative operator 2021-06-10 09:35:07 +10:00
Mike Farah 09c5ed24be Updating docs 2021-06-10 08:35:41 +10:00
Mike Farah 78af68f436 Added nested traversal examples 2021-06-10 08:31:26 +10:00
Mike Farah b6e2a96ead Increment version 2021-06-09 08:59:27 +10:00
Mike Farah 5f5c832570 Moved GithubAction docs to gitbook 2021-06-09 08:57:42 +10:00
Chris GruelandMike Farah 1a49f5222b outputs support in the action 2021-06-09 08:49:04 +10:00
Mike Farah 01e478e81d Fixing entries test 2021-06-08 21:50:14 +10:00
Curtis VogtandMike Farah ed377a032d Add with_entries example using filtering 2021-06-08 21:38:54 +10:00
Mike Farah fae2b2643c Added gofmt to format command 2021-06-01 10:52:14 +10:00
Mike Farah dd86b5e7f2 Fixing doc 2021-05-28 17:00:25 +10:00
Mike Farah f1f75683c1 Fixed nil RHS bug in alternative operator #838 2021-05-28 16:59:02 +10:00
Mike Farah 38b9856f50 Increment version 2021-05-22 08:24:08 +10:00
Mike Farah 48eeb2a9df Fixes update-assign with collect object issue #830 2021-05-22 08:22:45 +10:00
Mike Farah af283315f2 Increment version 2021-05-21 14:27:24 +10:00
Mike Farah d18a6963f6 Fixes nested array indexing #824 2021-05-21 14:18:24 +10:00
Mike Farah 77edbb9f5c Fixing readonly ops not to modify context when paths dont exist 2021-05-16 15:02:31 +10:00
Mike Farah 179c44aacc Fixing readonly ops not to modify context when paths dont exist 2021-05-16 14:36:13 +10:00
Mike Farah bc70c1fb16 Added blank alias example 2021-05-16 14:18:18 +10:00
Mike Farah 0b71a40797 Fixing readonly ops not to modify context when paths dont exist 2021-05-16 14:17:13 +10:00
Mike Farah 3f51a44596 Fixing readonly ops not to modify context when paths dont exist 2021-05-16 14:00:30 +10:00
Mike Farah afebf0e621 Increment version 2021-05-16 12:43:26 +10:00
Mike Farah dc464a5b10 Added ability to escape double quotes in double quotes 2021-05-16 12:38:17 +10:00
Mike Farah 5340ed0ad3 Fixed handling of null expressions in equals op 2021-05-16 12:38:17 +10:00
Mike Farah 7b52c5fe0e Increment version 2021-05-14 15:04:56 +10:00
Mike Farah f4392f8658 Added any_c and all_c operators 2021-05-14 15:03:28 +10:00
Mike Farah 8e14b3b393 Added any and all operators 2021-05-14 14:29:55 +10:00
Mike Farah 8627441705 Added unique operator 2021-05-14 09:43:52 +10:00
Mike Farah aa95ecd012 Update operator docs 2021-05-11 14:35:59 +10:00
Mike Farah a2bd463a91 Fixed null issue with entry operators 2021-05-10 10:42:43 +10:00
Mike Farah 6c3965dca3 Increment version 2021-05-10 09:39:59 +10:00
Mike Farah bb3ffd40b5 Added optional traverse flag 2021-05-09 15:36:33 +10:00
Mike Farah cc08afc435 Added with_entries 2021-05-09 15:12:50 +10:00
Mike Farah 941a453163 Added from_entries op 2021-05-09 14:18:25 +10:00
Mike Farah 77630ca179 Added to_entries op 2021-05-09 13:59:23 +10:00
Mike Farah ae4b606707 Fixed merge anchor bug #800 2021-05-09 13:26:02 +10:00
Mike Farah 37f3e21970 Fixed boolean op with empty context issue 2021-05-09 12:44:05 +10:00
Mike Farah 25d0787011 updating operator docs 2021-05-05 15:03:27 +10:00
Mike Farah b5b8da0a1d Updating comment docs 2021-04-29 13:18:57 +10:00
Mike Farah fa21510194 Moved multiply doc example lower 2021-04-29 12:03:56 +10:00
Mike Farah f541194250 Added complex merge example 2021-04-28 20:35:10 +10:00
Mike Farah 38666f4db6 Added another style example for doc 2021-04-26 14:18:18 +10:00
Mike Farah 8b327d0414 Increment version 2021-04-25 12:07:22 +10:00
Mike Farah c8630fe4f3 Fixes delete issue #793 2021-04-25 12:05:56 +10:00
Mike Farah 87df9b1ae6 Updating operator doc 2021-04-24 17:41:06 +10:00
Mike Farah 2483c38eeb Added command help about using stdin 2021-04-19 10:27:01 +10:00
Mike Farah b2a538bdfc Better string sub documentation 2021-04-16 16:07:40 +10:00
Mike Farah 6c26344449 Incrementing version 2021-04-15 16:22:24 +10:00
Mike Farah daf0bfe1b9 Added string substitute command 2021-04-15 16:09:47 +10:00
Mike Farah 750a00ec35 Added "expand" to explode docs for searchability 2021-04-13 13:59:26 +10:00
Mike Farah 25e0a824c5 Fixed alternative operator when LHS has empty matches 2021-04-13 10:53:46 +10:00
Mike Farah 095f921f62 4.6.3 release 2021-03-25 08:45:59 +11:00
Mike Farah 12d3425b4a Added subtract operator (numbers only) 2021-03-25 08:12:01 +11:00
Mike Farah 0249f00bd5 Added chocolate badges thanks @adriens 2021-03-23 20:40:39 +11:00
Mike Farah 42b1bf9678 updated release notes to run gosec manually 2021-03-19 13:41:56 +11:00
Mike Farah c632fd3641 cannot run gosec on all docker platforms, removing from devtools 2021-03-19 13:40:24 +11:00
Mike Farah 0470e5cd69 cannot run gosec on all docker platforms, removing for now 2021-03-19 13:21:07 +11:00
Mike Farah 35c6d07248 Bump version 2021-03-19 12:59:00 +11:00
Mike Farah 3f0be107d4 Bump dependencies 2021-03-19 12:58:43 +11:00
Mike Farah 21a9e506cb Fixed merge comments 2021-03-19 12:54:03 +11:00
Mike Farah 3722367fbb Dont print doc separators for JSON (https://github.com/mikefarah/yq/issues/735) 2021-03-19 12:40:56 +11:00
Mike Farah f7b50e9853 Fixed += operator (https://github.com/mikefarah/yq/issues/750) 2021-03-19 12:36:05 +11:00
Mike Farah 4f3fe256aa Fixed precedence of CREATE_MAP (https://github.com/mikefarah/yq/issues/753) 2021-03-19 12:09:32 +11:00
Mike Farah 2595a929c9 Fixing doc links 2021-03-19 11:52:13 +11:00
Mike Farah b2186d5404 Added gosec 2021-03-03 19:44:34 +11:00
Mike Farah e93c43f7a0 Improving docs 2021-02-26 11:31:43 +11:00
Mike Farah b1a5387cdd Update readme 2021-02-25 17:04:08 +11:00
Mike Farah 5911ab2929 Bump version 2021-02-25 16:52:49 +11:00
Mike Farah 2ed5b2ff59 Improved lexer performance! 2021-02-25 16:47:55 +11:00
Mike Farah 111c6e0be1 Increment version 2021-02-18 11:19:16 +11:00
Mike Farah 81136ad57e Arrays no longer deeply merge by defauly, like jq 2021-02-18 11:16:54 +11:00
Mike Farah a6cd250987 nicer reduce example 2021-02-15 18:23:50 +11:00
Mike Farah ee1f55630f nicer reduce example 2021-02-15 17:33:41 +11:00
Mike Farah 9072e8d3b3 Added context variable for reduce 2021-02-15 17:31:12 +11:00
Mike Farah 99b08fd612 Added reduce examples and doc 2021-02-15 16:38:53 +11:00
Mike Farah b2317a14ef infix reduce 2021-02-15 16:06:37 +11:00
Mike Farah 3e5f7b147f infix reduce 2021-02-15 15:31:55 +11:00
Mike Farah c4faa70143 wip - reduce! 2021-02-15 14:27:00 +11:00
Mike Farah 4d6d07ec43 Force re-release 2021-02-11 10:58:40 +11:00
Mike Farah bd0818c481 Fixed write-inplace with no expression 2021-02-11 10:58:40 +11:00
Ben MossandMike Farah 26742b2597 Fix pretty-printing
Fixes #716 #715
2021-02-11 10:58:40 +11:00
Mike Farah 64c618c041 Version increment 2021-02-11 10:58:40 +11:00
Mike Farah c4c8e5e7b0 Preserve comments on map keys 2021-02-11 10:58:40 +11:00
Mike Farah e02ad4d7e8 Added space example to docs 2021-02-11 10:58:40 +11:00
Mike Farah dd17f072cf update deps 2021-02-11 10:58:40 +11:00
Mike Farah 429c3ca65b Fixed merge dropping anchors 2021-02-11 10:58:40 +11:00
Mike Farah cfcac6d1dc improving docs 2021-02-11 10:58:40 +11:00
Mike Farah a5ddbca97f Fixing special character example 2021-02-11 10:58:40 +11:00
Mike Farah 30027a8cf4 Added not equals operator 2021-02-11 10:58:40 +11:00
Mike Farah f92a42e4f8 Equals now only compares scalars 2021-02-11 10:58:40 +11:00
Mike Farah 3c466dc66e Fixed delete bug 2021-02-11 10:58:40 +11:00
Mike Farah 0816e16d30 fixed instructions 2021-02-11 10:58:40 +11:00
Mike Farah 802d54e14e v4.5.0 2021-02-11 10:58:40 +11:00
Mike Farah 10600dd29a Fixed delete bug 2021-02-11 10:58:40 +11:00
Mike Farah 3a464272d4 Added variable doc 2021-02-11 10:58:40 +11:00
Mike Farah 691efadfac Fixed variable precedence 2021-02-11 10:58:40 +11:00
Mike Farah 6efe4c4797 Fixing op precedences 2021-02-11 10:58:40 +11:00
Mike Farah 9e56b364c2 Fixing op precedences 2021-02-11 10:58:40 +11:00
Mike Farah 85ec32e3db Added variables 2021-02-11 10:58:40 +11:00
Mike Farah 5c73132c8e Dont create entries when selecting 2021-02-11 10:58:40 +11:00
Mike Farah c6efd5519b Pass context through operators
Allows more sophisticated functionality
2021-02-11 10:58:40 +11:00
Mike Farah 3bae44be68 Added funding button 2021-02-11 10:58:40 +11:00
zyandMike Farah 48a7c59c4b change version from master to latest(v4) 2021-02-11 10:58:40 +11:00
zyandMike Farah 851fbd8cf5 fix: go install fails
Installation by go will result in an error:
module declares its path as: xxx,
but was required as: xxx.

Go install with master branch will fix it.

fix: #676
2021-02-11 10:58:40 +11:00
Mike Farah 820a3320be Fixed length of null to be zero 2021-02-11 10:58:40 +11:00
Mike Farah 61f569aebb fixing docker pipeline for nextime 2021-02-11 10:58:40 +11:00
Mike Farah 9ff51cd066 attempt to fix dockre 2021-02-11 10:58:40 +11:00
Mike Farah 9dd6d11362 Fixed bad docker version 2021-02-11 10:58:40 +11:00
Mike Farah 83139e21d9 Bump version 2021-02-11 10:58:40 +11:00
Mike Farah c77001f969 Can add and merge append to null 2021-02-11 10:58:40 +11:00
evnpandMike Farah 1be3b31bbc Don't escape HTML chars when converting to json
json.Encoder and json.Marshal implicitly use HTMLEscape to convert
>, <, &, with \u003c, \u003e, \u0026. This behavior carries over
to yq, where chars will be escaped when outputting json but not when
outputting yaml.

This changeset disables this behavior via encoder.SetEscapeHTML(false).
Unfortunately there is no equivalent option for json.Marshal, so its
single usage has been replaced with an encoder (with escaping disabled).
2021-02-11 10:58:40 +11:00
Mike Farah 6c14a80991 Fixed cross-function combinatorial bug 2021-02-11 10:58:40 +11:00
Mike Farah 76bd1896e9 wip 2021-02-11 10:58:40 +11:00
Mike Farah c63801a8a5 thoughts 2021-02-11 10:58:40 +11:00
Mike Farah f7cfdc29e1 cross function fix wip 2021-02-11 10:58:40 +11:00
Mike Farah 07c6549a58 Fixed doker instructions 2021-02-11 10:58:40 +11:00
Mike Farah 29f40dad59 Fixing multiply doc 2021-02-11 10:58:40 +11:00
Mike Farah fe33e7fcfe Incrementing version 2021-02-11 10:58:40 +11:00
Mike Farah 0707525b29 Added keys operator 2021-02-11 10:58:40 +11:00
Mike Farah 62acee54c3 Added split string operator 2021-02-11 10:58:40 +11:00
Mike Farah d21c94cf4f Added join strings operator 2021-02-11 10:58:40 +11:00
Mike Farah 626e9cacaf Split doc operator 2021-02-11 10:58:40 +11:00
Mike Farah 02ef99560d Fixing add,multiply,alternative operator precendences 2021-02-11 10:58:40 +11:00
Mike Farah c59209f041 Fixed remove comments example 2021-02-11 10:58:40 +11:00
Mike Farah 947ffb6986 Dont use pointer for env prefs (avoid nil) 2021-02-11 10:58:40 +11:00
Mike Farah 1a03031297 Dont use pointer for recursive prefs (avoid nil) 2021-02-11 10:58:40 +11:00
Mike Farah 2c7db0071a Dont use pointer for multiply prefs (avoid nil) 2021-02-11 10:58:40 +11:00
Mike Farah 0484d0232b Dont use pointer for commment prefs (avoid nil) 2021-02-11 10:58:40 +11:00
Mike Farah 91c72d2d9e Added merge if empty 2021-02-11 10:58:40 +11:00
Mike Farah 09ec740d45 Added operator level doc 2021-02-11 10:58:40 +11:00
Mike Farah 532dbd81a5 Incrementing version 2021-02-11 10:58:40 +11:00
Mike Farah e86f83fb69 Renaming pathtree to expression 2021-02-11 10:58:40 +11:00
Mike Farah 7d5b6b5442 Removed global vars 2021-02-11 10:58:40 +11:00
Mike Farah b749973fe0 UnwrapDoc now private 2021-02-11 10:58:40 +11:00
Mike Farah ba223df4ac Moved eval function to eval interface 2021-02-11 10:58:40 +11:00
Mikhail KatychevandMike Farah e6336bcb85 added lib_test.go 2021-02-11 10:58:40 +11:00
Mikhail KatychevandMike Farah 9ae03e0a1c added EvaluateNodes and EvaluateCandidateNodes to yqlib 2021-02-11 10:58:40 +11:00
Mike Farah 55712afea6 Merge now copies anchor names 2021-02-11 10:58:40 +11:00
Mike Farah 7518dac99c Fixed creation of candidateNode in operators to include file metadata 2021-02-11 10:58:40 +11:00
Mike Farah 49ac2bac13 Cleaning up exposed public api 2021-02-11 10:58:40 +11:00
Mike Farah e28df367eb Fixed tag operator for top level node 2021-02-11 10:58:40 +11:00
Mike Farah 90ec05be54 Fixed equals operator for top level node 2021-02-11 10:58:40 +11:00
Mike Farah 8f5270cc63 Fixed has operator for top level node 2021-02-11 10:58:40 +11:00
Mike Farah 286590b01e fixing exposed functions and interfaces 2021-02-11 10:58:40 +11:00
Mike Farah c1cf8b4e34 fixing exposed functions and interfaces 2021-02-11 10:58:40 +11:00
Mike Farah 461661112c Better add documentation 2021-02-11 10:58:40 +11:00
Mike Farah 578f2c27f9 Added scalar addition 2021-02-11 10:58:40 +11:00
Mike Farah 6ed037a9f6 Fixed collect at document level 2021-02-11 10:58:40 +11:00
Mike Farah 69386316f3 Better error handling will empty env 2021-02-11 10:58:40 +11:00
Mike Farah a0e1f65b20 Better recursive decent docs 2021-02-11 10:58:40 +11:00
Mike Farah 8027f4c568 Better docIndex docs 2021-02-11 10:58:40 +11:00
Mike Farah b13eb7083e Better env docs 2021-02-11 10:58:40 +11:00
Mike Farah b505240d09 Merged env commands in :eye-roll: 2021-02-11 10:58:40 +11:00
Mike Farah 7a184bef78 Env Ops! 2021-02-11 10:58:40 +11:00
Mike Farah 34bc33d5c5 strenv 2021-02-11 10:58:40 +11:00
Mike Farah 4d8b64d05c wip 2021-02-11 10:58:40 +11:00
Mike Farah 2d9cc3c107 wip 2021-02-11 10:58:40 +11:00
Mike Farah 018a6e616d Bump version 2021-02-11 10:58:40 +11:00
Mike Farah 7fa2b20b48 Error when passing files and using null-input flag 2021-02-11 10:58:40 +11:00
Mike Farah 316e0d4d5a Bumped go yaml for comment hanlding fixes 2021-02-11 10:58:40 +11:00
Mike Farah a0d4c51e27 Added webi 2021-02-11 10:58:40 +11:00
Mike Farah ceff2cc18d Added recurse examples 2021-02-11 10:58:40 +11:00
Mike Farah db62a16007 Added another delete example 2021-02-11 10:58:40 +11:00
Mike Farah 2a6e423d2d Can assign-update tag 2021-02-11 10:58:40 +11:00
Mike Farah 5a1b81cbfc Can assign-update style 2021-02-11 10:58:40 +11:00
Mike Farah 8c1f7dfbd7 Can assign-update aliases and anchors 2021-02-11 10:58:40 +11:00
Mike Farah 2e81384eed Can assign-update comments 2021-02-11 10:58:40 +11:00
Mike Farah fbf36037c9 updating readme 2021-02-11 10:58:40 +11:00
Mike Farah 2957210e65 brew v3! 2021-02-11 10:58:40 +11:00
Mike Farah bde419aaee Updated collect objcet doc 2021-02-11 10:58:40 +11:00
Mike Farah 9b185a4409 Added shorthand document index selection 2021-02-11 10:58:40 +11:00
Mike Farah 0c777a4967 Unwrap node in get tag to return proper tag at root level 2021-02-11 10:58:40 +11:00
Mike Farah e9591e0cd5 Added v3 snap instructions 2021-02-11 10:58:40 +11:00
Mike Farah 04491e13c3 Refactored doc generation, add fi fileIndex alias 2021-02-11 10:58:40 +11:00
Mike Farah 5aff50a345 Fixed updating yaml from other files 2021-02-11 10:58:40 +11:00
Mike Farah 90d55fb52a update issue template, instruct questions to be raised in disussion 2021-02-11 10:58:40 +11:00
Mike Farah e6f97518f3 fixed heading 2021-02-11 10:58:40 +11:00
Mike Farah f4a44e7313 added tar.gz instructions 2021-02-11 10:58:37 +11:00
Mike Farah edb5f213d7 updating readme 2020-12-31 09:22:22 +11:00
Mike Farah 5cfd9b05ee updating readme 2020-12-31 09:22:18 +11:00
jonatasrenanandMike Farah 0e764c59ce wget version var missing a 'v' prefix. 2020-12-31 08:59:38 +11:00
Mike Farah 1b887e23b3 scripts/check works for local and docker build 2020-12-30 10:40:41 +11:00
Chris WarthandMike Farah a76b72e691 find golangci_lint through PATH 2020-12-30 10:30:53 +11:00
Mike Farah 9509831cff Updated docs 2020-12-29 22:35:57 +11:00
Mike Farah e92180e89d updated release instructions 2020-12-29 09:59:16 +11:00
Mike Farah a6ae33c3f1 Cleaning up release process, fixed github action version 2020-12-29 09:50:21 +11:00
Mike Farah 94a563dfd8 Updated docs 2020-12-28 11:57:20 +11:00
Mike Farah 0328cfd619 Added prettyPrint flag 2020-12-28 11:40:41 +11:00
Mike Farah 88663a6ce3 Added recurse keys operator 2020-12-28 11:24:42 +11:00
Mike Farah b10a9ccfc6 Removed TraversePrefs 2020-12-28 10:29:43 +11:00
Mike Farah 9e9e15df73 More scenarios 2020-12-27 23:00:46 +11:00
Mike Farah 6cc6fdf322 Cleaning code 2020-12-27 22:56:15 +11:00
Mike Farah a88c2dc5d3 Traverse Array Operator 2020-12-27 22:48:20 +11:00
Mike Farah ea231006ed Refactoring traverse 2020-12-27 09:55:08 +11:00
Mike Farah 80f187f1a4 Refactoring traverse 2020-12-27 09:51:34 +11:00
Mike Farah 98e8b3479f Fixed nested array splat path 2020-12-25 12:49:05 +11:00
Mike Farah eb539ff326 Fixed doc links 2020-12-23 10:37:51 +11:00
Mike Farah c09f7aa707 Cleaning up docs 2020-12-23 10:30:13 +11:00
Mike Farah 7f5c380d16 v4.1.0 2020-12-23 10:23:54 +11:00
Mike Farah 6a05e517f1 Updated release instructions, remove gate for release 2020-12-23 10:23:09 +11:00
Mike Farah 8ee6f7dc1a fixing xcompile for git action 2020-12-22 22:50:01 +11:00
Mike Farah 8bd54cd603 fixing xcompile for git action 2020-12-22 22:31:28 +11:00
Mike Farah f2f7b6db0f only tar executable files 2020-12-22 20:50:52 +11:00
Mike Farah e082fee5d4 Fixed rhash call 2020-12-22 20:37:35 +11:00
Mike Farah 412911561f Fixed xcompile.sh 2020-12-22 20:23:13 +11:00
Mike Farah 52ae633cb7 trialing github release actions 2020-12-22 20:05:23 +11:00
Mike Farah 9356ca59bb trialing github release actions 2020-12-22 20:03:01 +11:00
Mike Farah 6dec167f74 trialing github release actions 2020-12-22 20:01:21 +11:00
Mike Farah 00f6981314 trialing github release actions 2020-12-22 19:56:56 +11:00
Mike Farah 4c60a2a967 trialing github release actions 2020-12-22 19:52:44 +11:00
Mike Farah f4529614c4 trialing github release actions 2020-12-22 19:19:48 +11:00
Mike Farah f059e13f94 automated docker releases! 2020-12-22 16:16:31 +11:00
Mike Farah 4dbf158505 playing with release action 2020-12-22 16:01:00 +11:00
Mike Farah 39a93a2836 playing with release action 2020-12-22 16:00:15 +11:00
Mike Farah 7c158fce26 playing with release action 2020-12-22 15:58:56 +11:00
Mike Farah 0bf43d2a55 playing with release action 2020-12-22 15:47:59 +11:00
Mike Farah 1b0bce5da6 Added alias operator;
alias, anchor and explode ops are now all documented together
2020-12-22 12:23:13 +11:00
Mike Farah f112bde5fe Added anchor operator 2020-12-22 11:57:41 +11:00
Mike Farah e5aa4a87a4 fixed test name 2020-12-22 11:47:58 +11:00
Mike Farah f305e8fa12 Fixed delete full path 2020-12-22 11:45:51 +11:00
Mike Farah d2d0c2c111 Added missing flag 2020-12-22 10:40:20 +11:00
Mike Farah 2aab79431c moved string space test to op values test cases 2020-12-22 10:38:52 +11:00
djajcevicandMike Farah 540d4953f5 #607 Fix string value with spaces error 2020-12-22 10:29:21 +11:00
Mike Farah 7849232255 tar files to keep permissions of exectuable 2020-12-22 10:25:15 +11:00
Mike Farah 57cd67f055 Added compressed binaries for download managers and better file size 2020-12-21 21:40:08 +11:00
Mike Farah 6b17fd4fc1 Added trivy to docker build, bumped alpine image 2020-12-21 15:48:25 +11:00
Mike Farah ca8cd78616 Add now uses crossFunction 2020-12-21 11:54:03 +11:00
Mike Farah 9876b0ce8f Boolean operators now use the crossFunction util func 2020-12-21 11:42:35 +11:00
Mike Farah a23272727d Added Alternative op 2020-12-21 11:32:34 +11:00
Mike Farah 1fb37785d6 Better readme 2020-12-20 13:34:58 +11:00
Mike Farah efb9027540 Merge branch 'v4' 2020-12-20 13:31:23 +11:00
Mike Farah 2577fe5425 Increment version 2020-12-20 13:29:12 +11:00
Mike Farah f39c57fed9 Updating readme for imminent v4 release 2020-12-20 12:39:42 +11:00
Mike Farah 1e8f755e7c Updating readme for imminent v4 release 2020-12-20 12:37:15 +11:00
Mike Farah bb088f6aa2 Added better error reporting 2020-12-17 14:19:46 +11:00
Mike Farah a96b74e779 Added better error reporting 2020-12-17 14:02:54 +11:00
Mike Farah 09a9e1e7f0 handle multiple document streams 2020-12-15 14:33:50 +11:00
Mike Farah db60746e4e Can now properly handle .a[] expressions 2020-12-09 12:15:14 +11:00
Shashank VeerapaneniandMike Farah 8846255d1c Update README.md
Fix the wget download command
2020-12-02 19:42:05 +11:00
Mike Farah a3e422ff76 added another test 2020-12-01 18:10:10 +11:00
Mike Farah 2c3357702d clarified pipe parsing tests 2020-12-01 18:08:41 +11:00
Mike Farah c9dbf04da3 Added pipe and length docs, fix pipe precedence 2020-12-01 17:58:07 +11:00
Mike FarahandGitHub fbe53885ae Update README.md 2020-12-01 17:24:14 +11:00
Mike Farah da027f69d7 updated cobra package 2020-12-01 16:16:20 +11:00
Mike Farah 8cd290c00b incrementing version 2020-12-01 15:15:12 +11:00
Mike Farah 363fe5d283 Added sort keys operator 2020-12-01 15:06:54 +11:00
Mike Farah 773b1a3517 fixed create doc for eval-all 2020-12-01 14:23:27 +11:00
Mike Farah cf4915d786 improved acceptance tests 2020-12-01 14:14:16 +11:00
Mike Farah 08f579f4e3 Fixed create yaml 2020-12-01 14:06:49 +11:00
Mike Farah c9229439f7 added exit status 2020-11-30 16:35:21 +11:00
Mike Farah 9bc66c80b6 Added write-inlplace flag 2020-11-30 16:05:07 +11:00
Mike Farah 8de10e550d wip - write in place 2020-11-29 20:25:47 +11:00
Mike Farah 1258fa199e Updated lib todo list 2020-11-28 11:25:10 +11:00
Mike Farah 3a030651a3 Added append equals, merge append. Fixed creating numeric arrays 2020-11-28 11:24:16 +11:00
Mike Farah 3f48201a19 wip 2020-11-28 10:46:04 +11:00
Mike Farah 3cecb4e383 wip 2020-11-28 10:41:09 +11:00
Mike Farah 13679e51e2 Added get key examples 2020-11-26 11:20:53 +11:00
Mike Farah f42728eef7 updated issue templates 2020-11-25 22:33:50 +11:00
Mike Farah 93136ba840 updated issue templates 2020-11-25 22:32:47 +11:00
Mike Farah 5665dc7b71 updated issue templates 2020-11-25 22:31:55 +11:00
Mike Farah 9302279dd2 updated issue templates 2020-11-25 22:22:16 +11:00
Mike Farah 5205f01248 Fixed recursive decent on empty objects/arrays 2020-11-25 15:01:12 +11:00
Mike Farah 0a66bb797d 4 alpha2 2020-11-25 13:32:32 +11:00
Mike Farah 5972bb2f23 attempt to fix pipeline 2020-11-25 11:17:28 +11:00
Mike Farah ec43f5e7c3 go mod tidy 2020-11-25 11:06:43 +11:00
Mike Farah 1ce30b25dc Add operator! 2020-11-24 13:07:19 +11:00
Mike Farah 3d6a231722 Added has operator 2020-11-24 11:38:39 +11:00
Mike Farah 3f04a1b52e Fixed empty array op 2020-11-22 13:50:32 +11:00
Mike Farah aed598c736 Fixing docs 2020-11-22 13:16:54 +11:00
Mike Farah e9fa873af8 path operator singular 2020-11-22 12:22:15 +11:00
Mike Farah 064cff1341 added path operator! 2020-11-22 12:19:57 +11:00
Mike Farah fc3af441e5 Extracted out evaluators 2020-11-22 11:56:28 +11:00
Mike Farah e451119014 Added File operators 2020-11-20 23:08:12 +11:00
Mike Farah d38caf6bc2 Added File operators 2020-11-20 22:57:32 +11:00
Mike Farah 4e385a1b93 get file wip 2020-11-20 15:50:15 +11:00
Mike Farah 356aac5a1f fixed boolean example 2020-11-20 15:33:21 +11:00
Mike Farah 663413cd7a Fixed typo 2020-11-20 15:31:49 +11:00
Mike Farah f03005f86d Fixed boolean ops 2020-11-20 15:29:53 +11:00
Mike Farah bc87aca8d7 wip 2020-11-20 14:35:34 +11:00
Mike Farah 62f262147c Attempt to fix git pipeline 2020-11-20 14:00:24 +11:00
Mike Farah 0259bb44c1 Updated readme 2020-11-20 13:55:18 +11:00
Mike Farah c08980e70f Set entrypoint to yq 2020-11-20 13:53:44 +11:00
bahetiamitandMike Farah e07a5b6065 Adding github action on release to publish multi-arch image 2020-11-20 13:48:35 +11:00
Mike Farah f69a81b79b Updated readme re v4 2020-11-19 22:56:13 +11:00
Mike Farah 9674acf684 Fixed docker file, fixed doco 2020-11-19 22:53:05 +11:00
Mike Farah 8e1ce4ca70 Updated todo 2020-11-19 22:12:34 +11:00
Mike Farah 9bd9468526 Minor fixes 2020-11-19 22:11:26 +11:00
Mike Farah 75044e480c Added plain assignment 2020-11-19 17:08:13 +11:00
Mike Farah 36084a60a9 Added tag operator 2020-11-19 16:45:05 +11:00
Mike Farah 9b48cf80e0 updated todo 2020-11-18 20:43:36 +11:00
Mike Farah bb3b08e648 wip style docs and test 2020-11-18 20:42:37 +11:00
Mike Farah dcacad1e7e docs 2020-11-18 10:32:30 +11:00
Mike Farah 3356061e1e select doc 2020-11-18 09:52:03 +11:00
Mike Farah 2c062bc2a5 Added printer test 2020-11-18 09:52:03 +11:00
Mike Farah 088ec36acd include docs for tracking 2020-11-18 09:50:52 +11:00
Mike Farah 83cb6421df added test to ensure json keys remain in order 2020-11-17 16:17:38 +11:00
Mike Farah a57944d123 Fixed printer 2020-11-16 12:09:57 +11:00
Mike Farah 79867473d5 updating release 2020-11-16 10:28:57 +11:00
Mike Farah b3efcdc202 more docs 2020-11-15 10:58:47 +11:00
Mike Farah af2aa9ad91 more docs 2020-11-15 10:50:30 +11:00
Mike Farah db4762ef7c more docs 2020-11-14 13:38:44 +11:00
Mike Farah 860655b4cd Better documentation generation 2020-11-13 21:34:43 +11:00
Mike Farah d91b25840a Better documentation generation 2020-11-13 21:22:05 +11:00
Mike Farah 019acfe456 Better documentation generation 2020-11-13 20:58:01 +11:00
Mike Farah af39fc737d Fixed linting 2020-11-13 14:07:11 +11:00
Mike Farah f8a700e400 Alpha1 of v4! 2020-11-13 13:35:59 +11:00
Mike Farah 708ff02e8d Fixed collect object for multi doc 2020-11-13 13:19:54 +11:00
Mike Farah 2edf64182b refining 2020-11-06 14:37:01 +11:00
Mike Farah b290a65602 document index 2020-11-06 12:11:38 +11:00
Mike Farah 05520c2168 more tests 2020-11-06 11:45:18 +11:00
Mike Farah 5ab584afac comment ops! 2020-11-06 11:23:26 +11:00
Mike Farah b1f139c965 refactored 2020-11-04 10:48:43 +11:00
Mike Farah 0cb2ff5b2e explode when outputting to json 2020-11-02 13:55:03 +11:00
Mike Farah d6ff198d63 explode! 2020-11-02 13:43:45 +11:00
Mike Farah e515b8c2db got style 2020-11-02 11:20:52 +11:00
Mike Farah b63b9644aa multiply merge anchors 2020-10-30 12:40:44 +11:00
Mike Farah 461c3e719c merge anchors! 2020-10-30 12:00:48 +11:00
Mike Farah 643f2467ee simple anchors 2020-10-30 10:56:45 +11:00
Mike Farah 4edb3e9021 create object fixes 2020-10-28 13:00:26 +11:00
Mike Farah 41c08891d3 create object fixes 2020-10-28 11:34:01 +11:00
Mike Farah 85d059340b first cli 2020-10-27 16:45:16 +11:00
Mike Farah badd476730 collect object operator! 2020-10-21 13:54:51 +11:00
Mike Farah 65e6e492cd wip 2020-10-21 12:54:58 +11:00
Mike Farah 6a698332dd more 2020-10-20 16:27:30 +11:00
Mike Farah 49615f5581 Added null 2020-10-20 15:40:11 +11:00
Mike Farah 4f574efdc4 simplified, refactored 2020-10-20 15:33:20 +11:00
Mike Farah ccb718cd0f Moved macports to community, announced v4 2020-10-20 13:58:45 +11:00
Mike Farah 73cf6224f2 wip 2020-10-20 13:53:26 +11:00
Herby GillotandMike Farah 815edef86a README: add instructions for installing with MacPorts 2020-10-20 13:50:10 +11:00
Mike Farah 4bc98776a6 wip 2020-10-19 20:05:38 +11:00
Mike Farah 1910563bfe merge 2020-10-19 16:36:46 +11:00
Mike Farah 2ddf8dd4ed autovivification, merge! 2020-10-19 16:14:29 +11:00
Mike Farah cd83d94b6a updating release instructions 2020-10-19 09:01:52 +11:00
Mike Farah 6afc2e9189 3.4.1 2020-10-19 08:40:59 +11:00
Mike Farah 49b810cedd Multiply wip 2020-10-19 08:36:33 +11:00
Mike Farah 391ab8d70c removed docs, added recursive decent 2020-10-18 11:31:36 +11:00
Mike Farah b026ebf2c3 more refinement 2020-10-17 22:58:18 +11:00
Mike Farah 5e544a5b7e value parse test 2020-10-17 22:39:01 +11:00
Mike Farah 60511f5f92 refactoring, fixing 2020-10-17 22:10:47 +11:00
Mike Farah 59296b7d12 can assign children! 2020-10-16 12:49:15 +11:00
Mike Farah fccd03036f can assign values 2020-10-16 12:47:31 +11:00
Mike Farah 6829d8cb78 JQ like syntax wip 2020-10-16 12:29:26 +11:00
Mike Farah 449fb8952c adding pipe 2020-10-13 14:37:01 +11:00
Mike Farah afffb2c3ba collect 2020-10-13 14:04:21 +11:00
Mike Farah 829ca3b424 read tests 2020-10-13 13:17:18 +11:00
Mike Farah d19e9f6917 read command 2020-10-13 12:51:37 +11:00
Mike Farah 6a0a4efa7b added single count operator 2020-10-12 12:24:59 +11:00
Mike Farah 288aec942c ops first class 2020-10-12 10:46:54 +11:00
Mike Farah 7c4cf72468 wip 2020-10-12 10:09:13 +11:00
Mike Farah b025000f20 cool, both work 2020-10-11 11:46:07 +11:00
Mike Farah 1ba1e90e58 dont splat scalars 2020-10-11 11:45:20 +11:00
Mike Farah e0d1aed5b9 Refactoring 2020-10-11 11:24:22 +11:00
Mike Farah e6fd6905eb wip 2020-10-10 23:04:10 +11:00
Mike Farah 0a2a3c4374 can delete 2020-10-10 22:42:09 +11:00
Mike Farah ac076cd34a assign operator 2020-10-10 15:24:37 +11:00
Mike Farah 8170eec6d1 extracted out operators 2020-10-10 15:00:39 +11:00
Mike Farah 23083ed974 fixed equals number issue 2020-10-09 17:07:53 +11:00
Mike Farah 93aaa8ccee array equals! 2020-10-09 16:43:43 +11:00
Mike Farah d7716551cf arrays 2020-10-09 16:38:07 +11:00
Mike Farah c791e5c663 equal! 2020-10-09 15:06:01 +11:00
Mike Farah a6d4dbb8b8 equal! 2020-10-09 15:05:45 +11:00
Mike Farah c7ebdda530 added AND op 2020-10-09 12:10:46 +11:00
Mike Farah a0d940638c use orderermap 2020-10-09 12:04:19 +11:00
Mike Farah c09513803a wip 2020-10-09 11:37:47 +11:00
Mike Farah f95226e267 ops work in theory! 2020-10-09 11:10:37 +11:00
Mike Farah f479a7e8e3 wip 2020-10-09 10:59:03 +11:00
Mike Farah f7d4695837 binary tree ftw 2020-10-09 08:51:14 +11:00
Mike Farah 5ee52f9506 wip 2020-10-09 08:51:14 +11:00
Mike Farah c2159d9861 postfix with traverse op 2020-10-09 08:51:14 +11:00
Mike Farah 95bc1e1599 include traverse as a operator token 2020-10-09 08:51:14 +11:00
Mike Farah e037c57725 postfix wip! 2020-10-09 08:51:14 +11:00
Mike Farah e32bc43c4e postfix wip! 2020-10-09 08:51:14 +11:00
Mike Farah a8bdc12d83 to postfix wip 2020-10-09 08:51:14 +11:00
Mike Farah ae59ad57f4 tree wip 2020-10-09 08:51:14 +11:00
Mike Farah c321600afa fixed wrapping! 2020-10-09 08:51:14 +11:00
Mike Farah 4c95efa469 wip 2020-10-09 08:51:14 +11:00
Morgan BazalgetteandMike Farah 996ee0b433 add test for key order 2020-10-09 08:38:42 +11:00
Morgan BazalgetteandMike Farah bb9cb0c60e fix tests 2020-10-09 08:38:42 +11:00
Morgan BazalgetteandMike Farah a125495eec keep order of keys when json marshalling 2020-10-09 08:38:42 +11:00
Peter BenjaminandMike Farah 7fa2835e13 fix(image): bump alpine image minor version
This is to patch a high security vulnerability.
Closes #550

Signed-off-by: Peter Benjamin <petermbenjamin@gmail.com>
2020-10-08 12:29:04 +11:00
Mike FarahandGitHub e0f5cb3c59 Update README.md
Fixing alpine instructions
2020-10-01 09:20:32 +10:00
Mike Farah 87550b7fe5 Show errors on validate 2020-09-21 20:34:29 +10:00
Mike Farah 5554301c29 Updated install instructions, added wget 2020-09-21 11:06:57 +10:00
Mike Farah 3b0aaac626 Added checksum hashes order to release 2020-09-18 16:37:45 +10:00
Mike FarahandGitHub 65cb472604 Update README.md 2020-09-16 15:43:08 +10:00
Mike FarahandGitHub fbba38c9b7 Update README.md 2020-09-16 15:42:09 +10:00
Mike Farah e5948c4f16 Fixed potential npe 2020-09-13 12:14:20 +10:00
Mike Farah 4eaadf98d0 Set STDOUT to default out when printing via cobra 2020-09-13 11:49:55 +10:00
Mike Farah eedbb0a99f Explode anchors now applies to map keys too 2020-09-13 11:26:07 +10:00
Mike Farah 7dabc57b65 Added array update merge example 2020-09-13 11:12:52 +10:00
Mike Farah fcd3a90f67 Bumping minor version to indicate new merge features and slight backwards incompatibility 2020-09-13 11:06:56 +10:00
Mike Farah 88e99e5336 New line in docs for better readability 2020-09-13 11:04:48 +10:00
Mike Farah a8cfccd3af Merge master fix 2020-09-13 10:59:40 +10:00
Mike Farah 3355e80d85 Merge branch 'master' into new-merge2 2020-09-13 10:52:31 +10:00
Mike Farah f528b28938 Convert to JSON now handles non string keys 2020-09-13 10:44:22 +10:00
Mike Farah 5b7b390a33 Force static linking 2020-09-13 10:32:45 +10:00
Mike Farah 4f12e09e78 More info on other installation methods 2020-09-13 10:16:24 +10:00
Mike Farah ee732fbf0b Added Alpine Linux instructions 2020-09-13 10:09:02 +10:00
Mike Farah 1507f929a2 Fixing version stuffup - now 3.3.4 2020-09-11 11:11:49 +10:00
Mike Farah c11c3df84f Version 3.2.3 2020-09-09 12:02:30 +10:00
Mike Farah 06bb3ac826 Can create new yaml files using scripts again 2020-09-09 11:02:00 +10:00
Mike Farah 778f8c6916 Removed doctools 2020-09-08 13:03:18 +10:00
Mike Farah 9f43a4a265 Keep comments when using the write commandt o update values 2020-09-08 09:46:04 +10:00
Mike Farah bb6f07d147 Use latest go-lang 2020-09-08 09:43:11 +10:00
Mike Farah 759456e375 Lib version bumps 2020-09-08 09:13:57 +10:00
Mike FarahandGitHub 5e59803037 Update README.md 2020-09-03 10:58:00 +10:00
Roberto Mier EscandonandMike Farah a0cb691601 Bump version to 3.3.2 2020-08-16 13:02:07 +10:00
Mike Farah fea8510061 Added comments merge strategy 2020-07-17 15:51:03 +10:00
Mike Farah b380ea2892 better array merge strategy name 2020-07-17 13:27:27 +10:00
Mike Farah d66a709213 refactored array merge flags into a strategy 2020-07-17 13:26:20 +10:00
Mike Farah 2fc39b3865 Can overwrite arrays when merging 2020-07-17 13:07:32 +10:00
Mike Farah ee07edbd88 Added merge alias test 2020-06-18 09:56:36 +10:00
Mike Farah b11661a1be Refactored merge - will allow more sophisticated mergin 2020-06-18 09:44:36 +10:00
Mike Farah eac218980e Visit document node 2020-06-18 09:03:40 +10:00
Mike Farah 80e7f46538 Dont log mergePathStackToString - end up with duplicate logs 2020-06-18 09:03:40 +10:00
Mike FarahandGitHub 086f0ec6b9 Update bug_report.md 2020-06-15 21:42:26 +10:00
Mike Farah 89cbe63343 Fixed deep read at root level 2020-06-15 12:31:13 +10:00
RyderXiaandMike Farah 07cd3d4b8b return error 2020-06-13 16:45:52 +10:00
RyderXiaandMike Farah b7b6988e76 mk TempDir 2020-06-13 16:45:52 +10:00
Mike Farah 9de2039c31 Version bump 2020-06-12 12:23:18 +10:00
Mike Farah 767709fef5 Fixed error flag 2020-06-12 12:21:46 +10:00
Mike Farah d9ae8e1e5a Updated readme 2020-06-12 09:30:05 +10:00
Mike Farah b0fa0e5b86 added shell completion instructions 2020-06-11 18:50:38 +10:00
Mike Farah 6777d639c0 Fixed error handling 2020-06-11 18:30:45 +10:00
Mike Farah de8dcff803 Added shell completions 2020-06-11 18:27:01 +10:00
Mike Farah 765ada4dc6 Bumping version 2020-06-11 15:01:18 +10:00
Mike Farah 1405584892 New,Update now support anchors and aliases 2020-06-11 13:57:13 +10:00
Mike Farah 8c9c326342 Usage error messages now go to StdErr 2020-06-11 10:14:33 +10:00
Mike Farah e90b00957b Added missing flow style 2020-06-11 09:58:10 +10:00
Mike Farah 71f5f76213 Delete now works with deep splat 2020-06-11 09:53:36 +10:00
Mike Farah b9e304e7a4 Can stripComments and explodeAnchors for compare 2020-06-11 09:13:55 +10:00
Mike Farah d473c39a44 Added exit flag 2020-06-10 16:55:20 +10:00
Mike Farah 9624410add Significantly improved performance of exploding anchors (improves to json speed) 2020-06-10 16:36:33 +10:00
Mike Farah b55fe48bd8 Update to latest go-yaml library, updated test w.r.t. formatting and comment handling fixes 2020-06-10 16:02:12 +10:00
adripoandMike Farah 721dd57ed4 Fixed typo
removed repeated word
2020-06-02 09:02:20 +10:00
Roberto Mier EscandonandMike Farah 6fc3566acd Changelog updated for version 3.3-0 2020-05-01 10:31:53 +10:00
Mike Farah 4b63d92a3c Added choco install instructions 2020-04-22 23:29:44 +10:00
M. MinotandMike Farah 3ccd32a47e docs(readme): protect parameter expansions
Avoid unwanted word-splitting, including in the working directory path.
2020-04-19 00:18:08 +10:00
Mike Farah 3f913afbb9 Fixed cli doco 2020-04-18 08:23:38 +10:00
Mike Farah ff598e1933 Increment version 2020-04-17 17:28:41 +10:00
Mike Farah 23de61a8d7 Can now update tag/style of nodes without affecting the value 2020-04-17 17:09:33 +10:00
Mike Farah 64135a16e1 Use single/double instead of singleQuoted/doubleQuoted 2020-04-17 11:24:45 +10:00
Mike Farah 06d8715cbe Added customStyle flag, split command tests 2020-04-17 11:03:43 +10:00
Mike Farah e15633023f Increment version 2020-04-16 15:29:58 +10:00
Mike Farah 6f0a329331 Fixed inplace errors clearing out original file 2020-04-15 11:48:42 +10:00
apenavandMike Farah 55511de9af Upgrade yq_dev container to golang:1.14 base container and deb packages to python3 2020-04-15 09:07:40 +10:00
Mike Farah 2db69c91c9 Added strip comments functionality 2020-04-14 14:48:45 +10:00
Mike Farah 33e35d10dd Dont unwrap json output by default 2020-04-14 14:11:44 +10:00
Mike Farah dfdbbbb24a Added unwrap flag 2020-04-14 13:48:25 +10:00
Mike Farah 55c4d01a91 Update deps 2020-04-14 11:39:08 +10:00
Mike Farah 7dc3d62bb6 Attempt to fix github flow 2020-04-14 11:33:25 +10:00
Mike Farah 11116804c5 Upgrade to git 1.14 2020-04-14 11:19:00 +10:00
Mike Farah f68b24323e Attempt to fix git workflow action 2020-04-14 11:18:45 +10:00
Mike Farah 8f166a9848 Fixed negative index bug 2020-04-14 11:17:29 +10:00
Mike Farah 3c36db9285 Split github actions pipeline 2020-04-14 09:22:38 +10:00
Mike Farah 605d6fab9b Try newest golang version 2020-04-13 11:05:36 +10:00
Mike Farah 1f9a3f5f6c Added negative index capability 2020-04-13 10:36:46 +10:00
Mike Farah a06320f13c Attempt to fix snapcraft 2020-03-04 15:32:26 +11:00
Mike Farah 279996533d Adding sourcetype to snapcraft yml 2020-03-04 15:21:09 +11:00
Mike Farah efe942727d Bump snapcraft go version 2020-03-02 09:36:03 +11:00
Mike Farah e4dc70cc84 Fixing github action description 2020-03-02 08:47:19 +11:00
Mike Farah 8ade1275e2 Fixing github action description 2020-03-02 08:43:47 +11:00
Mike Farah e1e05d85e3 Added another multistring test 2020-03-01 17:21:04 +11:00
Mike Farah b99467432e Fixed readme links 2020-03-01 17:15:32 +11:00
Mike Farah 6b07143af7 Fixed printing of scalars 2020-03-01 17:13:00 +11:00
Mike Farah ed234e37ce Better action description 2020-02-29 18:22:52 +11:00
Mike Farah c0e4917d52 Better action description 2020-02-28 19:43:32 +11:00
Mike Farah 2713893f87 Added icon and color to github action 2020-02-28 16:42:18 +11:00
Mike Farah 6bb221e973 3.2.0 2020-02-28 16:35:45 +11:00
Mike Farah 7eb01a81da Shorter colors flag 2020-02-28 15:57:44 +11:00
Mike Farah 5c117204fa Shorter colors flag 2020-02-28 15:57:05 +11:00
Mike Farah a4fa8f1341 Compare returns exit code 1 when not matching 2020-02-28 15:49:34 +11:00
Mike Farah 69caccd2d3 Added another scenario for find by value 2020-02-28 15:28:37 +11:00
Mike Farah 67fb924e0e Can find array elements bu value 2020-02-28 15:24:16 +11:00
Mike Farah b64187fe32 Dont recurse into scalar nodes
Fixes https://github.com/mikefarah/yq/issues/375
2020-02-28 15:03:56 +11:00
Mike Farah 8e6ceba2ac Array length and collect 2020-02-28 14:03:40 +11:00
Mike Farah 6ef04e1e77 wip 2020-02-28 14:03:40 +11:00
Mike Farah 10029420a5 wip 2020-02-28 14:03:40 +11:00
Mike Farah f91093d5fe Colors work for all commands 2020-02-28 10:42:19 +11:00
Risent VeberandMike Farah 090432d241 add colorization 2020-02-28 10:42:19 +11:00
Mike Farah 22d5bd3615 Show github build status 2020-02-26 21:14:15 +11:00
Mike Farah 0d477841da Show github build status 2020-02-26 21:13:39 +11:00
Mike Farah 1f72817d74 Removing travis integration - use github 2020-02-26 21:11:27 +11:00
Mike Farah 125d04a75b Attempt to fix git workflow 2020-02-26 11:03:05 +11:00
chocolatey030@gmail.comandMike Farah 08f6a90603 [GH-371] cleaned up go modules using 'go mod tidy' 2020-02-26 10:44:03 +11:00
Pascal SochackiandMike Farah da398765b8 added files for github action 2020-02-26 09:09:37 +11:00
Roberto Mier EscandonandMike Farah d356fa0d0b Bump debian package to version 3.1-2
Updated all files to be more Debian compliant
Update release instructions for get mod vendor before releasing
2020-02-25 08:57:41 +11:00
Roberto Mier EscandonandMike Farah d22bfc241b Add changelog 2020-02-25 08:57:41 +11:00
Mike FarahandGitHub 954affea23 Create go.yml 2020-02-21 21:19:09 +11:00
Mike FarahandGitHub b0d1afb601 Update CONTRIBUTING.md 2020-02-21 21:16:47 +11:00
Mike FarahandGitHub b286636909 Create CODE_OF_CONDUCT.md 2020-02-21 21:13:14 +11:00
Mike Farah bdf47c9797 Separated contribution notes 2020-02-21 21:12:09 +11:00
Mike FarahandGitHub 1cc20d52bb Create CONTRIBUTING.md 2020-02-21 21:11:34 +11:00
Mike Farah 651d9edf88 Updating readme 2020-02-21 21:08:28 +11:00
Mike Farah 903605df39 Updating readme 2020-02-21 21:07:59 +11:00
Mike FarahandGitHub 0f9facc84b Update issue templates 2020-02-21 21:04:54 +11:00
Mike FarahandGitHub 5af86b1333 Update issue templates 2020-02-21 21:00:36 +11:00
Mike Farah 2bd2a85a4c Fixed trailing empty docs 2020-02-21 11:37:59 +11:00
Mike Farah ceb76e5c17 Fixed trailing empty docs 2020-02-21 11:34:26 +11:00
Mike Farah 44322f0248 Fixed writing to null document 2020-02-21 11:02:10 +11:00
Mike Farah 0347516d82 Always print new line so wc works properly 2020-02-21 10:29:37 +11:00
Mike Farah a46386e093 Fixed special characters in path for merging 2020-02-18 20:18:49 +11:00
Mike Farah f5c3beb159 Added test for https://github.com/mikefarah/yq/issues/361 2020-02-18 20:02:09 +11:00
Mike Farah 9864afc4e7 Fixed empty merge problem 2020-02-18 09:15:46 +11:00
Roberto Mier EscandonandMike Farah 69fae2d9cb Inc Deb version 2020-02-17 09:29:02 +11:00
Mike Farah 83c13ce392 Fixed empty merge problem - need to visit empty arrays and objects 2020-02-13 14:56:58 +11:00
Mike Farah d83c46eec2 Uncomment line in publish script 2020-02-13 10:22:52 +11:00
Mike Farah 65802f9e0e updated readme 2020-02-12 16:28:24 +11:00
Mike Farah 07309e1685 Inc snapcraft version 2020-02-12 16:27:25 +11:00
Mike Farah 24e906bae6 Fixed numeric map key issue 2020-02-12 15:40:21 +11:00
Mike Farah f084f2bb23 Inc version for next release 2020-02-12 12:04:41 +11:00
Mike Farah 96a4161a92 Fixed explode anchors for array roots 2020-02-12 11:03:40 +11:00
Mike Farah 5cc01e43bc Can supply value for write from file 2020-02-08 14:04:54 +11:00
Mike Farah 9de2573009 Fixed merge append arrays 2020-02-07 16:32:39 +11:00
Mike Farah 29521f2e3e Simplified when to visit a node 2020-02-07 14:52:37 +11:00
Mike Farah af5724ba29 Updated readme 2020-02-07 11:28:56 +11:00
Mike Farah 0a39d29c53 Updated readme 2020-02-07 11:26:29 +11:00
Mike Farah 72cd3e4a2a Fixed explode for aliases to scalars 2020-02-07 10:42:07 +11:00
Mike Farah d40ad9649d Fixed explode for aliases to scalars 2020-02-07 10:09:20 +11:00
Mike Farah 63313ebb02 Merge branch 'coryrc-fix-merge-with-dots' into compare 2020-02-07 09:10:25 +11:00
Mike Farah de3bfaef60 Merge branch 'fix-merge-with-dots' of git://github.com/coryrc/yq into coryrc-fix-merge-with-dots 2020-02-07 09:09:52 +11:00
Mike Farah 108b5cb093 Fixed explode for simple anchors 2020-02-07 09:08:52 +11:00
Mike Farah b116f40348 Major version bump for new features 2020-02-06 12:20:51 +11:00
Cory Cross ea9df0eede Fix path generation when merging file has period in key
The program generates a path for every leaf node in the
file-to-be-merged. It does not escape them if they contain a dot, as
the path-expressions document mentions is necessary.

Add in a test for this condition. Verified it fails without the fix.
2020-02-04 22:37:00 -08:00
Mike Farah b7dd3e8e0a Added explode test 2020-02-05 15:08:13 +11:00
Mike Farah dc13fa99f7 wip: explode anchors 2020-02-05 14:10:59 +11:00
Mike Farah 179049a535 Always allow empty 2020-02-04 14:42:08 +11:00
Mike Farah 2fa8b24272 Can merge one file 2020-02-04 14:33:35 +11:00
Mike Farah f1dbe13f21 Can write and merge into empty files :) 2020-02-04 14:21:54 +11:00
Mike Farah 02258fbaae Fixed deep splatting merge anchors - dont visit twice 2020-02-04 14:10:12 +11:00
Mike Farah 6f0538173b Fix delete adding entries 2020-02-04 09:58:20 +11:00
Mike Farah 6840ea8c78 can set indent levels 2020-02-03 16:56:01 +11:00
Mike Farah 70b88fa778 Pretty print everything test 2020-02-03 16:40:17 +11:00
Mike Farah bfc1a621c4 Pretty print everything 2020-02-03 16:37:53 +11:00
Mike Farah 166f866f28 Pretty print json 2020-02-03 16:31:03 +11:00
Mike Farah b3598aaa43 Updated readme 2020-02-03 16:21:00 +11:00
Mike Farah 14ac791eaf Fixed compare output, added tests 2020-02-03 15:35:00 +11:00
Mike Farah 25293a6894 Check write errors 2020-02-03 14:28:38 +11:00
Mike Farah d828b214cc More powerful compare 2020-02-03 14:15:12 +11:00
Mike Farah 9e47685271 Compare first cut 2020-02-03 13:59:16 +11:00
Mike Farah 699fce9da4 Added default value flag - for printing out a value when reading and there are no matches 2020-02-03 10:13:48 +11:00
Mike Farah f52de57652 Don't fail when reading an empty file 2020-02-03 09:15:16 +11:00
Mike Farah b7554e6e76 Pretty print disclaimer 2020-01-31 16:37:24 +11:00
Mike Farah ec25511f1b Pretty print 2020-01-31 16:35:01 +11:00
Mike Farah c6a52012ab Prefer download binary 2020-01-31 10:37:27 +11:00
Mike Farah 63ded205e8 Added docs for validate 2020-01-31 10:32:44 +11:00
Mike Farah d1c1ab0a75 Added validate command 2020-01-30 16:34:43 +11:00
Mike Farah 6ec8386f9e Fixed bad yaml handling 2020-01-30 16:32:28 +11:00
Mike Farah 4dbe3636c2 Splat array is now the fallback instead of parsing int 2020-01-30 15:11:47 +11:00
Mike Farah 4a5bd0ff5b No need to log error 2020-01-30 15:00:27 +11:00
Mike Farah 44f36833cf Fixed delete array pattern matching 2020-01-30 14:55:58 +11:00
Mike Farah 789ea02096 Merge branch 'v3' 2020-01-30 13:01:16 +11:00
Mike Farah 7c27491dd6 Removed user docs 2020-01-30 10:32:34 +11:00
Mike Farah 720cc8f798 Update cli docs 2020-01-30 09:58:21 +11:00
Mike Farah abda0e38af Removed unused dep 2020-01-22 16:39:41 +11:00
Mike Farah 5cd4c347b0 Updated user docs link 2020-01-22 16:25:52 +11:00
Mike Farah 1a4d8158ba Removed custom value parsing logic 2020-01-20 08:42:08 +11:00
Mike Farah 8a65822b0b Updated docs to include value parsing 2020-01-20 08:35:03 +11:00
Ryan SIUandMike Farah b7148adf20 #323 Fix the unit test 2020-01-15 14:02:48 +11:00
Ryan SIUandMike Farah 64d38e9f03 #323 Refactor the cobra command with standard structure 2020-01-15 14:02:48 +11:00
Mike Farah 3a387e65be Updated travis ci build 2020-01-15 09:02:06 +11:00
Mike Farah 56ba7c9a43 Updated travis ci build 2020-01-15 09:01:08 +11:00
Mike Farah d203ec7b56 Accidently changed sample.yaml 2020-01-15 08:55:01 +11:00
Mike Farah e2f79a3dae bolden contribute disclaimer 2020-01-13 19:45:24 +11:00
Mike Farah 2d7be26ad5 wip update docs 2020-01-13 16:58:11 +11:00
Mike Farah 350a8343e9 adv search with prefix! 2020-01-11 19:52:33 +11:00
Mike Farah a3f8f9df10 more bits 2020-01-11 19:38:16 +11:00
Mike Farah 35fd5b7ae4 Extracted out is path expression checking logic 2020-01-11 19:30:27 +11:00
Mike Farah 2d237e7e8e it works! wip 2020-01-11 19:13:52 +11:00
Mike Farah 74c7a4e027 it works! wip 2020-01-11 18:52:15 +11:00
Mike Farah f18c5161e0 Fixed sponge instructions 2020-01-11 16:01:32 +11:00
Mike Farah eeeeeffd7b Added note about v3 2020-01-11 11:44:02 +11:00
Mike Farah 96955ffa9c release notes 2020-01-11 09:55:24 +11:00
Mike Farah 9361b8b3e9 Beta 2020-01-11 09:14:32 +11:00
Mike Farah 24dcb56466 Inc version - fix help text 2020-01-11 09:13:42 +11:00
Mike Farah 728cbe991a Print path is more accurate than keys (i think) 2020-01-11 09:07:39 +11:00
Mike Farah 854f5f0fc9 wip json encoding 2020-01-10 22:01:59 +11:00
Mike Farah feba7b04fa Added path stack to string test 2020-01-09 21:36:05 +11:00
Mike Farah 0621307391 Fixed linting errors 2020-01-09 21:27:52 +11:00
Mike Farah 924eb6c462 Added missing functions to interface 2020-01-09 21:18:24 +11:00
Mike Farah 52eef67e37 more tests, some refactoring 2020-01-09 08:17:56 +11:00
Mike Farah 38d35185bc Can overwrite and append with merge 2020-01-06 16:27:00 +13:00
Mike Farah d8c29b26c1 Merge can allow empty merges! 2020-01-06 16:22:24 +13:00
Mike Farah e3f4eedd51 Fixed merge new array 2020-01-06 10:12:38 +13:00
Mike Farah 690da9ee74 Fixed merge new array 2020-01-06 10:12:30 +13:00
Mike Farah 1f7f1b0def Merge arrays! 2020-01-05 17:28:24 +13:00
Mike Farah 1aa5ec1d40 Merge! wip 2020-01-05 17:14:14 +13:00
Mike Farah a065a47b37 Fixed tests 2020-01-05 16:22:18 +13:00
Mike Farah 625cfdac75 wip; 2019-12-31 15:21:39 +13:00
Mike Farah 4dbdd4a805 Deep splat! 2019-12-30 16:51:07 +13:00
Mike Farah 8a6af1720d Fixed modify array issue! 2019-12-30 11:21:21 +13:00
Mike Farah 0652f67a91 Refactored! 2019-12-28 20:19:37 +13:00
Mike Farah df52383ffb Delete works! needs refactor 2019-12-28 10:51:54 +13:00
Mike Farah 707ad09ba5 Refactor wip 2019-12-27 19:06:58 +11:00
Mike Farah cf389bed4a Refactor wip 2019-12-27 19:06:08 +11:00
Mike Farah ff5b23251b Refactor wip 2019-12-25 12:11:04 +11:00
Mike Farah 9925b26b9d Added Key and Value printing tests 2019-12-24 10:46:21 +11:00
Mike Farah 93dbe80a77 wip 2019-12-24 10:35:57 +11:00
Mike Farah 27604289f4 Log out original error if removing temporary file failed 2019-12-23 12:09:38 +11:00
Mike Farah 3f36a18791 Add readme notice re v3 2019-12-23 10:01:55 +11:00
Mike Farah 1e541cd65f wip handle aliases when printing keys 2019-12-23 09:25:44 +11:00
Mike Farah 5204a13685 Show paths 2019-12-23 09:08:00 +11:00
Mike Farah 3d3eaf3034 Return path, smart print 2019-12-22 17:16:03 +11:00
Mike Farah 4fb44dbc47 Return path, smart print 2019-12-22 17:13:11 +11:00
Mike Farah 784513dd18 Merge anchors - refactored 2019-12-22 15:35:16 +11:00
Mike Farah 865a55645c Merge anchors - refactored 2019-12-22 15:33:54 +11:00
Mike Farah 949bf1c1d7 Merge anchors - wip 2019-12-22 15:15:15 +11:00
Mike Farah 19fe718cfb Aliases! 2019-12-16 21:09:23 +11:00
Mike Farah 290579ac7f Handle simple aliases 2019-12-16 20:38:55 +11:00
Mike Farah d7392f7b58 Refactoring 2019-12-16 16:46:20 +11:00
Mike Farah a3cebec2fd Added prefix command 2019-12-16 16:17:01 +11:00
Mike Farah b81fd638d7 wip - new node 2019-12-15 19:34:05 +11:00
Mike Farah 2344638da4 Fixed delete splat 2019-12-15 18:53:49 +11:00
Mike Farah 8be006fba4 Fixed delete splat 2019-12-15 18:52:37 +11:00
Mike Farah 53a4a47ce3 wip - prefix splat 2019-12-15 18:38:40 +11:00
Mike Farah 5988d0cffa Simplified 2019-12-15 18:24:23 +11:00
Mike Farah b7640946ac Delete! 2019-12-15 17:31:26 +11:00
Mike Farah d061b2f9f9 Can delete arrays 2019-12-12 20:47:22 +11:00
Mike Farah 8c0046a622 Refactoring 2019-12-09 13:57:38 +11:00
Mike Farah 586ffb833b Refactoring 2019-12-09 13:57:10 +11:00
Mike Farah 9771e7001c splatting 2019-12-09 13:44:53 +11:00
Mike Farah 8da9a81702 visitor! 2019-12-08 15:59:24 +11:00
Mike Farah d97f1d8be2 recurse 2019-12-08 15:37:30 +11:00
Mike Farah dad61ec615 remove json conversion for now 2019-12-06 16:52:00 +11:00
Mike Farah 676fc63219 remove json conversion for now 2019-12-06 16:41:21 +11:00
Mike Farah 972e2b9575 wip 2019-12-06 16:36:42 +11:00
Mike Farah aad15ccc6e better v3 2019-12-06 15:57:46 +11:00
Conor NosalandMike Farah 5fc13bdccd update imports for v2 module path 2019-12-06 13:58:56 +11:00
Conor NosalandMike Farah 95fec2984e Move parseValue to yqlib/value_parser.go 2019-12-06 13:58:56 +11:00
Conor NosalandMike Farah 64d1e58f97 test coverage and linting 2019-12-06 13:58:56 +11:00
Conor NosalandMike Farah 4b3fbb878f Split marshal package from yqlib, implement interfaces 2019-12-06 13:58:56 +11:00
Conor NosalandMike Farah 26a09e6ec0 Move implementation files to yqlib and test packages to allow for imports:
- Move data_navigator, json_converter, merge, and path_parser to pkg/yqlib
- Extract yamlToString from yq to pkg/yqlib/yaml_converter
- Move utils_test to test/utils
2019-12-06 13:58:56 +11:00
Mike Farah ceafed30f9 attempt to fix go get 2019-12-02 10:38:44 +11:00
Mike Farah b8b2c9de61 attempt to fix go get 2019-12-02 10:37:06 +11:00
Mike Farah f5fdf98c38 Updating release instructions 2019-11-13 12:26:33 +11:00
Mike Farah 29986db8f8 Update doc for go get 2019-11-13 12:25:24 +11:00
Mike Farah 1f4e3a9cde Ignore vendor folder 2019-11-06 11:45:31 +11:00
Mike Farah b6da773dde Bumbed snapcraft version 2019-11-01 12:40:35 +11:00
Mike Farah 8020d4253b Updated README 2019-11-01 12:40:21 +11:00
Mike Farah 3c701fe98e Incremented version 2019-11-01 10:47:38 +11:00
Mike Farah 97d1aa2b26 Added formatter, fixed docker build 2019-10-31 08:21:19 +11:00
ElliotandMike Farah d05391e244 update ci to use go 1.13, switch to golangci-lint 2019-10-31 08:21:19 +11:00
ElliotandMike Farah d1cec1ad18 fix to make it work with modules 2019-10-31 08:21:19 +11:00
Mike Farah fe5842e5f9 Fix: Only remove original file if copying was successful 2019-08-27 09:21:39 +10:00
Aleksandr SerginandMike Farah e0d8cd6bf6 yq small fix 2019-08-27 09:18:38 +10:00
Aleksandr SerginandMike Farah 8f5ffe47ff return to old behavior, small fix. 2019-08-27 09:18:38 +10:00
Aleksandr SerginandMike Farah 5acc1e661e fix linter error 2019-08-27 09:18:38 +10:00
Aleksandr SerginandMike Farah a9c0ef571c fix linter error 2019-08-27 09:18:38 +10:00
Aleksandr SerginandMike Farah 7a28531f2f fix linter error 2019-08-27 09:18:38 +10:00
Aleksandr SerginandMike Farah 5de2bea1b4 fix linter error 2019-08-27 09:18:38 +10:00
Aleksandr SerginandMike Farah 7320b8d3c9 fix linter error 2019-08-27 09:18:38 +10:00
Aleksandr SerginandMike Farah 2f70e6f27a fix linter error 2019-08-27 09:18:38 +10:00
Aleksandr SerginandMike Farah a9e871ee00 add Move func to avoid 'invalid cross-device link' 2019-08-27 09:18:38 +10:00
Azimjon IlkhomovandMike Farah bc4bab9380 Fix typo 2019-08-05 11:30:20 +10:00
Mike Farah 665d9079fa Added goreport to readme 2019-07-23 10:07:59 +10:00
Mike Farah 7b54a44fcf Fixed readme for bash docker alias to bash function, thanks @dead10ck 2019-07-23 09:57:58 +10:00
Kenny JonesandGitHub 94148e4398 Merge pull request #256 from arnaud-deprez/patch-1
doc: use '--rm' instead of '-rm' for docker command
2019-07-02 09:32:51 -04:00
Arnaud DeprezandGitHub f8553162ca doc: use '--rm' instead of '-rm' for docker command 2019-07-02 12:17:35 +00:00
Eduardo Minguez PerezandMike Farah be532bf2fe Added '-rm' docker flag to remove the containers
Also, added a handy alias just in case.
2019-06-10 21:59:40 +10:00
Mike Farah e9b8265ca3 Updated docs re creating a new array 2019-05-16 14:57:34 +10:00
Mike Farah 0f8b864321 Updated instructions 2019-05-16 14:56:00 +10:00
Mike Farah e5bcfedbe9 updating docs 2019-05-16 14:55:32 +10:00
Mike Farah a5f5fb2562 Publish moves files after uploading for speedy retries 2019-05-16 14:54:58 +10:00
Mike Farah 84de9c078d Improved handling of numeric keys
When there is no match at a given path, numeric keys are assumed to be strings.
To create an array '+' must be used.

e.g: yq n thing[+].cat fred
will create an array under thing, whereas
yq n thing[0].cat fred
will create a map under thing, with a key '0'
2019-05-16 10:03:54 +10:00
Mike Farah c7f5261036 Bump version 2019-05-16 10:03:54 +10:00
Georgi KnoxandMike Farah 6e35356a84 add help description 2019-05-16 09:35:16 +10:00
Mike Farah b2fe3e6738 fixing delete splat 2019-05-14 11:20:41 +10:00
Mike Farah 774badfef4 Can delete splat!
Fixes https://github.com/mikefarah/yq/issues/175
2019-05-13 09:48:05 +10:00
Mike Farah c4e9516aa6 Prefix matching splat
Fixes https://github.com/mikefarah/yq/issues/218
2019-05-13 09:32:08 +10:00
Mike Farah 323089eb64 fixed tests for write array splat 2019-05-13 09:13:45 +10:00
Mike Farah 53289366a5 Write array splat 2019-05-01 08:55:44 +10:00
Mike Farah cda9a82906 Refactoring write command to allow splat 2019-05-01 08:40:35 +10:00
Mike Farah 2dbde6b9fb Can process numeric keys
Fixes: https://github.com/mikefarah/yq/issues/215
2019-04-30 09:43:09 +10:00
Mike Farah f8c1c3c1b4 Updated instructions w.r.t keys and values starting with dashes 2019-04-29 16:14:33 +10:00
Mike Farah 238a1241d2 Added snap specific notes
https://forum.snapcraft.io/t/requesting-classic-confinement-for-yq/10559
2019-03-27 09:27:07 +11:00
Mike Farah 8a61ef072a Revert "Snapcraft classic confinment to allow access to system resources"
Snap doesn't let me use classic

This reverts commit 4f178d2317.
2019-03-25 09:28:06 +11:00
Mike Farah 4f178d2317 Snapcraft classic confinment to allow access to system resources
https://docs.snapcraft.io/snap-confinement/6233
2019-03-25 09:19:29 +11:00
Mike Farah 133e55105c Bump snapcraft go version 2019-03-22 16:32:30 +11:00
Mike Farah 5e5468af3b Release instructions update 2019-03-22 16:03:11 +11:00
Mike Farah 9b4972e46e Increment version for new functionality 2019-03-22 09:15:26 +11:00
Renzo CrisóstomoandMike Farah 23543ee031 Add test for --allow-empty flag in merge command 2019-03-22 09:13:39 +11:00
Renzo CrisóstomoandMike Farah 75c7d40c44 Add --allow-empty flag to merge command 2019-03-22 09:13:39 +11:00
Mikhail NovosyolovandMike Farah 44b8a5e80f Fix Debian 'Architecture'
When it's 'all', architecture-independent packages are built, and so now an x86_64 executable is packaged to noarch packaged.
2019-03-21 12:39:47 +11:00
Mike Farah 77c8f22a79 Bump golang version to 1.11 2019-01-21 09:37:22 +11:00
Roberto Mier EscandonandMike Farah 386a0ca3c3 Bump debian pkg to 2.2-1 version 2019-01-21 09:06:43 +11:00
Mike Farah 53a20d4421 Bumb version 2019-01-07 10:23:37 +11:00
Kyle TitusandMike Farah 478208b7c4 Added Windows support for the "--inplace" command flag 2019-01-07 10:07:08 +11:00
Mike Farah 1159d0a212 Fixing snapcraft yml 2018-11-21 13:39:03 +11:00
Mike Farah 8861b392a8 Bump version 2018-11-20 09:49:44 +11:00
Mike Farah 16bde80334 Prefix now supports arrays 2018-11-20 09:47:17 +11:00
matfaxandMike Farah 8a3fb32f36 Update documentation 2018-11-20 08:53:25 +11:00
matfaxandMike Farah 48dcc15281 feat: add prefix command 2018-11-20 08:53:25 +11:00
Matthias FaxandMike Farah d7040e3933 Bump Alpine version to 3.8
There has been a security issue with older Alpine versions and their package manager.
https://justi.cz/security/2018/09/13/alpine-apk-rce.html

Not sure about 3.7, but the latest 3.8 image has it fixed.
2018-11-19 08:39:20 +11:00
Mike Farah ef579d4ccf Updated release instructions 2018-10-30 13:18:52 +11:00
Mike Farah 785ee68a76 Improved docker build process 2018-10-25 17:49:46 +11:00
Mike Farah 90fe9c6512 Version bump 2018-10-25 16:05:43 +11:00
Thad CraftandMike Farah a9ade5a832 fixing test lint 2018-10-25 15:46:57 +11:00
Thad CraftandMike Farah 8d6e3a6a75 copying file permissions from original file when inline merging - Closes #180 2018-10-25 15:46:57 +11:00
Mike Farah 7a6689eb40 Fixed latest linting issues 2018-08-06 16:24:06 +10:00
Mike FarahandGitHub e6660e2460 Update README.md 2018-07-31 19:04:34 +10:00
Mike Farah 28169b04f7 Added build support for all linux architectures supported by gox 2018-07-23 09:16:52 +10:00
Mike Farah 742cf748ac Added support for PPC architectures 2018-07-18 13:45:15 +10:00
Mike Farah 54c06cdb4c Update release instructions re version tag 2018-07-15 08:18:11 +10:00
Roberto Mier EscandonandMike Farah ef5f745da3 Fix version typo 2018-07-11 08:49:37 +10:00
Roberto Mier EscandonandMike Farah 25025f2771 Bump debian package version 2018-07-11 08:49:37 +10:00
Mike Farah ebb8b34b31 Updating readme badges 2018-07-10 22:00:50 +10:00
Mike Farah 9a5e4ee828 Fixed whitespace in badge 2018-07-10 21:51:47 +10:00
Benedikt FrankeandMike Farah 0a2dd29940 Add badge for docker build 2018-07-10 21:49:59 +10:00
Mike Farah 50dfce86c9 Updated mkdocs library 2018-07-10 21:29:41 +10:00
Mike Farah e55006e935 Document multi document read feature 2018-07-10 21:24:13 +10:00
Mike Farah d8fed62f03 merge documentation 2018-07-10 21:24:13 +10:00
Mike Farah 52a39bf31e Incrementing snapcraft version 2018-07-10 21:12:32 +10:00
Mike Farah d84254c30f moar tests 2018-07-08 22:04:31 +10:00
Mike Farah 18bb4eee96 moar tests 2018-07-08 21:57:56 +10:00
Mike Farah 86b9fe3ef9 Can read from all documents 2018-07-08 21:47:01 +10:00
Mike Farah 2c15048ddb Added merge with append 2018-07-07 15:26:56 +10:00
Mike Farah ce2ee42f71 Release instructions for gopkg 2018-07-01 14:45:19 +10:00
Mike Farah c2c49dcb17 Fixed help length to prevent horizontal scroll in README 2018-06-27 19:37:18 +10:00
Mike Farah 60de18391c Incrementing version for next release 2018-06-27 12:06:46 +10:00
Mike Farah c86f8b426b Fixed writing inplace from docker 2018-06-27 12:06:31 +10:00
Mike Farah b3532e0a61 Cache devtools and vendor libs in docker 2018-06-27 12:05:52 +10:00
Mike Farah b3b60665e4 Fixed toJson command line option, should only apply to read command 2018-06-26 14:09:56 +10:00
Mike Farah df08b055cf Shorten instructions in readme to avoid horizontal scroll 2018-06-20 19:50:19 +10:00
Mike Farah e822313e82 Merge branch 'multi' 2018-06-20 19:48:44 +10:00
Mike Farah a9f25c9d76 Added more snapcraft instructions 2018-06-20 19:46:47 +10:00
Roberto Mier EscandonandMike Farah 0a8c268dcc Bumped deb version 2018-06-20 19:28:44 +10:00
Mike Farah a0e70279a8 Updating snapcraft version 2018-06-20 17:51:07 +10:00
Mike Farah 25c9c22d8d Updating docs 2018-06-20 14:29:17 +10:00
Mike Farah d46d555b07 Incrementing version 2018-06-20 14:29:10 +10:00
Mike Farah fb87f638f2 Multi doc supports updating all docs 2018-06-20 11:45:51 +10:00
Mike Farah facc81d1f4 github version of mousetrap required for xcompile 2018-06-20 08:14:14 +10:00
Mike Farah c1f9065c68 pflag has to be github :eye_roll: 2018-06-18 20:12:09 +10:00
Mike Farah be84cc3082 Add pflag back in 2018-06-18 20:08:41 +10:00
Mike Farah a2571da1a1 Updated docs to refer to gopkg.in when using go get 2018-06-18 11:45:46 +10:00
Mike Farah 6d6e476ac8 Use gopkg managed versions of dependencies, for better go get support 2018-06-18 11:37:42 +10:00
Mike Farah ae0c042ae6 Use gopkg managed version of yaml to properly support go get 2018-06-18 11:12:52 +10:00
Mike Farah 867ec92d3a Version bump 2018-06-15 20:50:20 +10:00
Mike Farah 113586b5e0 Updating help for multi doc 2018-06-15 20:31:29 +10:00
Mike Farah c38f19e0a9 Enabled multi document support for merge (first document only) 2018-06-15 16:48:36 +10:00
Mike Farah 8ca85b1c64 Simplified merge command 2018-06-15 16:40:52 +10:00
Mike Farah 08870f8ec9 Simplified 'new' command 2018-06-15 16:21:18 +10:00
Mike Farah 94b217984c Better error handling 2018-06-15 16:11:13 +10:00
Mike Farah 2f5a481cc3 Detect when there is no document X to update 2018-06-15 09:54:11 +10:00
Mike Farah 1a4064429d Delete now supports multi docs! 2018-06-15 09:43:20 +10:00
Mike Farah 1b22e1d812 Fixed delete command for arrays 2018-06-15 09:03:42 +10:00
Mike Farah 297522cbdd Write supports multidoc yaml, better use of yaml library streaming 2018-06-15 08:39:59 +10:00
Mike Farah be991fdacd Read test 2018-06-15 08:39:29 +10:00
Mike Farah be08214773 fixed version test 2018-06-13 10:00:01 +10:00
Mike Farah 9e971ebeae Beta version of multiple document support for read, write coming soon 2018-06-13 09:26:52 +10:00
Mike Farah f340db5795 Extract out reading of write commands 2018-06-13 09:24:37 +10:00
Mike Farah ab852ceafa Separate reading stream from processing 2018-06-13 09:11:54 +10:00
Mike Farah 06a843e9b2 Read now handles multiple documents 2018-06-12 15:41:09 +10:00
Mike Farah ebdc092688 Updating user docs 2018-06-12 10:17:09 +10:00
Roberto Mier EscandonandMike Farah 27089d1ca1 Updated some documentation pointing to deb install option 2018-06-12 10:12:55 +10:00
Roberto Mier EscandonandMike Farah 1853585d22 Add debian packaging 2018-06-12 10:12:55 +10:00
Mike Farah 0124d26086 Added mkdocs instructions to Contribute 2018-06-12 10:11:15 +10:00
Mike Farah 0d68bea3dc Release instructions 2018-05-08 10:55:16 +10:00
Mike Farah 54603b3607 Updated version in snapcraft.yml 2018-05-08 10:06:41 +10:00
Mike Farah c86aeca325 Fixed script for publishing from a mac 2018-05-07 20:39:18 +10:00
Mike Farah a4f124f24f Updated repo name 2018-05-07 16:40:23 +10:00
Mike Farah 090b377fa5 Incrementing version to reflect new delete feature! 2018-05-07 16:38:26 +10:00
Mike Farah 3a4d62d820 Adding delete command documentation 2018-05-07 16:34:29 +10:00
Mike Farah 6053c8c136 Use dev scripts for making docker image 2018-05-07 16:31:26 +10:00
Mike Farah c5a45ba7d5 Removed dud instructions 2018-05-07 16:26:38 +10:00
Matthew HuxtableandMike Farah 56a0771cd1 Mark test helpers as such 2018-05-07 15:52:29 +10:00
Matthew HuxtableandMike Farah 8072e66d46 Add delete command
The delete (short option "d") will delete the YAML subtree at the
provided path in the specified file (or STDIN), if it the node exists.

More complex support is currently omitted, for example:

  - specify nodes to delete using an external script
  - deleting common elements from all elements of an array
2018-05-07 15:52:29 +10:00
Tim HobbsandMike Farah 26153b3eb5 Rename to yq 2018-04-09 15:58:12 +10:00
Tim HobbsandMike Farah f2e10f21c7 Rename to yq 2018-04-09 15:58:12 +10:00
spawniaandMike Farah d3ecf7aa88 Add Dockerfile for building the official CLI container 2018-04-03 09:25:00 +10:00
Mike Farah ee8ffd458a Multiline value fix - multi line strings no longer printed as a yaml block
Although printing the string as a yaml block can be argued to be technically correct, in practical terms it's more useful to just print out the multiline string as is.
2018-03-27 16:22:24 +11:00
Mike Farah 8f15dba812 Updated docs to explicity put array paths in quotes 2018-02-28 08:07:34 +11:00
Mike Farah 92ce195424 Fixed version test 2018-02-19 14:50:46 +11:00
Mike Farah e725a2cec5 Fixed docs 2018-02-19 14:21:38 +11:00
Mike Farah 37de7a3505 Don't default to dev version 2018-02-19 14:07:21 +11:00
Mike Farah e96794a420 Remove version pre release
this is appearing in the snap release :(
2018-02-19 13:27:22 +11:00
Mike Farah 120ef8e4dc drop dev from version 2018-02-19 09:45:10 +11:00
David BlissandMike Farah db1954da25 Hard-code version and change grade to 'stable' 2018-02-19 08:23:30 +11:00
David BlissandMike Farah e552dbb6ab Add install instructions to documentation 2018-02-19 08:23:30 +11:00
David BlissandMike Farah 298126864f Remove comment 2018-02-19 08:23:30 +11:00
David BlissandMike Farah d30cd8cc75 Add snap target to Makefile 2018-02-19 08:23:30 +11:00
David BlissandMike Farah e6ee86930b Support building snap packages 2018-02-19 08:23:30 +11:00
Mike Farah 0ea3c71df7 No longer using circle ci 2017-12-27 14:22:17 +11:00
Mike Farah ef99bedf45 Added circle ci dashtic config 2017-12-27 14:16:57 +11:00
Mike Farah 6e1a5aef2c Add dev tools to circle ci 2017-12-27 14:10:47 +11:00
Mike Farah 70bd860287 Added circle ci config 2017-12-27 14:08:28 +11:00
Mike Farah 0abda0098c Now on brew! 2017-12-25 06:30:49 +11:00
Mike Farah a409a7e82b Missed one replace in docs 2017-12-19 12:01:23 +11:00
Mike Farah 0e4f9e8579 Update docs 2017-12-19 11:59:27 +11:00
Mike Farah 0c932ba7dc Updated travis ci image 2017-12-19 11:39:54 +11:00
Mike Farah cb48ba7173 Rename to yq 2017-12-18 15:29:41 +11:00
Mike Farah dc4f8a6adb Fixed vendor scripts 2017-12-18 15:29:41 +11:00
Mike Farah 1f6d7a50b2 Clearer README 2017-12-18 15:29:41 +11:00
Kenny JonesandGitHub 6fc3bdf58f Merge pull request #103 from mikefarah/task/upgrade-to-golang1.9
Task: Upgrade to Golang 1.9
2017-09-27 07:07:16 -04:00
kenjones 87b33e8603 Task: Upgrade to Golang 1.9 2017-09-27 07:05:18 -04:00
kenjones cc7eb84388 Task: Add docs on keys with dots
Adds documentation on how to use a key lookup indicator for dealing
with keys that have dots when specifying a path as part of create,
read, and write commands.

Resolves: #22
2017-09-25 22:36:49 -04:00
kenjones 9e3f8ebd0a Task: Prepare for development 2017-09-25 09:41:27 -04:00
kenjones 28bcbd321f Release v1.13.1 2017-09-25 09:35:23 -04:00
Kenny JonesandGitHub 9dd4503b23 Merge pull request #42 from mikefarah/bugfix/append-empty-array
Bugfix: Append when array empty results in null value
2017-09-25 09:34:00 -04:00
kenjones 185d1faadb Bugfix: Append when array empty results in null value
Initialize new array as empty instead of having a single value.

Resolves: #41
2017-09-25 09:31:06 -04:00
kenjones 7b004cb456 Task: Prepare for development 2017-09-24 21:28:28 -04:00
kenjones 54c73eb34f Release v1.13.0 2017-09-24 21:20:02 -04:00
Kenny JonesandGitHub 3b03a0852a Merge pull request #40 from kenjones-cisco/task/releasing
Task: Add release process
2017-09-24 21:13:06 -04:00
kenjones a00e6c5316 Task: Add release process 2017-09-24 21:10:57 -04:00
Kenny JonesandGitHub 9d1a5b17b8 Merge pull request #39 from kenjones-cisco/feature/append-array
Feature: Add append to array
2017-09-23 20:24:09 -04:00
kenjones c5f80a105d Feature: Add append to array
Adds the ability to append a value to an array instead of having to
know the index of the values within the array.

Resolves: #17
2017-09-23 20:21:16 -04:00
Kenny JonesandGitHub c17f8df8f8 Merge pull request #38 from kenjones-cisco/task/add-merge-docs
Task: Add `merge` command docs
2017-09-23 15:36:31 -04:00
kenjones 66c8390d54 Task: Add merge command docs
Resolves: #35
2017-09-23 15:33:23 -04:00
Kenny JonesandGitHub dda9b1f087 Merge pull request #37 from kenjones-cisco/bugfix/read-yaml-array
Bugfix: Read yaml array
2017-09-23 14:04:33 -04:00
Kenny JonesandGitHub 683de28c64 Merge pull request #34 from kenjones-cisco/feature/add-version
Feature: Adds support for --version
2017-09-23 14:04:18 -04:00
kenjones 51fa1a87b7 Bugfix: Read yaml array
Parsing an array into MapSlice results in `[{nil, nil}]`.
Parse into `[]map[interface{}]interface{}` allows for the processing of
top level arrays in the document.

Resolves: #23
2017-09-23 13:53:04 -04:00
Kenny JonesandGitHub b9ac6a3d9d Merge pull request #36 from kenjones-cisco/bugfix/write-empty-array
Bugfix: Write empty array value
2017-09-23 09:39:01 -04:00
kenjones 499974c27e Bugfix: Write empty array value
When the value is `[]` set the value to empty array instead of `'[]'`.

Resolves: #21
2017-09-23 09:36:17 -04:00
kenjones 72bd88cfa5 Feature: Adds support for --version
Resolves: #24
2017-09-23 01:08:39 -04:00
kenjonesandMike Farah 6980be3800 Feature: Adds merge command
Adds merge command for merging multiple yaml files together.

Resolves: #31
2017-09-23 14:45:59 +10:00
Kenny JonesandGitHub 2933ea1684 Merge pull request #33 from kenjones-cisco/bugfix/acceptance
Bugfix: Resolve failing acceptance test
2017-09-23 00:00:48 -04:00
kenjones cf2f23d747 Bugfix: Resolve failing acceptance test 2017-09-22 23:58:50 -04:00
Kenny JonesandGitHub 45e9ad870f Merge pull request #30 from kenjones-cisco/task/refactor-add-tests
Task: Increase test coverage, includes refactor
2017-09-22 23:09:04 -04:00
kenjones 53b2c64747 Task: Increase test coverage, includes refactor
Adds test cases to increase test coverage.
Refactors code to enable adding tests by reducing the number of
locations where `os.Exit()` is called from.
2017-09-22 23:01:46 -04:00
Mike Farah 359ca5a117 Merge branch 'kenjones-cisco-bugfix/nonstring-keys' 2017-09-23 08:56:55 +10:00
Mike Farah 79baa49eaa Merge branch 'bugfix/nonstring-keys' of git://github.com/kenjones-cisco/yaml into kenjones-cisco-bugfix/nonstring-keys 2017-09-23 08:54:08 +10:00
Mike Farah 2cda78ce0b Vendor shas 2017-09-23 08:47:18 +10:00
Mike FarahandGitHub 6d1e61c410 Merge branch 'master' into bugfix/nonstring-keys 2017-09-23 08:38:37 +10:00
kenjonesandMike Farah 86639acf70 Task: Simplify development
The base directory has all shell scripts in scripts/
and all example/test files in examples/.
A Makefile provides all the commands with helpful information.
If a developer simply types `make` then vendor is properly updated,
the code is formatted, linted, tested, built, acceptance test run,
and installed.

Linting errors resolved.
Ignored test case (`TestParsePath`) updated to work as expected.
2017-09-23 08:37:34 +10:00
kenjones 3beee3f804 Bugfix: Panic on non-string keys
Adds check if the key is an `int` or `bool`, and converts to a string
as part of the `toJSON` function.
Test cases added.

Resolves: #28
2017-09-21 12:01:03 -04:00
Mike Farah 1ed8e7017e Can create arrays 2017-08-08 17:04:30 +10:00
Mike Farah 5514d2300b Can update arrays 2017-08-08 16:55:57 +10:00
Mike Farah 5bb0934710 Handle arrays and strings when reading 2017-08-08 16:42:11 +10:00
Mike Farah cdd78af4bc Fixed bug #11: Inability to set field to empty string 2017-06-06 10:19:32 +10:00
Mike Farah d07e436065 Update docs re using values that look like flags 2017-05-03 10:42:53 +10:00
Mike Farah b2a0964de2 switched from godeps to govendor, now supports new 'vendor' folder 2017-05-03 09:19:55 +10:00
Mike Farah 69e6bb354d Added doco regarding values starting with hyphens 2017-05-03 08:11:26 +10:00
Mike Farah ec25886528 Removed redundant code, updated doc w.r.t reading json files 2017-04-19 15:45:45 +10:00
Mike Farah c2000a446b Fixed writeCommands to maintain the same execution as was read in 2017-04-18 15:55:43 +10:00
Mike Farah 08ba0083be formatting 2017-04-18 09:14:06 +10:00
Mike Farah 909b62be54 Fixed ability to grow arrays 2017-04-18 08:53:27 +10:00
Mike Farah 0facf35d60 Fixed test flakeyness with using printf 2017-04-14 12:56:50 +10:00
Mike Farah a7c4813703 Updated doco 2017-04-14 12:40:03 +10:00
Mike Farah 373e0a5eb7 More tests 2017-04-14 12:39:55 +10:00
Mike Farah 124c57f9d9 README now links to doco 2017-04-13 15:44:31 +10:00
Mike Farah fb73a793bd Added doco 2017-04-13 15:36:59 +10:00
Mike Farah c22394b540 Updated readme 2017-04-12 21:30:29 +10:00
Mike Farah b1ff47022b Updated readme 2017-04-12 21:20:43 +10:00
Mike Farah 82f1230db8 Added "new" command for creating new yaml 2017-04-12 21:10:00 +10:00
Mike Farah a3190f1504 Refactor write to allow new entries 2017-04-12 20:25:13 +10:00
Mike Farah 44ee869e47 Maintain order 2017-02-27 09:09:29 +11:00
Mike Farah 5d2d37a5f8 Fixed travis script, added Travis banner to readme 2017-02-13 07:55:06 +11:00
Mike Farah e3fc944709 Added travis config 2017-02-13 07:28:48 +11:00
Mike Farah 6ee9db9a70 Added License (MIT) 2017-02-10 16:00:25 +11:00
Mike FarahandMike Farah 0d75edfb67 Fixed updating array bug (Issue 3 in git) 2017-02-09 13:58:47 +11:00
Mike Farah 037314af8a Merge pull request #2 from chaos95/master
Handle 'index out of range' errors more gracefully
2016-03-19 13:05:57 +11:00
Morgan Larosa 2a283b4ef7 Fix #1 2016-03-16 16:11:06 +11:00
Mike Farah 7ef556f22b Update README.md 2015-11-20 21:42:45 +11:00
Mike Farah 6b566fd983 Refactored code 2015-10-13 21:42:36 +11:00
Mike Farah 001925a4d4 Release task now clears build directory first 2015-10-13 21:34:40 +11:00
Mike Farah 3dee7b89d2 Updated README 2015-10-13 21:34:26 +11:00
Mike Farah c955815aab Added json input functionality 2015-10-11 17:06:52 +11:00
Mike Farah 3720bf8211 Added json output functionality 2015-10-11 10:00:22 +11:00
Mike Farah 5f09aabf4c Extracted out common test code 2015-10-10 19:18:54 +11:00
Mike Farah 98751cf607 Using godeps 2015-10-10 12:57:11 +11:00
Mike Farah 2ec3b59da2 Added more help info about using write with an update script 2015-10-09 21:30:15 +11:00
Mike Farah 56c923228d Fixed bug when using write command
Added more tests to avoid bugs ;)
2015-10-09 21:24:42 +11:00
Mike Farah c122b9a843 Fixed example in README 2015-10-08 20:07:27 +11:00
mfarah 15f51d4bf0 Can update a yaml file from an instruction yaml file 2015-10-08 10:31:31 +11:00
mfarah 219105f999 Test result order no longer matters 2015-10-07 13:36:39 +11:00
mfarah 955ecc2547 Removed usage of log 2015-10-06 16:39:19 +11:00
mfarah 1d5fbd5ad0 Use cobra for cli for nicer cli-ness 2015-10-06 16:17:28 +11:00
mfarah 1605938c2c Readme updates 2015-10-06 11:58:51 +11:00
mfarah 2780903b60 Fixed readme formatting 2015-10-06 11:51:36 +11:00
mfarah 81672d4efe Can now splat maps 2015-10-06 10:08:31 +11:00
mfarah 6a696c81db Individual tests now have their own test data 2015-10-06 10:02:40 +11:00
mfarah 805729e4f7 DRYd code 2015-10-06 09:25:55 +11:00
mfarah 7db31006da Fixed write bug: can now update yaml with single key in path 2015-10-05 16:03:11 +11:00
mfarah 8409be1cdf Removed debug printLn 2015-10-05 16:02:07 +11:00
mfarah c03c4813d4 Can read from STDIN 2015-10-05 15:48:34 +11:00
mfarah 5ee6a9b9ca Updated README 2015-10-05 14:48:57 +11:00
mfarah 8efc46deae Fixed bad paths causing recursing down scalar values 2015-10-05 14:47:24 +11:00
mfarah e4d5769f29 Added array splat functionality 2015-10-05 14:41:50 +11:00
Mike Farah fea6e0db3d Clarified README 2015-10-04 17:07:39 +11:00
Mike Farah 6823d43325 Added ability to update yaml files inplace 2015-10-03 18:28:30 +10:00
Mike Farah da4b1a6449 Minor Readme fix 2015-10-03 18:19:13 +10:00
384 changed files with 35548 additions and 436 deletions
+1
View File
@@ -0,0 +1 @@
bin/*
+1
View File
@@ -0,0 +1 @@
github: mikefarah
+51
View 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
View 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
View 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 '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.
+22
View File
@@ -0,0 +1,22 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: docker
directory: /
schedule:
day: thursday
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
day: thursday
interval: weekly
- package-ecosystem: gomod
directory: /
schedule:
day: thursday
interval: weekly
+70
View File
@@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '24 3 * * 1'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
+62
View File
@@ -0,0 +1,62 @@
name: Release Docker
on:
release:
types: [released]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
publishDocker:
environment: dockerhub
env:
IMAGE_NAME: mikefarah/yq
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }} && docker version
- name: Build and push image
run: |
echo "GithubRef: ${GITHUB_REF}"
VERSION=${GITHUB_REF##*/}
echo "VERSION: ${VERSION}"
IMAGE_VERSION=${VERSION:1}
echo "IMAGE_VERSION: ${IMAGE_VERSION}"
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 \
--label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \
--label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" \
--label "org.opencontainers.image.description=yq is a portable command-line YAML processor" \
--label "org.opencontainers.image.documentation=https://mikefarah.gitbook.io/yq/" \
--label "org.opencontainers.image.licenses=MIT" \
--label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \
--label "org.opencontainers.image.source=https://github.com/mikefarah/yq" \
--label "org.opencontainers.image.title=yq" \
--label "org.opencontainers.image.url=https://mikefarah.gitbook.io/yq/" \
--label "org.opencontainers.image.version=${IMAGE_VERSION}" \
--platform "${PLATFORMS}" \
--pull \
--push \
-t "${IMAGE_NAME}:${IMAGE_VERSION}" \
-t "${IMAGE_NAME}:4" \
-t "${IMAGE_NAME}:latest" \
.
+35
View File
@@ -0,0 +1,35 @@
name: Build
on: [push, pull_request]
permissions:
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v3
with:
go-version: 1.18
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- 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: Check the build
shell: bash -l {0}
run: |
export PATH=${PATH}:`go env GOPATH`/bin
scripts/devtools.sh
make local build
+53
View File
@@ -0,0 +1,53 @@
name: Release YQ
on:
push:
tags:
- 'v*'
- 'draft-*'
jobs:
publishGitRelease:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.18'
- name: Compile man page markup
id: gen-man-page-md
run: |
./scripts/generate-man-page-md.sh
echo "::set-output name=man-page-md::man.md"
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF##*/}
- name: Generate man page
uses: docker://pandoc/core:2.14.2
id: gen-man-page
with:
args: >-
--standalone
--to man
--variable=title:"YQ"
--variable=section:"1"
--variable=header:"yq (https://github.com/mikefarah/yq/) version ${{ steps.get_version.outputs.VERSION }}"
--variable=author:"Mike Farah"
--output=yq.1
${{ steps.gen-man-page-md.outputs.man-page-md }}
- name: Cross compile
run: |
sudo apt-get install rhash -y
go install github.com/mitchellh/gox@v1.0.1
mkdir -p build
cp yq.1 build/yq.1
./scripts/xcompile.sh
- name: Release
uses: softprops/action-gh-release@v1
with:
files: build/*
draft: true
fail_on_unmatched_files: true
+22
View File
@@ -0,0 +1,22 @@
name: Test Yq Action
on: [push]
permissions:
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get test
uses: mikefarah/yq@master
with:
cmd: yq eval '.a' examples/sample.yaml
- name: Write inplace test
id: lookupSdkVersion
uses: mikefarah/yq@master
with:
cmd: yq eval -i '.b.c = 5' examples/sample.yaml
+33 -1
View File
@@ -6,7 +6,9 @@
# Folders
_obj
_test
bin
build
build-done
.DS_Store
# Architecture specific extensions/prefixes
@@ -20,8 +22,38 @@ _cgo_gotypes.go
_cgo_export.*
_testmain.go
coverage.out
coverage.html
*.exe
*.test
*.prof
yaml
vendor/
tmp/
cover/
yq
# snapcraft
parts/
prime/
.snapcraft/
yq*.snap
test.yml
test*.yml
test*.yaml
0.yml
1.yml
2.yml
# man page
man.md
yq.1
# debian pkg
_build
debian/files
# intellij
/.idea
+40
View File
@@ -0,0 +1,40 @@
run:
timeout: 5m
linters:
enable:
- asciicheck
- depguard
- errorlint
- gci
- gochecknoinits
- gofmt
- goimports
- gosec
- megacheck
- misspell
- nakedret
- nolintlint
- predeclared
- revive
- unconvert
- unparam
linters-settings:
depguard:
list-type: blacklist
include-go-root: true
packages:
- io/ioutil
packages-with-error-message:
- io/ioutil: "The 'io/ioutil' package is deprecated. Use corresponding 'os' or 'io' functions instead."
issues:
exclude-rules:
- linters:
- gosec
text: "Implicit memory aliasing in for loop."
path: _test\.go
- linters:
- revive
text: "unexported-return"
- linters:
- revive
text: "var-naming"
+76
View 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
+40
View File
@@ -0,0 +1,40 @@
# Development
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 :)
# Documentation
The documentation is a bit of a mixed bag (sorry in advanced, I do plan on simplifying it...) - with some parts automatically generated and stiched together and some statically defined.
Documentation is written in markdown, and is published in the 'gitbook' branch.
The various operator documentation (e.g. 'strings') are generated from the 'master' branch, and have a statically defined header (e.g. `pkg/yqlib/doc/operators/headers/add.md`) and the bulk of the docs are generated from the unit tests e.g. `pkg/yqlib/operator_add_test.go`.
The pipeline will run the tests and automatically concatenate the files together, and put them under
`pkg/qylib/doc/add.md`. These files are checked in the master branch (and are copied to the gitbook branch as part of the release process).
## How to contribute
The first step is to find if what you want is automatically generated or not - start by looking in the master branch.
### Updating dynamic documentation from master
- Search for the documentation you want to update. If you find matches in a `*_test.go` file - update that, as that will automatically update the matching `*.md` file
- Assuming you are updating a `*_test.go` file, once updated, run the test to regenerated the docs. E.g. for the 'Add' test generated docs, from the pkg/yqlib folder run:
`go test -run TestAddOperatorScenarios` which will run that test defined in the `operator_add_test.go` file.
- Ensure the tests still pass, and check the generated documentation have your update.
- Note: If the documentation is only in a `headers/*.md` file, then just update that directly
- Raise a PR to merge the changes into master!
### Updating static documentation from the gitbook branch
If you haven't found what you want to update in the master branch, then check the gitbook branch directly as there are a few pages in there that are not in master.
- Update the `*.md` files
- Raise a PR to merge the changes into gitbook.
+28
View File
@@ -0,0 +1,28 @@
FROM golang:1.18.4 as builder
WORKDIR /go/src/mikefarah/yq
COPY . .
RUN CGO_ENABLED=0 go build .
# RUN ./scripts/test.sh -- this too often times out in the github pipeline.
RUN ./scripts/acceptance.sh
# 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 as production
LABEL maintainer="Mike Farah <mikefarah@users.noreply.github.com>"
COPY --from=builder /go/src/mikefarah/yq/yq /usr/bin/yq
WORKDIR /workdir
RUN set -eux; \
addgroup -g 1000 yq; \
adduser -u 1000 -G yq -s /bin/sh -h /home/yq -D yq
RUN chown -R yq:yq /workdir
USER yq
ENTRYPOINT ["/usr/bin/yq"]
+10
View File
@@ -0,0 +1,10 @@
FROM golang:1.18.4
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
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
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.
+119
View File
@@ -0,0 +1,119 @@
MAKEFLAGS += --warn-undefined-variables
SHELL := /bin/bash
.SHELLFLAGS := -o pipefail -euc
.DEFAULT_GOAL := install
ENGINE := $(shell { command -v podman || command -v docker; } 2>/dev/null)
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 ENGINERUN= )
@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
@${ENGINE} rmi -f ${DEV_IMAGE} > /dev/null 2>&1 || true
@${ENGINE} build -t ${DEV_IMAGE} -f Dockerfile.dev .
@${ENGINE} 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/
${ENGINERUN} go build --ldflags "$(LDFLAGS)"
${ENGINERUN} bash ./scripts/acceptance.sh
## Compile the project for multiple OS and Architectures.
xcompile: check
@rm -rf build/
@mkdir -p build
${ENGINERUN} bash ./scripts/xcompile.sh
@find build -type d -exec chmod 755 {} \; || :
@find build -type f -exec chmod 755 {} \; || :
.PHONY: install
install: build
${ENGINERUN} 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
@mkdir -p vendor
${ENGINERUN} go mod vendor
# ----------------------------------------------
# develop and test
.PHONY: format
format: vendor
${ENGINERUN} bash ./scripts/format.sh
.PHONY: secure
secure: format
${ENGINERUN} bash ./scripts/secure.sh
.PHONY: check
check: secure
${ENGINERUN} bash ./scripts/check.sh
.PHONY: test
test: check
${ENGINERUN} bash ./scripts/test.sh
.PHONY: cover
cover: check
@rm -rf cover/
@mkdir -p cover
${ENGINERUN} bash ./scripts/coverage.sh
@find cover -type d -exec chmod 755 {} \; || :
@find cover -type f -exec chmod 644 {} \; || :
.PHONY: release
release: xcompile
${ENGINERUN} bash ./scripts/publish.sh
# ----------------------------------------------
# utilities
.PHONY: setup
setup:
@bash ./scripts/setup.sh
+38
View 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
ENGINERUN := ${ENGINE} 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}
+337 -58
View File
@@ -1,73 +1,352 @@
# yaml
yaml command line tool written in go
# yq
Allows you to read (and soon update) yaml files given a yaml path. All in a lovely dependency free binary!
![Build](https://github.com/mikefarah/yq/workflows/Build/badge.svg) ![Docker Pulls](https://img.shields.io/docker/pulls/mikefarah/yq.svg) ![Github Releases (by Release)](https://img.shields.io/github/downloads/mikefarah/yq/total.svg) ![Go Report](https://goreportcard.com/badge/github.com/mikefarah/yq) ![CodeQL](https://github.com/mikefarah/yq/workflows/CodeQL/badge.svg)
[Download latest release](https://github.com/mikefarah/yaml/releases/latest)
or alternatively install using go get:
```
go get github.com/mikefarah/yaml
```
a lightweight and portable command-line YAML, JSON and XML processor. `yq` uses [jq](https://github.com/stedolan/jq) like syntax but works with yaml files as well as json and xml. It doesn't yet support everything `jq` does - but it does support the most common operations and functions, and more is being added continuously.
## Read examples
```
yaml <yaml file> <path>
```
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 and Podman, all listed below.
### Basic
Given a sample.yaml file of:
```yaml
b:
c: 2
```
then
## Notice for v4.x versions prior to 4.18.1
Since 4.18.1, yq's 'eval/e' command is the _default_ command and no longer needs to be specified.
Older versions will still need to specify 'eval/e'.
Similarly, '-' is no longer required as a filename to read from STDIN (unless reading from one or more files).
TLDR:
Prior to 4.18.1
```bash
yaml sample.yaml b.c
yq e '.cool' - < file.yaml
```
will output the value of '2'.
### Handling '.' in the yaml key
Given a sample.yaml file of:
```yaml
b.x:
c: 2
```
then
4.18+
```bash
yaml sample.yaml \"b.x\".c
yq '.cool' < file.yaml
```
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 sample.yaml b.e[1].name
```
will output 'sam'
When merging multiple files together, `eval-all/ea` is still required to tell `yq` to run the expression against all the document at once.
### Updating yaml
Given a sample.yaml file of:
```yaml
b:
c: 2
```
then
## Quick Usage Guide
Read a value:
```bash
yaml w sample.yaml b.c 'cat'
yq '.a.b[0].c' file.yaml
```
will output:
```yaml
b:
c: cat
Pipe from STDIN:
```bash
yq '.a.b[0].c' < file.yaml
```
Update a yaml file, inplace
```bash
yq -i '.a.b[0].c = "cool"' file.yaml
```
Update using environment variables
```bash
NAME=mike yq -i '.a.b[0].c = strenv(NAME)' file.yaml
```
Merge multiple files
```bash
# note the use of `ea` to evaluate all the files at once
# instead of in sequence
yq ea '. as $item ireduce ({}; . * $item )' path/to/*.yml
```
Multiple updates to a yaml file
```bash
yq -i '
.a.b[0].c = "cool" |
.x.y.z = "foobar" |
.person.name = strenv(NAME)
' file.yaml
```
Convert JSON to YAML
```bash
yq -P sample.json
```
See the [documentation](https://mikefarah.gitbook.io/yq/) for more examples.
## 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
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\
tar xz && mv ${BINARY} /usr/bin/yq
```
#### Plain binary
```bash
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq &&\
chmod +x /usr/bin/yq
```
For instance, VERSION=v4.2.0 and BINARY=yq_linux_amd64
### MacOS / Linux via Homebrew:
Using [Homebrew](https://brew.sh/)
```
brew install yq
```
### Linux via snap:
```
snap install yq
```
#### 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 '.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 '.a.path = "value"' | sudo sponge /etc/myfile
```
or write to a temporary file:
```
sudo cat /etc/myfile | yq '.a.path = "value"' | sudo tee /etc/myfile.tmp
sudo mv /etc/myfile.tmp /etc/myfile
rm /etc/myfile.tmp
```
### Run with Docker or Podman
#### Oneshot use:
```bash
docker run --rm -v "${PWD}":/workdir mikefarah/yq [command] [flags] [expression ]FILE...
```
Note that you can run `yq` in docker without network access and other privileges if you desire,
namely `--security-opt=no-new-privileges --cap-drop all --network none`.
```bash
podman run --rm -v "${PWD}":/workdir mikefarah/yq [command] [flags] [expression ]FILE...
```
#### Pipe in via STDIN:
You'll need to pass the `-i\--interactive` flag to docker:
```bash
docker run -i --rm mikefarah/yq '.this.thing' < myfile.yml
```
```bash
podman run -i --rm mikefarah/yq '.this.thing' < myfile.yml
```
#### Run commands interactively:
```bash
docker run --rm -it -v "${PWD}":/workdir --entrypoint sh mikefarah/yq
```
```bash
podman run --rm -it -v "${PWD}":/workdir --entrypoint sh mikefarah/yq
```
It can be useful to have a bash function to avoid typing the whole docker command:
```bash
yq() {
docker run --rm -i -v "${PWD}":/workdir mikefarah/yq "$@"
}
```
```bash
yq() {
podman run --rm -i -v "${PWD}":/workdir mikefarah/yq "$@"
}
```
#### Running as root:
`yq`'s container image no longer runs under root (https://github.com/mikefarah/yq/pull/860). If you'd like to install more things in the container image, or you're having permissions issues when attempting to read/write files you'll need to either:
```
docker run --user="root" -it --entrypoint sh mikefarah/yq
```
```
podman run --user="root" -it --entrypoint sh mikefarah/yq
```
Or, in your Dockerfile:
```
FROM mikefarah/yq
USER root
RUN apk add --no-cache bash
USER yq
```
#### Missing timezone data
By default, the alpine image yq uses does not include timezone data. If you'd like to use the `tz` operator, you'll need to include this data:
```
FROM mikefarah/yq
USER root
RUN apk add --no-cache tzdata
USER yq
```
### GitHub Action
```
- name: Set foobar to cool
uses: mikefarah/yq@master
with:
cmd: yq -i '.foo.bar = "cool"' 'config.yml'
```
See https://mikefarah.gitbook.io/yq/usage/github-action for more.
### Go Install:
```
go install github.com/mikefarah/yq/v4@latest
```
## 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)
### Arch Linux
```
pacman -S go-yq
```
### Windows:
[![Chocolatey](https://img.shields.io/chocolatey/v/yq.svg)](https://chocolatey.org/packages/yq)
[![Chocolatey](https://img.shields.io/chocolatey/dt/yq.svg)](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, [JSON](https://mikefarah.gitbook.io/yq/usage/convert) and [XML](https://mikefarah.gitbook.io/yq/usage/xml) files
- Fully supports multi document yaml files
- Supports yaml [front matter](https://mikefarah.gitbook.io/yq/usage/front-matter) blocks (e.g. jekyll/assemble)
- Colorized yaml output
- [Date/Time manipulation and formatting with TZ](https://mikefarah.gitbook.io/yq/operators/datetime)
- [Deeply data structures](https://mikefarah.gitbook.io/yq/operators/traverse-read)
- [Sort 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 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)
- [Decode/Encode base64 data](https://mikefarah.gitbook.io/yq/operators/encode-decode)
- [Load content from other files](https://mikefarah.gitbook.io/yq/operators/load)
- [Convert to/from json](https://mikefarah.gitbook.io/yq/v/v4.x/usage/convert)
- [Convert to/from xml](https://mikefarah.gitbook.io/yq/v/v4.x/usage/xml)
- [Convert to/from properties](https://mikefarah.gitbook.io/yq/v/v4.x/usage/properties)
- [Convert to csv/tsv](https://mikefarah.gitbook.io/yq/usage/csv-tsv)
- [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.
- [Github Action](https://mikefarah.gitbook.io/yq/usage/github-action) to use in your automated pipeline (thanks @devorbitus)
## [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]
Examples:
# yq defaults to 'eval' command if no command is specified. See "yq eval --help" for more examples.
yq '.stuff' < myfile.yml # outputs the data at the "stuff" node from "myfile.yml"
yq -i '.stuff = "foo"' myfile.yml # update myfile.yml inplace
Available Commands:
completion Generate the autocompletion script for the specified shell
eval (default) Apply the expression to each document in each yaml file 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
-f, --front-matter string (extract|process) first input as yaml front-matter. Extract will pull out the yaml content, process will run the expression against the yaml content, leaving the remaining data intact
--header-preprocess Slurp any header comments and separators before processing expression. (default true)
-h, --help help for yq
-I, --indent int sets indent level for output (default 2)
-i, --inplace update the file inplace of first file given.
-p, --input-format string [yaml|y|xml|x] parse format for input. Note that json is a subset of yaml. (default "yaml")
-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 docs from scratch.
-o, --output-format string [yaml|y|json|j|props|p|xml|x] output format type. (default "yaml")
-P, --prettyPrint pretty print, shorthand for '... style = ""'
-s, --split-exp string print each result (or doc) into a file named (exp). [exp] argument must return a string. You can use $index in the expression as the result counter.
--unwrapScalar unwrap scalar, print the value with no quotes, colors or comments (default true)
-v, --verbose verbose mode
-V, --version Print version information and quit
--xml-attribute-prefix string prefix for xml attributes (default "+")
--xml-content-name string name for xml content (if no attribute name is present). (default "+content")
Use "yq [command] --help" for more information about a command.
```
## 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)
- Powershell has its own...[opinions on quoting yq](https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#quotes-in-windows-powershell)
See [tips and tricks](https://mikefarah.gitbook.io/yq/usage/tips-and-tricks) for more common problems and solutions.
+41
View File
@@ -0,0 +1,41 @@
#!/bin/bash
testWriteInPlacePipeIn() {
result=$(./yq e -i -n '.a' 2>&1)
assertEquals 1 $?
assertEquals "Error: write inplace flag only applicable when giving an expression and at least one file" "$result"
}
testWriteInPlacePipeInEvalall() {
result=$(./yq ea -i -n '.a' 2>&1)
assertEquals 1 $?
assertEquals "Error: write inplace flag only applicable when giving an expression and at least one file" "$result"
}
testWriteInPlaceWithSplit() {
result=$(./yq e -s "cat" -i '.a = "thing"' test.yml 2>&1)
assertEquals 1 $?
assertEquals "Error: write inplace cannot be used with split file" "$result"
}
testWriteInPlaceWithSplitEvalAll() {
result=$(./yq ea -s "cat" -i '.a = "thing"' test.yml 2>&1)
assertEquals 1 $?
assertEquals "Error: write inplace cannot be used with split file" "$result"
}
testNullWithFiles() {
result=$(./yq e -n '.a = "thing"' test.yml 2>&1)
assertEquals 1 $?
assertEquals "Error: cannot pass files in when using null-input flag" "$result"
}
testNullWithFilesEvalAll() {
result=$(./yq ea -n '.a = "thing"' test.yml 2>&1)
assertEquals 1 $?
assertEquals "Error: cannot pass files in when using null-input flag" "$result"
}
source ./scripts/shunit2
+356
View File
@@ -0,0 +1,356 @@
#!/bin/bash
setUp() {
rm test*.yml 2>/dev/null || true
rm .xyz 2>/dev/null || true
rm instructions.txt 2>/dev/null || true
}
testBasicEvalRoundTrip() {
./yq -n ".a = 123" > test.yml
X=$(./yq '.a' test.yml)
assertEquals 123 "$X"
}
testBasicTrailingContent() {
cat >test-trailing.yml <<EOL
test:
# this comment will be removed
EOL
read -r -d '' expected << EOM
test:
# this comment will be removed
EOM
X=$(./yq test-trailing.yml -P)
assertEquals "$expected" "$X"
}
testBasicTrailingContent() {
cat >test-trailing.yml <<EOL
test:
# this comment will be removed
EOL
read -r -d '' expected << EOM
test:
# hi
EOM
X=$(./yq '. footComment = "hi"' test-trailing.yml)
assertEquals "$expected" "$X"
}
testBasicTrailingContentEvalAll() {
cat >test-trailing.yml <<EOL
test:
# this comment will be removed
EOL
read -r -d '' expected << EOM
test:
# this comment will be removed
EOM
X=$(./yq ea test-trailing.yml -P)
assertEquals "$expected" "$X"
}
testBasicTrailingContentEvalAll() {
cat >test-trailing.yml <<EOL
test:
# this comment will be removed
EOL
read -r -d '' expected << EOM
test:
# hi
EOM
X=$(./yq ea '. footComment = "hi"' test-trailing.yml)
assertEquals "$expected" "$X"
}
testBasicPipeWithDot() {
./yq -n ".a = 123" > test.yml
X=$(cat test.yml | ./yq '.')
assertEquals "a: 123" "$X"
}
testBasicExpressionMatchesFileName() {
./yq -n ".xyz = 123" > test.yml
touch .xyz
X=$(./yq --expression '.xyz' test.yml)
assertEquals "123" "$X"
X=$(./yq ea --expression '.xyz' test.yml)
assertEquals "123" "$X"
}
testBasicExpressionFromFile() {
./yq -n ".xyz = 123" > test.yml
echo '.xyz = "meow" | .cool = "frog"' > instructions.txt
X=$(./yq --from-file instructions.txt test.yml -o=j -I=0)
assertEquals '{"xyz":"meow","cool":"frog"}' "$X"
X=$(./yq ea --from-file instructions.txt test.yml -o=j -I=0)
assertEquals '{"xyz":"meow","cool":"frog"}' "$X"
}
testBasicGitHubAction() {
./yq -n ".a = 123" > test.yml
X=$(cat /dev/null | ./yq test.yml)
assertEquals "a: 123" "$X"
X=$(cat /dev/null | ./yq e test.yml)
assertEquals "a: 123" "$X"
X=$(cat /dev/null | ./yq ea test.yml)
assertEquals "a: 123" "$X"
}
testBasicGitHubActionWithExpression() {
./yq -n ".a = 123" > test.yml
X=$(cat /dev/null | ./yq '.a' test.yml)
assertEquals "123" "$X"
X=$(cat /dev/null | ./yq e '.a' test.yml)
assertEquals "123" "$X"
X=$(cat /dev/null | ./yq ea '.a' test.yml)
assertEquals "123" "$X"
}
testBasicEvalAllAllFiles() {
./yq -n ".a = 123" > test.yml
./yq -n ".a = 124" > test2.yml
X=$(./yq ea test.yml test2.yml)
Y=$(./yq e '.' test.yml test2.yml)
assertEquals "$Y" "$X"
}
# when given a file, don't read STDIN
# otherwise strange things start happening
# in scripts
# https://github.com/mikefarah/yq/issues/1115
testBasicCatWithFilesNoDash() {
./yq -n ".a = 123" > test.yml
./yq -n ".a = 124" > test2.yml
X=$(cat test.yml | ./yq test2.yml)
Y=$(./yq e '.' test2.yml)
assertEquals "$Y" "$X"
}
# when the nullinput flag is used
# dont automatically read STDIN (this breaks github actions)
testBasicCreateFileGithubAction() {
cat /dev/null | ./yq -n ".a = 123" > test.yml
}
testBasicEvalAllCatWithFilesNoDash() {
./yq -n ".a = 123" > test.yml
./yq -n ".a = 124" > test2.yml
X=$(cat test.yml | ./yq ea test2.yml)
Y=$(./yq e '.' test2.yml)
assertEquals "$Y" "$X"
}
testBasicCatWithFilesNoDashWithExp() {
./yq -n ".a = 123" > test.yml
./yq -n ".a = 124" > test2.yml
X=$(cat test.yml | ./yq '.a' test2.yml)
Y=$(./yq e '.a' test2.yml)
assertEquals "$Y" "$X"
}
testBasicEvalAllCatWithFilesNoDashWithExp() {
./yq -n ".a = 123" > test.yml
./yq -n ".a = 124" > test2.yml
X=$(cat test.yml | ./yq ea '.a' test2.yml)
Y=$(./yq e '.a' test2.yml)
assertEquals "$Y" "$X"
}
testBasicStdInWithFiles() {
./yq -n ".a = 123" > test.yml
./yq -n ".a = 124" > test2.yml
X=$(cat test.yml | ./yq - test2.yml)
Y=$(./yq e '.' test.yml test2.yml)
assertEquals "$Y" "$X"
}
testBasicEvalAllStdInWithFiles() {
./yq -n ".a = 123" > test.yml
./yq -n ".a = 124" > test2.yml
X=$(cat test.yml | ./yq ea - test2.yml)
Y=$(./yq e '.' test.yml test2.yml)
assertEquals "$Y" "$X"
}
testBasicStdInWithFilesReverse() {
./yq -n ".a = 123" > test.yml
./yq -n ".a = 124" > test2.yml
X=$(cat test.yml | ./yq test2.yml -)
Y=$(./yq e '.' test2.yml test.yml)
assertEquals "$Y" "$X"
}
testBasicEvalAllStdInWithFilesReverse() {
./yq -n ".a = 123" > test.yml
./yq -n ".a = 124" > test2.yml
X=$(cat test.yml | ./yq ea test2.yml -)
Y=$(./yq e '.' test2.yml test.yml)
assertEquals "$Y" "$X"
}
testBasicEvalRoundTripNoEval() {
./yq -n ".a = 123" > test.yml
X=$(./yq '.a' test.yml)
assertEquals 123 "$X"
}
testBasicStdInWithOneArg() {
./yq e -n ".a = 123" > test.yml
X=$(cat test.yml | ./yq e ".a")
assertEquals 123 "$X"
X=$(cat test.yml | ./yq ea ".a")
assertEquals 123 "$X"
X=$(cat test.yml | ./yq ".a")
assertEquals 123 "$X"
}
testBasicUpdateInPlaceSequence() {
cat >test.yml <<EOL
a: 0
EOL
./yq e -i ".a = 10" test.yml
X=$(./yq e '.a' test.yml)
assertEquals "10" "$X"
}
testBasicUpdateInPlaceSequenceNoEval() {
cat >test.yml <<EOL
a: 0
EOL
./yq -i ".a = 10" test.yml
X=$(./yq '.a' test.yml)
assertEquals "10" "$X"
}
testBasicUpdateInPlaceSequenceEvalAll() {
cat >test.yml <<EOL
a: 0
EOL
./yq ea -i ".a = 10" test.yml
X=$(./yq e '.a' test.yml)
assertEquals "10" "$X"
}
testBasicUpdateInPlaceMultipleFilesNoExpressionEval() {
cat >test.yml <<EOL
a: 0
EOL
cat >test2.yml <<EOL
a: 1
EOL
read -r -d '' expected << EOM
0
---
1
EOM
./yq -i test.yml test2.yml
X=$(./yq e '.a' test.yml)
assertEquals "$expected" "$X"
}
testBasicUpdateInPlaceMultipleFilesNoExpressionEvalAll() {
cat >test.yml <<EOL
a: 0
EOL
cat >test2.yml <<EOL
a: 1
EOL
read -r -d '' expected << EOM
0
---
1
EOM
./yq -i ea test.yml test2.yml
X=$(./yq e '.a' test.yml)
assertEquals "$expected" "$X"
}
testBasicNoExitStatus() {
echo "a: cat" > test.yml
X=$(./yq e '.z' test.yml)
assertEquals "null" "$X"
}
testBasicExitStatus() {
echo "a: cat" > test.yml
X=$(./yq e -e '.z' test.yml 2&>/dev/null)
assertEquals 1 "$?"
}
testBasicExitStatusNoEval() {
echo "a: cat" > test.yml
X=$(./yq -e '.z' test.yml 2&>/dev/null)
assertEquals 1 "$?"
}
testBasicExtractFieldWithSeperator() {
cat >test.yml <<EOL
---
name: chart-name
version: 1.2.3
EOL
X=$(./yq e '.name' test.yml)
assertEquals "chart-name" "$X"
}
testBasicExtractMultipleFieldWithSeperator() {
cat >test.yml <<EOL
---
name: chart-name
version: 1.2.3
---
name: thing
version: 1.2.3
EOL
read -r -d '' expected << EOM
chart-name
---
thing
EOM
X=$(./yq e '.name' test.yml)
assertEquals "$expected" "$X"
}
testBasicMultiplyAssignMultiDoc() {
cat >test.yml <<EOL
a: 1
---
b: 2
EOL
read -r -d '' expected << EOM
a: 1
c: 3
---
b: 2
c: 3
EOM
X=$(./yq '. *= {"c":3}' test.yml)
assertEquals "$expected" "$X"
}
source ./scripts/shunit2
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
testCompletionRuns() {
result=$(./yq __complete "" 2>&1)
assertEquals 0 $?
assertContains "$result" "Completion ended with directive:"
}
source ./scripts/shunit2
+83
View File
@@ -0,0 +1,83 @@
#!/bin/bash
setUp() {
rm test*.yml || true
cat >test.yml <<EOL
# comment
EOL
}
testEmptyEval() {
X=$(./yq e test.yml)
expected=$(cat test.yml)
assertEquals 0 $?
assertEquals "$expected" "$X"
}
testEmptyEvalNoNewLine() {
echo -n "#comment" >test.yml
X=$(./yq e test.yml)
expected=$(cat test.yml)
assertEquals 0 $?
assertEquals "$expected" "$X"
}
testEmptyEvalNoNewLineWithExpression() {
echo -n "# comment" >test.yml
X=$(./yq e '.apple = "tree"' test.yml)
read -r -d '' expected << EOM
# comment
apple: tree
EOM
assertEquals "$expected" "$X"
}
testEmptyEvalPipe() {
X=$(./yq e - < test.yml)
assertEquals 0 $?
}
testEmptyCommentsWithExpressionEval() {
read -r -d '' expected << EOM
# comment
apple: tree
EOM
X=$(./yq e '.apple="tree"' test.yml)
assertEquals "$expected" "$X"
}
testEmptyCommentsWithExpressionEvalAll() {
read -r -d '' expected << EOM
# comment
apple: tree
EOM
X=$(./yq ea '.apple="tree"' test.yml)
assertEquals "$expected" "$X"
}
testEmptyWithExpressionEval() {
rm test.yml
touch test.yml
expected="apple: tree"
X=$(./yq e '.apple="tree"' test.yml)
assertEquals "$expected" "$X"
}
testEmptyWithExpressionEvalAll() {
rm test.yml
touch test.yml
expected="apple: tree"
X=$(./yq ea '.apple="tree"' test.yml)
assertEquals "$expected" "$X"
}
source ./scripts/shunit2
+76
View File
@@ -0,0 +1,76 @@
#!/bin/bash
setUp() {
rm test*.yml || true
cat >test.yml <<EOL
---
a: apple
b: cat
---
not yaml
c: at
EOL
}
testFrontMatterProcessEval() {
read -r -d '' expected << EOM
---
a: apple
b: dog
---
not yaml
c: at
EOM
./yq e --front-matter="process" '.b = "dog"' test.yml -i
assertEquals "$expected" "$(cat test.yml)"
}
testFrontMatterProcessEvalAll() {
read -r -d '' expected << EOM
---
a: apple
b: dog
---
not yaml
c: at
EOM
./yq ea --front-matter="process" '.b = "dog"' test.yml -i
assertEquals "$expected" "$(cat test.yml)"
}
testFrontMatterExtractEval() {
cat >test.yml <<EOL
a: apple
b: cat
---
not yaml
c: at
EOL
read -r -d '' expected << EOM
a: apple
b: dog
EOM
./yq e --front-matter="extract" '.b = "dog"' test.yml -i
assertEquals "$expected" "$(cat test.yml)"
}
testFrontMatterExtractEvalAll() {
cat >test.yml <<EOL
a: apple
b: cat
---
not yaml
c: at
EOL
read -r -d '' expected << EOM
a: apple
b: dog
EOM
./yq ea --front-matter="extract" '.b = "dog"' test.yml -i
assertEquals "$expected" "$(cat test.yml)"
}
source ./scripts/shunit2
+168
View File
@@ -0,0 +1,168 @@
#!/bin/bash
setUp() {
rm test*.yml 2>/dev/null || true
rm test*.properties 2>/dev/null || true
rm test*.csv 2>/dev/null || true
rm test*.tsv 2>/dev/null || true
rm test*.xml 2>/dev/null || true
}
testInputProperties() {
cat >test.properties <<EOL
mike.things = hello
EOL
read -r -d '' expected << EOM
mike:
things: hello
EOM
X=$(./yq e -p=props test.properties)
assertEquals "$expected" "$X"
X=$(./yq ea -p=props test.properties)
assertEquals "$expected" "$X"
}
testInputPropertiesGitHubAction() {
cat >test.properties <<EOL
mike.things = hello
EOL
read -r -d '' expected << EOM
mike:
things: hello
EOM
X=$(cat /dev/null | ./yq e -p=props test.properties)
assertEquals "$expected" "$X"
X=$(cat /dev/null | ./yq ea -p=props test.properties)
assertEquals "$expected" "$X"
}
testInputCSV() {
cat >test.csv <<EOL
fruit,yumLevel
apple,5
banana,4
EOL
read -r -d '' expected << EOM
- fruit: apple
yumLevel: 5
- fruit: banana
yumLevel: 4
EOM
X=$(./yq e -p=csv test.csv)
assertEquals "$expected" "$X"
X=$(./yq ea -p=csv test.csv)
assertEquals "$expected" "$X"
}
testInputTSV() {
cat >test.tsv <<EOL
fruit yumLevel
apple 5
banana 4
EOL
read -r -d '' expected << EOM
- fruit: apple
yumLevel: 5
- fruit: banana
yumLevel: 4
EOM
X=$(./yq e -p=t test.tsv)
assertEquals "$expected" "$X"
X=$(./yq ea -p=t test.tsv)
assertEquals "$expected" "$X"
}
testInputXml() {
cat >test.yml <<EOL
<cat legs="4">BiBi</cat>
EOL
read -r -d '' expected << EOM
cat:
+content: BiBi
+legs: "4"
EOM
X=$(./yq e -p=xml test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea -p=xml test.yml)
assertEquals "$expected" "$X"
}
testInputXmlNamespaces() {
cat >test.yml <<EOL
<?xml version="1.0"?>
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url">
</map>
EOL
read -r -d '' expected << EOM
map:
+xmlns: some-namespace
+xmlns:xsi: some-instance
+xsi:schemaLocation: some-url
EOM
X=$(./yq e -p=xml test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea -p=xml test.yml)
assertEquals "$expected" "$X"
}
testInputXmlStrict() {
cat >test.yml <<EOL
<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY writer "Catherine.">
<!ENTITY copyright "(r) Great">
]>
<root>
<item>&writer;&copyright;</item>
</root>
EOL
X=$(./yq -p=xml --xml-strict-mode test.yml 2>&1)
assertEquals 1 $?
assertEquals "Error: bad file 'test.yml': XML syntax error on line 7: invalid character entity &writer;" "$X"
X=$(./yq ea -p=xml --xml-strict-mode test.yml 2>&1)
assertEquals "Error: bad file 'test.yml': XML syntax error on line 7: invalid character entity &writer;" "$X"
}
testInputXmlGithubAction() {
cat >test.yml <<EOL
<cat legs="4">BiBi</cat>
EOL
read -r -d '' expected << EOM
cat:
+content: BiBi
+legs: "4"
EOM
X=$(cat /dev/null | ./yq e -p=xml test.yml)
assertEquals "$expected" "$X"
X=$(cat /dev/null | ./yq ea -p=xml test.yml)
assertEquals "$expected" "$X"
}
source ./scripts/shunit2
+450
View File
@@ -0,0 +1,450 @@
#!/bin/bash
setUp() {
rm test*.yml || true
cat >test.yml <<EOL
---
a: test
EOL
}
testLeadingSeperatorWithDoc() {
cat >test.yml <<EOL
# hi peeps
# cool
---
a: test
---
b: cool
EOL
read -r -d '' expected << EOM
# hi peeps
# cool
---
a: thing
---
b: cool
EOM
X=$(./yq e '(select(di == 0) | .a) = "thing"' - < test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorPipeIntoEvalSeq() {
X=$(./yq e - < test.yml)
expected=$(cat test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorExtractField() {
X=$(./yq e '.a' - < test.yml)
assertEquals "test" "$X"
}
testLeadingSeperatorExtractFieldWithCommentsAfterSep() {
cat >test.yml <<EOL
---
# hi peeps
# cool
a: test
EOL
X=$(./yq e '.a' test.yml)
assertEquals "test" "$X"
}
testLeadingSeperatorExtractFieldWithCommentsBeforeSep() {
cat >test.yml <<EOL
# hi peeps
# cool
---
a: test
EOL
X=$(./yq e '.a' test.yml)
assertEquals "test" "$X"
}
testLeadingSeperatorExtractFieldMultiDoc() {
cat >test.yml <<EOL
---
a: test
---
a: test2
EOL
read -r -d '' expected << EOM
test
---
test2
EOM
X=$(./yq e '.a' test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorExtractFieldMultiDocWithComments() {
cat >test.yml <<EOL
# here
---
# there
a: test
# whereever
---
# you are
a: test2
# woop
EOL
read -r -d '' expected << EOM
test
---
test2
EOM
X=$(./yq e '.a' test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorEvalSeq() {
X=$(./yq e test.yml)
expected=$(cat test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorPipeIntoEvalAll() {
X=$(./yq ea - < test.yml)
expected=$(cat test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorEvalAll() {
X=$(./yq ea test.yml)
expected=$(cat test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocEvalSimple() {
read -r -d '' expected << EOM
---
a: test
---
version: 3
application: MyApp
EOM
X=$(./yq e '.' test.yml examples/order.yaml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocInOneFile() {
cat >test.yml <<EOL
---
# hi peeps
# cool
a: test
---
b: things
EOL
expected=$(cat test.yml)
X=$(./yq e '.' test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocInOneFileEvalAll() {
cat >test.yml <<EOL
---
# hi peeps
# cool
a: test
---
b: things
EOL
expected=$(cat test.yml)
X=$(./yq ea '.' test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocEvalComments() {
cat >test.yml <<EOL
# hi peeps
# cool
a: test
EOL
cat >test2.yml <<EOL
# this is another doc
# great
b: sane
EOL
read -r -d '' expected << EOM
# hi peeps
# cool
a: test
---
# this is another doc
# great
b: sane
EOM
X=$(./yq e '.' test.yml test2.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocEvalCommentsTrailingSep() {
cat >test.yml <<EOL
# hi peeps
# cool
---
a: test
EOL
cat >test2.yml <<EOL
# this is another doc
# great
---
b: sane
EOL
read -r -d '' expected << EOM
# hi peeps
# cool
---
a: test
---
# this is another doc
# great
---
b: sane
EOM
X=$(./yq e '.' test.yml test2.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiMultiDocEvalCommentsTrailingSep() {
cat >test.yml <<EOL
# hi peeps
# cool
---
a: test
---
a1: test2
EOL
cat >test2.yml <<EOL
# this is another doc
# great
---
b: sane
---
b2: cool
EOL
read -r -d '' expected << EOM
# hi peeps
# cool
---
a: test
---
a1: test2
---
# this is another doc
# great
---
b: sane
---
b2: cool
EOM
X=$(./yq e '.' test.yml test2.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocEvalCommentsLeadingSep() {
cat >test.yml <<EOL
---
# hi peeps
# cool
a: test
EOL
cat >test2.yml <<EOL
---
# this is another doc
# great
b: sane
EOL
read -r -d '' expected << EOM
---
# hi peeps
# cool
a: test
---
# this is another doc
# great
b: sane
EOM
X=$(./yq e '.' test.yml test2.yml)
assertEquals "$expected" "$X"
}
# https://github.com/mikefarah/yq/issues/919
testLeadingSeparatorDoesNotBreakCommentsOnOtherFiles() {
cat >test.yml <<EOL
# a1
a: 1
# a2
EOL
cat >test2.yml <<EOL
# b1
b: 2
# b2
EOL
read -r -d '' expected << EOM
# a1
a: 1
# a2
# b1
b: 2
# b2
EOM
X=$(./yq ea 'select(fi == 0) * select(fi == 1)' test.yml test2.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocEvalCommentsStripComments() {
cat >test.yml <<EOL
---
# hi peeps
# cool
a: test
---
# this is another doc
# great
b: sane
EOL
# it will be hard to remove that top level separator
read -r -d '' expected << EOM
a: test
---
b: sane
EOM
X=$(./yq e '... comments=""' test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocEvalCommentsLeadingSepNoDocFlag() {
cat >test.yml <<EOL
---
# hi peeps
# cool
a: test
---
# this is another doc
# great
b: sane
EOL
read -r -d '' expected << EOM
# hi peeps
# cool
a: test
# this is another doc
# great
b: sane
EOM
X=$(./yq e '.' --no-doc test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocEvalJsonFlag() {
cat >test.yml <<EOL
---
# hi peeps
# cool
a: test
EOL
cat >test2.yml <<EOL
---
# this is another doc
# great
b: sane
EOL
read -r -d '' expected << EOM
{
"a": "test"
}
{
"b": "sane"
}
EOM
X=$(./yq e '.' -j test.yml test2.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocEvalAllJsonFlag() {
cat >test.yml <<EOL
---
# hi peeps
# cool
a: test
EOL
cat >test2.yml <<EOL
---
# this is another doc
# great
b: sane
EOL
read -r -d '' expected << EOM
{
"a": "test"
}
{
"b": "sane"
}
EOM
X=$(./yq ea '.' -j test.yml test2.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocEvalAll() {
read -r -d '' expected << EOM
---
a: test
---
version: 3
application: MyApp
EOM
X=$(./yq ea '.' test.yml examples/order.yaml)
assertEquals "$expected" "$X"
}
source ./scripts/shunit2
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
testLoadFileNotExist() {
result=$(./yq e -n 'load("cat.yml")' 2>&1)
assertEquals 1 $?
assertEquals "Error: Failed to load cat.yml: open cat.yml: no such file or directory" "$result"
}
testLoadFileExpNotExist() {
result=$(./yq e -n 'load(.a)' 2>&1)
assertEquals 1 $?
assertEquals "Error: Filename expression returned nil" "$result"
}
testStrLoadFileNotExist() {
result=$(./yq e -n 'strload("cat.yml")' 2>&1)
assertEquals 1 $?
assertEquals "Error: Failed to load cat.yml: open cat.yml: no such file or directory" "$result"
}
testStrLoadFileExpNotExist() {
result=$(./yq e -n 'strload(.a)' 2>&1)
assertEquals 1 $?
assertEquals "Error: Filename expression returned nil" "$result"
}
source ./scripts/shunit2
+208
View File
@@ -0,0 +1,208 @@
#!/bin/bash
setUp() {
rm test*.yml || true
}
testOutputJsonDeprecated() {
cat >test.yml <<EOL
a: {b: ["cat"]}
EOL
read -r -d '' expected << EOM
{
"a": {
"b": [
"cat"
]
}
}
EOM
X=$(./yq e -j test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea -j test.yml)
assertEquals "$expected" "$X"
}
testOutputJson() {
cat >test.yml <<EOL
a: {b: ["cat"]}
EOL
read -r -d '' expected << EOM
{
"a": {
"b": [
"cat"
]
}
}
EOM
X=$(./yq e --output-format=json test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea --output-format=json test.yml)
assertEquals "$expected" "$X"
}
testOutputJsonShort() {
cat >test.yml <<EOL
a: {b: ["cat"]}
EOL
read -r -d '' expected << EOM
{
"a": {
"b": [
"cat"
]
}
}
EOM
X=$(./yq e -o=j test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea -o=j test.yml)
assertEquals "$expected" "$X"
}
testOutputProperties() {
cat >test.yml <<EOL
a: {b: {c: ["cat"]}}
EOL
read -r -d '' expected << EOM
a.b.c.0 = cat
EOM
X=$(./yq e --output-format=props test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea --output-format=props test.yml)
assertEquals "$expected" "$X"
}
testOutputPropertiesShort() {
cat >test.yml <<EOL
a: {b: {c: ["cat"]}}
EOL
read -r -d '' expected << EOM
a.b.c.0 = cat
EOM
X=$(./yq e -o=p test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea -o=p test.yml)
assertEquals "$expected" "$X"
}
testOutputCSV() {
cat >test.yml <<EOL
- fruit: apple
yumLevel: 5
- fruit: banana
yumLevel: 4
EOL
read -r -d '' expected << EOM
fruit,yumLevel
apple,5
banana,4
EOM
X=$(./yq -o=c test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea -o=csv test.yml)
assertEquals "$expected" "$X"
}
testOutputTSV() {
cat >test.yml <<EOL
- fruit: apple
yumLevel: 5
- fruit: banana
yumLevel: 4
EOL
read -r -d '' expected << EOM
fruit yumLevel
apple 5
banana 4
EOM
X=$(./yq -o=t test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea -o=tsv test.yml)
assertEquals "$expected" "$X"
}
testOutputXml() {
cat >test.yml <<EOL
a: {b: {c: ["cat"]}}
EOL
read -r -d '' expected << EOM
<a>
<b>
<c>cat</c>
</b>
</a>
EOM
X=$(./yq e --output-format=xml test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea --output-format=xml test.yml)
assertEquals "$expected" "$X"
}
testOutputXmlShort() {
cat >test.yml <<EOL
a: {b: {c: ["cat"]}}
EOL
read -r -d '' expected << EOM
<a>
<b>
<c>cat</c>
</b>
</a>
EOM
X=$(./yq e --output-format=x test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea --output-format=x test.yml)
assertEquals "$expected" "$X"
}
testOutputXmComplex() {
cat >test.yml <<EOL
a: {b: {c: ["cat", "dog"], +f: meow}}
EOL
read -r -d '' expected << EOM
<a>
<b f="meow">
<c>cat</c>
<c>dog</c>
</b>
</a>
EOM
X=$(./yq e --output-format=x test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea --output-format=x test.yml)
assertEquals "$expected" "$X"
}
source ./scripts/shunit2
+70
View File
@@ -0,0 +1,70 @@
#!/bin/bash
setUp() {
rm test*.yml || true
cat >test.yml <<EOL
a: frog
EOL
}
testPipeViaCatWithParam() {
X=$(cat test.yml | ./yq '.a')
assertEquals "frog" "$X"
}
testPipeViaCatWithParamEval() {
X=$(cat test.yml | ./yq e '.a')
assertEquals "frog" "$X"
}
testPipeViaCatWithParamEvalAll() {
X=$(cat test.yml | ./yq ea '.a')
assertEquals "frog" "$X"
}
testPipeViaCatNoParam() {
X=$(cat test.yml | ./yq)
assertEquals "a: frog" "$X"
}
testPipeViaCatNoParamEval() {
X=$(cat test.yml | ./yq e)
assertEquals "a: frog" "$X"
}
testPipeViaCatNoParamEvalAll() {
X=$(cat test.yml | ./yq ea)
assertEquals "a: frog" "$X"
}
testPipeViaFileishWithParam() {
X=$(./yq '.a' < test.yml)
assertEquals "frog" "$X"
}
testPipeViaFileishWithParamEval() {
X=$(./yq e '.a' < test.yml)
assertEquals "frog" "$X"
}
testPipeViaFileishWithParamEvalAll() {
X=$(./yq ea '.a' < test.yml)
assertEquals "frog" "$X"
}
testPipeViaFileishNoParam() {
X=$(./yq < test.yml)
assertEquals "a: frog" "$X"
}
testPipeViaFileishNoParamEval() {
X=$(./yq e < test.yml)
assertEquals "a: frog" "$X"
}
testPipeViaFileishNoParamEvalAll() {
X=$(./yq ea < test.yml)
assertEquals "a: frog" "$X"
}
source ./scripts/shunit2
+176
View File
@@ -0,0 +1,176 @@
#!/bin/bash
setUp() {
rm test*.yml || true
}
testPrettyPrintWithBooleans() {
cat >test.yml <<EOL
leaveUnquoted: [yes, no, on, off, y, n, true, false]
leaveQuoted: ["yes", "no", "on", "off", "y", "n", "true", "false"]
EOL
read -r -d '' expected << EOM
leaveUnquoted:
- yes
- no
- on
- off
- y
- n
- true
- false
leaveQuoted:
- "yes"
- "no"
- "on"
- "off"
- "y"
- "n"
- "true"
- "false"
EOM
X=$(./yq e --prettyPrint test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea --prettyPrint test.yml)
assertEquals "$expected" "$X"
}
testPrettyPrintWithBooleansCapitals() {
cat >test.yml <<EOL
leaveUnquoted: [YES, NO, ON, OFF, Y, N, TRUE, FALSE]
leaveQuoted: ["YES", "NO", "ON", "OFF", "Y", "N", "TRUE", "FALSE"]
EOL
read -r -d '' expected << EOM
leaveUnquoted:
- YES
- NO
- ON
- OFF
- Y
- N
- TRUE
- FALSE
leaveQuoted:
- "YES"
- "NO"
- "ON"
- "OFF"
- "Y"
- "N"
- "TRUE"
- "FALSE"
EOM
X=$(./yq e --prettyPrint test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea --prettyPrint test.yml)
assertEquals "$expected" "$X"
}
testPrettyPrintOtherStringValues() {
cat >test.yml <<EOL
leaveUnquoted: [yesSir, hellno, bonapite]
makeUnquoted: ["yesSir", "hellno", "bonapite"]
EOL
read -r -d '' expected << EOM
leaveUnquoted:
- yesSir
- hellno
- bonapite
makeUnquoted:
- yesSir
- hellno
- bonapite
EOM
X=$(./yq e --prettyPrint test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea --prettyPrint test.yml)
assertEquals "$expected" "$X"
}
testPrettyPrintKeys() {
cat >test.yml <<EOL
"removeQuotes": "please"
EOL
read -r -d '' expected << EOM
removeQuotes: please
EOM
X=$(./yq e --prettyPrint test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea --prettyPrint test.yml)
assertEquals "$expected" "$X"
}
testPrettyPrintOtherStringValues() {
cat >test.yml <<EOL
leaveUnquoted: [yesSir, hellno, bonapite]
makeUnquoted: ["yesSir", "hellno", "bonapite"]
EOL
read -r -d '' expected << EOM
leaveUnquoted:
- yesSir
- hellno
- bonapite
makeUnquoted:
- yesSir
- hellno
- bonapite
EOM
X=$(./yq e --prettyPrint test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea --prettyPrint test.yml)
assertEquals "$expected" "$X"
}
testPrettyPrintStringBlocks() {
cat >test.yml <<EOL
"removeQuotes": |
"please"
EOL
read -r -d '' expected << EOM
removeQuotes: |
"please"
EOM
X=$(./yq e --prettyPrint test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea --prettyPrint test.yml)
assertEquals "$expected" "$X"
}
testPrettyPrintWithExpression() {
cat >test.yml <<EOL
a: {b: {c: ["cat"]}}
EOL
read -r -d '' expected << EOM
b:
c:
- cat
EOM
X=$(./yq e '.a' --prettyPrint test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea '.a' --prettyPrint test.yml)
assertEquals "$expected" "$X"
}
source ./scripts/shunit2
+207
View File
@@ -0,0 +1,207 @@
#!/bin/bash
setUp() {
rm test*.yml || true
}
testBasicSplitWithName() {
cat >test.yml <<EOL
a: test_doc1
---
a: test_doc2
EOL
./yq e test.yml -s ".a"
doc1=$(cat test_doc1.yml)
assertEquals "a: test_doc1" "$doc1"
doc2=$(cat test_doc2.yml)
read -r -d '' expectedDoc2 << EOM
---
a: test_doc2
EOM
assertEquals "$expectedDoc2" "$doc2"
}
testBasicSplitWithNameCustomExtension() {
rm test*.yaml || true
cat >test.yml <<EOL
a: test_doc1
---
a: test_doc2
EOL
./yq e test.yml -s '.a + ".yaml"'
doc1=$(cat test_doc1.yaml)
assertEquals "a: test_doc1" "$doc1"
doc2=$(cat test_doc2.yaml)
read -r -d '' expectedDoc2 << EOM
---
a: test_doc2
EOM
assertEquals "$expectedDoc2" "$doc2"
}
testSplitFromFile() {
cat >test.yml <<EOL
a: test_doc1
---
a: test_doc2
EOL
cat >test_splitExp.yml <<EOL
.a
EOL
./yq test.yml --split-exp-file test_splitExp.yml
doc1=$(cat test_doc1.yml)
assertEquals "a: test_doc1" "$doc1"
doc2=$(cat test_doc2.yml)
read -r -d '' expectedDoc2 << EOM
---
a: test_doc2
EOM
assertEquals "$expectedDoc2" "$doc2"
}
testBasicSplitWithNameEvalAll() {
cat >test.yml <<EOL
a: test_doc1
---
a: test_doc2
EOL
./yq ea test.yml -s ".a"
doc1=$(cat test_doc1.yml)
assertEquals "a: test_doc1" "$doc1"
doc2=$(cat test_doc2.yml)
read -r -d '' expectedDoc2 << EOM
---
a: test_doc2
EOM
assertEquals "$expectedDoc2" "$doc2"
}
testBasicSplitWithIndex() {
cat >test.yml <<EOL
a: test_doc1
---
a: test_doc2
EOL
./yq e test.yml -s '"test_" + $index'
doc1=$(cat test_0.yml)
assertEquals "a: test_doc1" "$doc1"
doc2=$(cat test_1.yml)
read -r -d '' expectedDoc2 << EOM
---
a: test_doc2
EOM
assertEquals "$expectedDoc2" "$doc2"
}
testBasicSplitWithIndexEvalAll() {
cat >test.yml <<EOL
a: test_doc1
---
a: test_doc2
EOL
./yq ea test.yml -s '"test_" + $index'
doc1=$(cat test_0.yml)
assertEquals "a: test_doc1" "$doc1"
doc2=$(cat test_1.yml)
read -r -d '' expectedDoc2 << EOM
---
a: test_doc2
EOM
assertEquals "$expectedDoc2" "$doc2"
}
testArraySplitWithNameNoSeparators() {
cat >test.yml <<EOL
- name: test_fred
age: 35
- name: test_catherine
age: 37
EOL
./yq e --no-doc -s ".name" ".[]" test.yml
doc1=$(cat test_fred.yml)
read -r -d '' expectedDoc1 << EOM
name: test_fred
age: 35
EOM
assertEquals "$expectedDoc1" "$doc1"
doc2=$(cat test_catherine.yml)
read -r -d '' expectedDoc2 << EOM
name: test_catherine
age: 37
EOM
assertEquals "$expectedDoc2" "$doc2"
}
testArraySplitWithNameNoSeparatorsEvalAll() {
cat >test.yml <<EOL
- name: test_fred
age: 35
- name: test_catherine
age: 37
EOL
cat >test2.yml <<EOL
- name: test_mike
age: 564
EOL
./yq ea --no-doc -s ".name" ".[]" test.yml test2.yml
doc1=$(cat test_fred.yml)
read -r -d '' expectedDoc1 << EOM
name: test_fred
age: 35
EOM
assertEquals "$expectedDoc1" "$doc1"
doc2=$(cat test_catherine.yml)
read -r -d '' expectedDoc2 << EOM
name: test_catherine
age: 37
EOM
assertEquals "$expectedDoc2" "$doc2"
doc3=$(cat test_mike.yml)
read -r -d '' expectedDoc3 << EOM
name: test_mike
age: 564
EOM
assertEquals "$expectedDoc3" "$doc3"
}
source ./scripts/shunit2
+17
View File
@@ -0,0 +1,17 @@
name: 'yq - portable yaml processor'
description: 'create, read, update, delete, merge, validate and do more with yaml'
branding:
icon: command
color: gray-dark
inputs:
cmd:
description: 'The Command which should be run'
required: true
outputs:
result:
description: "The complete result from the yq command being run"
runs:
using: 'docker'
image: 'github-action/Dockerfile'
args:
- ${{ inputs.cmd }}
+38
View File
@@ -0,0 +1,38 @@
package cmd
var leadingContentPreProcessing = true
var unwrapScalar = true
var writeInplace = false
var outputToJSON = false
var outputFormat = "yaml"
var inputFormat = "yaml"
var xmlAttributePrefix = "+"
var xmlContentName = "+content"
var xmlStrictMode = false
var xmlKeepNamespace = true
var xmlUseRawToken = true
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
// can be either "" (off), "extract" or "process"
var frontMatter = ""
var splitFileExp = ""
var splitFileExpFile = ""
var completedSuccessfully = false
var forceExpression = ""
var expressionFile = ""
+128
View File
@@ -0,0 +1,128 @@
package cmd
import (
"errors"
"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: `
# Merge f2.yml into f1.yml (inplace)
yq eval-all --inplace 'select(fileIndex == 0) * select(fileIndex == 1)' f1.yml f2.yml
## the same command and expression using shortened names:
yq ea -i 'select(fi == 0) * select(fi == 1)' f1.yml f2.yml
# Merge all given files
yq ea '. as $item ireduce ({}; . * $item )' file1.yml file2.yml ...
# Pipe from STDIN
## use '-' as a filename to pipe from STDIN
cat file2.yml | yq ea '.a.b' file1.yml - file3.yml
`,
Long: `yq is a portable command-line YAML processor (https://github.com/mikefarah/yq/)
See https://mikefarah.gitbook.io/yq/ for detailed documentation and examples.
## Evaluate All ##
This command loads _all_ yaml documents of _all_ yaml files and runs expression once
Useful when you need to run an expression across several yaml documents or files (like merge).
Note that it consumes more memory than eval.
`,
RunE: evaluateAll,
}
return cmdEvalAll
}
func evaluateAll(cmd *cobra.Command, args []string) (cmdError error) {
// 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
expression, args, err := initCommand(cmd, args)
if err != nil {
return err
}
out := cmd.OutOrStdout()
if writeInplace {
// only use colors if its forced
colorsEnabled = forceColor
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[0])
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() {
if cmdError == nil {
cmdError = writeInPlaceHandler.FinishWriteInPlace(completedSuccessfully)
}
}()
}
format, err := yqlib.OutputFormatFromString(outputFormat)
if err != nil {
return err
}
decoder, err := configureDecoder()
if err != nil {
return err
}
printerWriter, err := configurePrinterWriter(format, out)
if err != nil {
return err
}
encoder := configureEncoder(format)
printer := yqlib.NewPrinter(encoder, printerWriter)
if frontMatter != "" {
frontMatterHandler := yqlib.NewFrontMatterHandler(args[0])
err = frontMatterHandler.Split()
if err != nil {
return err
}
args[0] = frontMatterHandler.GetYamlFrontMatterFilename()
if frontMatter == "process" {
reader := frontMatterHandler.GetContentReader()
printer.SetAppendix(reader)
defer yqlib.SafelyCloseReader(reader)
}
defer frontMatterHandler.CleanUp()
}
allAtOnceEvaluator := yqlib.NewAllAtOnceEvaluator()
switch len(args) {
case 0:
if nullInput {
err = yqlib.NewStreamEvaluator().EvaluateNew(processExpression(expression), printer, "")
} else {
cmd.Println(cmd.UsageString())
return nil
}
default:
err = allAtOnceEvaluator.EvaluateFiles(processExpression(expression), args, printer, leadingContentPreProcessing, decoder)
}
completedSuccessfully = err == nil
if err == nil && exitStatus && !printer.PrintedAnything() {
return errors.New("no matches found")
}
return err
}
+141
View File
@@ -0,0 +1,141 @@
package cmd
import (
"errors"
"fmt"
"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: "(default) Apply the expression to each document in each yaml file in sequence",
Example: `
# Reads field under the given path for each file
yq e '.a.b' f1.yml f2.yml
# Prints out the file
yq e sample.yaml
# Pipe from STDIN
## use '-' as a filename to pipe from STDIN
cat file2.yml | yq e '.a.b' file1.yml - file3.yml
# Creates a new yaml document
## Note that editing an empty file does not work.
yq e -n '.a.b.c = "cat"'
# Update a file inplace
yq e '.a.b = "cool"' -i file.yaml
`,
Long: `yq is a portable command-line YAML processor (https://github.com/mikefarah/yq/)
See https://mikefarah.gitbook.io/yq/ for detailed documentation and examples.
## Evaluate Sequence ##
This command iterates over each yaml document from each given file, applies the
expression and prints the result in sequence.`,
RunE: evaluateSequence,
}
return cmdEvalSequence
}
func processExpression(expression string) string {
if prettyPrint && expression == "" {
return yqlib.PrettyPrintExp
} else if prettyPrint {
return fmt.Sprintf("%v | %v", expression, yqlib.PrettyPrintExp)
}
return expression
}
func evaluateSequence(cmd *cobra.Command, args []string) (cmdError error) {
// 0 args, read std in
// 1 arg, null input, process expression
// 1 arg, read file in sequence
// 2+ args, [0] = expression, file the rest
out := cmd.OutOrStdout()
var err error
expression, args, err := initCommand(cmd, args)
if err != nil {
return err
}
if writeInplace {
// only use colors if its forced
colorsEnabled = forceColor
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[0])
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() {
if cmdError == nil {
cmdError = writeInPlaceHandler.FinishWriteInPlace(completedSuccessfully)
}
}()
}
format, err := yqlib.OutputFormatFromString(outputFormat)
if err != nil {
return err
}
printerWriter, err := configurePrinterWriter(format, out)
if err != nil {
return err
}
encoder := configureEncoder(format)
printer := yqlib.NewPrinter(encoder, printerWriter)
decoder, err := configureDecoder()
if err != nil {
return err
}
streamEvaluator := yqlib.NewStreamEvaluator()
if frontMatter != "" {
yqlib.GetLogger().Debug("using front matter handler")
frontMatterHandler := yqlib.NewFrontMatterHandler(args[0])
err = frontMatterHandler.Split()
if err != nil {
return err
}
args[0] = frontMatterHandler.GetYamlFrontMatterFilename()
if frontMatter == "process" {
reader := frontMatterHandler.GetContentReader()
printer.SetAppendix(reader)
defer yqlib.SafelyCloseReader(reader)
}
defer frontMatterHandler.CleanUp()
}
switch len(args) {
case 0:
if nullInput {
err = streamEvaluator.EvaluateNew(processExpression(expression), printer, "")
} else {
cmd.Println(cmd.UsageString())
return nil
}
default:
err = streamEvaluator.EvaluateFiles(processExpression(expression), args, printer, leadingContentPreProcessing, decoder)
}
completedSuccessfully = err == nil
if err == nil && exitStatus && !printer.PrintedAnything() {
return errors.New("no matches found")
}
return err
}
+105
View File
@@ -0,0 +1,105 @@
package cmd
import (
"os"
"github.com/mikefarah/yq/v4/pkg/yqlib"
"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 portable command-line YAML processor (https://github.com/mikefarah/yq/)
See https://mikefarah.gitbook.io/yq/ for detailed documentation and examples.`,
Example: `
# yq defaults to 'eval' command if no command is specified. See "yq eval --help" for more examples.
# read the "stuff" node from "myfile.yml"
yq '.stuff' < myfile.yml
# update myfile.yml in place
yq -i '.stuff = "foo"' myfile.yml
# print contents of sample.json as idiomatic YAML
yq -P sample.json
`,
RunE: func(cmd *cobra.Command, args []string) error {
if version {
cmd.Print(GetVersionDisplay())
return nil
}
return evaluateSequence(cmd, args)
},
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)
yqlib.InitExpressionParser()
yqlib.XMLPreferences.AttributePrefix = xmlAttributePrefix
yqlib.XMLPreferences.ContentName = xmlContentName
yqlib.XMLPreferences.StrictMode = xmlStrictMode
},
}
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose mode")
rootCmd.PersistentFlags().BoolVarP(&outputToJSON, "tojson", "j", false, "(deprecated) output as json. Set indent to 0 to print json in one line.")
err := rootCmd.PersistentFlags().MarkDeprecated("tojson", "please use -o=json instead")
if err != nil {
panic(err)
}
rootCmd.PersistentFlags().StringVarP(&outputFormat, "output-format", "o", "yaml", "[yaml|y|json|j|props|p|xml|x] output format type.")
rootCmd.PersistentFlags().StringVarP(&inputFormat, "input-format", "p", "yaml", "[yaml|y|props|p|xml|x] parse format for input. Note that json is a subset of yaml.")
rootCmd.PersistentFlags().StringVar(&xmlAttributePrefix, "xml-attribute-prefix", "+", "prefix for xml attributes")
rootCmd.PersistentFlags().StringVar(&xmlContentName, "xml-content-name", "+content", "name for xml content (if no attribute name is present).")
rootCmd.PersistentFlags().BoolVar(&xmlStrictMode, "xml-strict-mode", false, "enables strict parsing of XML. See https://pkg.go.dev/encoding/xml for more details.")
rootCmd.PersistentFlags().BoolVar(&xmlKeepNamespace, "xml-keep-namespace", true, "enables keeping namespace after parsing attributes")
rootCmd.PersistentFlags().BoolVar(&xmlUseRawToken, "xml-raw-token", true, "enables using RawToken method instead Token. Commonly disables namespace translations. See https://pkg.go.dev/encoding/xml#Decoder.RawToken for details.")
rootCmd.PersistentFlags().BoolVarP(&nullInput, "null-input", "n", false, "Don't read input, simply evaluate the expression given. Useful for creating 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 file inplace of first file given.")
rootCmd.PersistentFlags().BoolVarP(&unwrapScalar, "unwrapScalar", "r", 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.PersistentFlags().StringVarP(&frontMatter, "front-matter", "f", "", "(extract|process) first input as yaml front-matter. Extract will pull out the yaml content, process will run the expression against the yaml content, leaving the remaining data intact")
rootCmd.PersistentFlags().StringVarP(&forceExpression, "expression", "", "", "forcibly set the expression argument. Useful when yq argument detection thinks your expression is a file.")
rootCmd.PersistentFlags().BoolVarP(&leadingContentPreProcessing, "header-preprocess", "", true, "Slurp any header comments and separators before processing expression.")
rootCmd.PersistentFlags().StringVarP(&splitFileExp, "split-exp", "s", "", "print each result (or doc) into a file named (exp). [exp] argument must return a string. You can use $index in the expression as the result counter.")
rootCmd.PersistentFlags().StringVarP(&splitFileExpFile, "split-exp-file", "", "", "Use a file to specify the split-exp expression.")
rootCmd.PersistentFlags().StringVarP(&expressionFile, "from-file", "", "", "Load expression from specified file.")
rootCmd.AddCommand(
createEvaluateSequenceCommand(),
createEvaluateAllCommand(),
completionCmd,
)
return rootCmd
}
+61
View 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
},
}
+177
View File
@@ -0,0 +1,177 @@
package cmd
import (
"fmt"
"io"
"os"
"github.com/mikefarah/yq/v4/pkg/yqlib"
"github.com/spf13/cobra"
"gopkg.in/op/go-logging.v1"
)
func initCommand(cmd *cobra.Command, args []string) (string, []string, error) {
cmd.SilenceUsage = true
fileInfo, _ := os.Stdout.Stat()
if forceColor || (!forceNoColor && (fileInfo.Mode()&os.ModeCharDevice) != 0) {
colorsEnabled = true
}
expression, args, err := processArgs(args)
if err != nil {
return "", nil, err
}
if splitFileExpFile != "" {
splitExpressionBytes, err := os.ReadFile(splitFileExpFile)
if err != nil {
return "", nil, err
}
splitFileExp = string(splitExpressionBytes)
}
// backwards compatibility
if outputToJSON {
outputFormat = "json"
}
if writeInplace && (len(args) == 0 || args[0] == "-") {
return "", nil, fmt.Errorf("write inplace flag only applicable when giving an expression and at least one file")
}
if frontMatter != "" && len(args) == 0 {
return "", nil, fmt.Errorf("front matter flag only applicable when giving an expression and at least one file")
}
if writeInplace && splitFileExp != "" {
return "", nil, fmt.Errorf("write inplace cannot be used with split file")
}
if nullInput && len(args) > 0 {
return "", nil, fmt.Errorf("cannot pass files in when using null-input flag")
}
return expression, args, nil
}
func configureDecoder() (yqlib.Decoder, error) {
yqlibInputFormat, err := yqlib.InputFormatFromString(inputFormat)
if err != nil {
return nil, err
}
switch yqlibInputFormat {
case yqlib.XMLInputFormat:
return yqlib.NewXMLDecoder(xmlAttributePrefix, xmlContentName, xmlStrictMode, xmlKeepNamespace, xmlUseRawToken), nil
case yqlib.PropertiesInputFormat:
return yqlib.NewPropertiesDecoder(), nil
case yqlib.JsonInputFormat:
return yqlib.NewJSONDecoder(), nil
case yqlib.CSVObjectInputFormat:
return yqlib.NewCSVObjectDecoder(','), nil
case yqlib.TSVObjectInputFormat:
return yqlib.NewCSVObjectDecoder('\t'), nil
}
return yqlib.NewYamlDecoder(), nil
}
func configurePrinterWriter(format yqlib.PrinterOutputFormat, out io.Writer) (yqlib.PrinterWriter, error) {
var printerWriter yqlib.PrinterWriter
if splitFileExp != "" {
colorsEnabled = forceColor
splitExp, err := yqlib.ExpressionParser.ParseExpression(splitFileExp)
if err != nil {
return nil, fmt.Errorf("bad split document expression: %w", err)
}
printerWriter = yqlib.NewMultiPrinterWriter(splitExp, format)
} else {
printerWriter = yqlib.NewSinglePrinterWriter(out)
}
return printerWriter, nil
}
func configureEncoder(format yqlib.PrinterOutputFormat) yqlib.Encoder {
switch format {
case yqlib.JSONOutputFormat:
return yqlib.NewJSONEncoder(indent, colorsEnabled)
case yqlib.PropsOutputFormat:
return yqlib.NewPropertiesEncoder(unwrapScalar)
case yqlib.CSVOutputFormat:
return yqlib.NewCsvEncoder(',')
case yqlib.TSVOutputFormat:
return yqlib.NewCsvEncoder('\t')
case yqlib.YamlOutputFormat:
return yqlib.NewYamlEncoder(indent, colorsEnabled, !noDocSeparators, unwrapScalar)
case yqlib.XMLOutputFormat:
return yqlib.NewXMLEncoder(indent, xmlAttributePrefix, xmlContentName)
}
panic("invalid encoder")
}
// this is a hack to enable backwards compatibility with githubactions (which pipe /dev/null into everything)
// and being able to call yq with the filename as a single parameter
//
// without this - yq detects there is stdin (thanks githubactions),
// then tries to parse the filename as an expression
func maybeFile(str string) bool {
yqlib.GetLogger().Debugf("checking '%v' is a file", str)
stat, err := os.Stat(str) // #nosec
result := err == nil && !stat.IsDir()
if yqlib.GetLogger().IsEnabledFor(logging.DEBUG) {
if err != nil {
yqlib.GetLogger().Debugf("error: %v", err)
} else {
yqlib.GetLogger().Debugf("error: %v, dir: %v", err, stat.IsDir())
}
yqlib.GetLogger().Debugf("result: %v", result)
}
return result
}
func processStdInArgs(args []string) []string {
stat, _ := os.Stdin.Stat()
pipingStdin := (stat.Mode() & os.ModeCharDevice) == 0
// if we've been given a file, don't automatically
// read from stdin.
// this happens if there is more than one argument
// or only one argument and its a file
if nullInput || !pipingStdin || len(args) > 1 || (len(args) > 0 && maybeFile(args[0])) {
return args
}
for _, arg := range args {
if arg == "-" {
return args
}
}
yqlib.GetLogger().Debugf("missing '-', adding it to the end")
// we're piping from stdin, but there's no '-' arg
// lets add one to the end
return append(args, "-")
}
func processArgs(originalArgs []string) (string, []string, error) {
expression := forceExpression
if expressionFile != "" {
expressionBytes, err := os.ReadFile(expressionFile)
if err != nil {
return "", nil, err
}
expression = string(expressionBytes)
}
args := processStdInArgs(originalArgs)
yqlib.GetLogger().Debugf("processed args: %v", args)
if expression == "" && len(args) > 0 && args[0] != "-" && !maybeFile(args[0]) {
yqlib.GetLogger().Debug("assuming expression is '%v'", args[0])
expression = args[0]
args = args[1:]
}
return expression, args, nil
}
+49
View 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.26.1"
// 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("yq (https://github.com/mikefarah/yq/) version %s\n", 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
View File
@@ -0,0 +1,51 @@
package cmd
import "testing"
func TestGetVersionDisplay(t *testing.T) {
var expectedVersion = ProductName + " (https://github.com/mikefarah/yq/) 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)
}
}
}
-50
View File
@@ -1,50 +0,0 @@
package main
import (
// "fmt"
"log"
"strconv"
)
func write(context map[interface{}]interface{}, head string, tail []string, value interface{}) {
// 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{} {
value := context[head]
if len(tail) > 0 {
return recurse(value, tail[0], tail[1:len(tail)])
}
return value
}
func recurse(value interface{}, head string, tail []string) interface{} {
switch value.(type) {
case []interface{}:
index, err := strconv.ParseInt(head, 10, 64)
if err != nil {
log.Fatalf("Error accessing array: %v", err)
}
return readArray(value.([]interface{}), index, tail)
case nil:
return nil
default:
return readMap(value.(map[interface{}]interface{}), head, tail)
}
}
func readArray(array []interface{}, head int64, tail []string) interface{} {
if head > int64(len(array)) {
return nil
}
value := array[head]
if len(tail) > 0 {
return recurse(value, tail[0], tail[1:len(tail)])
}
return value
}
-64
View File
@@ -1,64 +0,0 @@
package main
import (
"fmt"
"gopkg.in/yaml.v2"
"os"
"testing"
)
var rawData = `
a: Easy!
b:
c: 2
d: [3, 4]
`
var parsedData map[interface{}]interface{}
func TestMain(m *testing.M) {
err := yaml.Unmarshal([]byte(rawData), &parsedData)
if err != nil {
fmt.Println("Error parsing yaml: %v", err)
os.Exit(1)
}
os.Exit(m.Run())
}
func TestReadMap_simple(t *testing.T) {
assertResult(t, 2, readMap(parsedData, "b", []string{"c"}))
}
func TestReadMap_key_doesnt_exist(t *testing.T) {
assertResult(t, nil, readMap(parsedData, "b.x.f", []string{"c"}))
}
func TestReadMap_with_array(t *testing.T) {
assertResult(t, 4, readMap(parsedData, "b", []string{"d", "1"}))
}
func TestReadMap_with_array_out_of_bounds(t *testing.T) {
assertResult(t, nil, readMap(parsedData, "b", []string{"d", "3"}))
}
func TestWrite_simple(t *testing.T) {
write(parsedData, "b", []string{"c"}, "4")
b := parsedData["b"].(map[interface{}]interface{})
assertResult(t, "4", b["c"].(string))
}
func assertResult(t *testing.T, expectedValue interface{}, actualValue interface{}) {
if expectedValue != actualValue {
t.Error("Expected <", expectedValue, "> but got <", 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, ">")
}
}
+210
View File
@@ -0,0 +1,210 @@
yq (4.16.2) focal; urgency=medium
* Fixed with semicolon space issue
* Updating with documentation
* Added STDIN example to the top
* minor readme cleanup
* Help text tweak
* Fixed docker timeout - simplify docker builds
* New release with docker build fixes
* Updating to go 1.17 to fix CVE #944
* Fix a typo in root.go
* Skip the tests if the nocheck Debian build option is specified
* Fixed select bug (#958)
* Sped up explode operator
* Slight performance improvement to context.ChildContext
* Speed up multiply
* Update README with recently added / changed options
* Make deepMatch report in linear time
* Removed leadingContentPreProcessing flag - header preprocessing is stable
* Revert "Removed leadingContentPreProcessing flag - header preprocessing is stable"
* Keep flag, it is needed in corner cases
* Updated Readme
* Man page
* Fixed expression parsing bug #970
* Bumping go-lang, docker versions
* Added test release flow
* Updated github action release to generate man page
* Bumping version
* Removing no longer needed github action
* Added decoder op
* Fixed newline handling when decoding/encoding
* Fixed newline handling in encoder/decoder
* Can specify indent in encode ops
* Added group_by operator
* Added flatten operator
* Fixed flatten error message
* Improving docs
* Split printer
* Refactored command logic
* Fix JSON encoding removing null #985
* Fixed acceptance tests
* gitbook
* Update document generation script
* Updating README
* Updating release instructions
* github action no longer uses data1.yml
* Create dependabot.yml
* Bump actions/create-release from 1.0.0 to 1.1.4
* Bump actions/setup-go from 1 to 2.1.4
* Bump github.com/goccy/go-yaml from 1.8.9 to 1.9.4
* Bump github.com/jinzhu/copier from 0.2.8 to 0.3.2
* Bump github.com/fatih/color from 1.10.0 to 1.13.0
* Bump github.com/spf13/cobra from 1.1.3 to 1.2.1
* Update dependabot.yml
* Update go.yml
* add build check to PRs
* Include secure as part of build process
* Fixing bad label in github action
* fixed printer test
* remove leading content indicator
* Fixed header preprocessing!
* lint : define golangci configuration file
* Update check.sh
* Load file acceptance test
* Minor improvement on handling front matter
* Improved load doc
* feature: detect MANPATh and install there
* Update install-man-page.sh
* simplify prod stage, move version label to action
* add labels, quote some values
* enable errorlint linter
* Added errorlint to devtools
* Added key operator
* Added more tests
* Fixing comments
* Attempt to fix golint problem
* Include version query for tools
* Clean up errored file?
* enable misspell linter
* updated readme
* update Golangci version to v1.43.0
* gci linter
* Better merge array by key example
* Added credit for merge by array example
* Better formatting of merge arrays example
* Better merge example
* Add accessor for the yq logger instance (#1013)
* Fixed collect op when working with multiple nodes
* Added map, map_values
* Add support for Podman as well as Docker (#1026)
* Bump github.com/jinzhu/copier from 0.3.2 to 0.3.4 (#1027)
* Added csv, tsv output formats
* Added encoder tests
* Cleanup test
* Fixed docker permission issue #1014
* Recording release notes for next release
* Assignment op no longer clobbers anchor (#1029)
* Added sort_by operator
* Improved error message
* Improved tips and tricks
* Report while filename failed to parse #1030
* Added script for extracting checksums
* Improved extract-checksum.sh
* Bump github.com/spf13/cobra from 1.2.1 to 1.3.0 (#1039)
* enable more linters (#1043)
* Bump golang compiler #1037
-- Roberto Mier Escandon <rmescandon@gmail.com> Tue, 21 Dec 2021 09:41:44 +0000
yq (4.13.0) focal; urgency=medium
* New `with` operator for making multiple changes to a given path
* New `contains` operator, works like the `jq` equivalent
* Subtract operator now supports subtracting elements from arrays!
* Fixed Swapping values using variables #934
* Github Action now properly supports multiline output #936, thanks @pjxiao
* Fixed missing closing bracket validation #932
* Fix processing of hex numbers #929
* Fixed alternative and union operator issues #930
* Can now convert yaml to properties properties format (`-o=props`), See [docs](https://mikefarah.gitbook.io/yq/v/v4.x/usage/properties) for more info.
* Fixed document header/footer comment handling when merging (https://github.com/mikefarah/yq/issues/919)
* pretty print yaml 1.1 compatibility (https://github.com/mikefarah/yq/issues/914)
-- Roberto Mier Escandon <rmescandon@gmail.com> Thu, 16 Sep 2021 20:58:30 +0200
yq (4.9.6) focal; urgency=medium
* Added darwin/arm64 build, thanks @alecthomas
* Incremented docker alpine base version, thanks @da6d6i7-bronga
* Bug fix: multine expression
* Bug fix: special character
-- Roberto Mier Escandon <rmescandon@gmail.com> Tue, 29 Jun 2021 21:32:14 +0200
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
View File
@@ -0,0 +1 @@
10
+22
View File
@@ -0,0 +1,22 @@
Source: yq
Section: devel
Priority: optional
Maintainer: Roberto Mier Escandón <rmescandon@gmail.com>
Build-Depends: debhelper (>=10),
golang-1.17-go,
pandoc,
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
View 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
View File
@@ -0,0 +1,2 @@
[DEFAULT]
pristine-tar = True
Vendored Executable
+74
View File
@@ -0,0 +1,74 @@
#!/usr/bin/make -f
#
# Copyright (C) 2018-2021 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
export DH_OPTIONS
export DH_GOPKG := ${REPO}/${OWNER}/${PROJECT}
export GOROOT := /usr/local/go
export GOPATH := ${CURDIR}/_build
export GOBIN := ${GOPATH}/bin
export PATH := ${GOROOT}/bin:${GOBIN}:${PATH}
export GOCACHE := /tmp/gocache
export GOFLAGS := -mod=vendor
export GO111MODULE := on
SRCDIR := ${GOPATH}/src/${DH_GOPKG}
DESTDIR := ${CURDIR}/debian/${PROJECT}
BINDIR := /usr/bin
MANDIR := /usr/share/man/man1/
ASSETSDIR := /usr/share/${PROJECT}
%:
dh $@
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 ./... \
)
# build man page
( \
cd ${SRCDIR} && \
./scripts/generate-man-page-md.sh && \
./scripts/generate-man-page.sh \
)
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
(cd ${SRCDIR} && go test -v ./...)
endif
override_dh_auto_install:
cp ${GOBIN}/yq ${DESTDIR}/${BINDIR}
cp -f ${SRCDIR}/LICENSE ${DESTDIR}/${ASSETSDIR}
chmod a+x ${DESTDIR}/${BINDIR}/yq
# man
mkdir -p "${DESTDIR}"/"${MANDIR}"
cp "${SRCDIR}"/yq.1 "${DESTDIR}"/"${MANDIR}" \
override_dh_auto_clean:
dh_clean
rm -rf ${CURDIR}/_build
+1
View File
@@ -0,0 +1 @@
3.0 (native)
+3
View File
@@ -0,0 +1,3 @@
usr/bin
usr/share/yq
usr/share/man/man1
+11
View 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
View File
@@ -0,0 +1,8 @@
b:
d: be gone
c: 2
e:
- name: Billy Bob # comment over here
---
[123123
+1
View File
@@ -0,0 +1 @@
bXkgc2VjcmV0IGNoaWxsaSByZWNpcGUgaXMuLi4u
+4
View File
@@ -0,0 +1,4 @@
a: simple
b: [1, 2]
c:
test: 1
+12
View File
@@ -0,0 +1,12 @@
# --------------------------------------------------
# It's a test with comment
# --------------------------------------------------
test:
- name: a
- name: b
- name: c
groups:
- name: a
- name: b
- name: c
- name: c
+5
View File
@@ -0,0 +1,5 @@
# --------------------------------------------------
# It's a test with comment
# --------------------------------------------------
groups:
- name: d
+4
View File
@@ -0,0 +1,4 @@
a: "simple" # just the best
b: [1, 3]
c:
test: 1
+1
View File
@@ -0,0 +1 @@
# comment
+6
View File
@@ -0,0 +1,6 @@
# comments on values appear
person.name = Mike
# comments on array values appear
person.pets.0 = cat
person.food.0 = pizza
+6
View File
@@ -0,0 +1,6 @@
---
a: apple
b: bannana
---
hello there
apples: great
+7
View File
@@ -0,0 +1,7 @@
- command: update
path: b.c
value:
#great
things: frog # wow!
- command: delete
path: b.d
+2
View File
@@ -0,0 +1,2 @@
---
a: test
+19
View 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
+14
View File
@@ -0,0 +1,14 @@
<!-- before cat -->
<cat>
<!-- in cat before -->
<x>3<!-- multi
line comment
for x --></x>
<y>
<!-- in y before -->
<d><!-- in d before -->4<!-- in d after --></d>
<!-- in y after -->
</y>
<!-- in_cat_after -->
</cat>
<!-- after cat -->
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- osm-->
<osm version="0.6" generator="CGImap 0.0.2">
<!-- bounds-->
<bounds minlat="54.0889580" minlon="12.2487570" maxlat="54.0913900" maxlon="12.2524800">
<!-- great -->
cool
</bounds>
<foo>ba2234r</foo>
<foo>bar2234233</foo>
</osm>
+5
View File
@@ -0,0 +1,5 @@
test: |
abcdefg
hijklmno
+18
View 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
View File
@@ -0,0 +1,7 @@
a: Easy! as one two three
---
another:
document: here
---
- 1
- 2
+2
View File
@@ -0,0 +1,2 @@
5:
6: camel!
+2
View File
@@ -0,0 +1,2 @@
version: 3
application: MyApp
+6
View File
@@ -0,0 +1,6 @@
version: '2'
services:
test:
image: ubuntu:14.04
stdin_open: true
tty: true
+1
View 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"}
+5 -3
View File
@@ -1,9 +1,11 @@
a: Easy! as one two three
# Some doc
a: true
b:
c: 2
d: [3, 4]
d: [3, 4, 5]
e:
- name: fred
value: 3
- name: sam
value: 4
value: 4
+1
View File
@@ -0,0 +1 @@
[1,2,3]
+2
View File
@@ -0,0 +1,2 @@
- 4
- 5
+3
View File
@@ -0,0 +1,3 @@
name,numberOfCats,likesApples,height
Gary,1,true,168.8
Samantha's Rabbit,2,false,-188.8
1 name numberOfCats likesApples height
2 Gary 1 true 168.8
3 Samantha's Rabbit 2 false -188.8
+1
View File
@@ -0,0 +1 @@
hi
+5
View File
@@ -0,0 +1,5 @@
foo:
a: 1
foobar:
a: 1
+5
View File
@@ -0,0 +1,5 @@
foo: &foo
a: 1
foobar:
<<: *foo
+1
View File
@@ -0,0 +1 @@
this.is = a properties file
+1
View File
@@ -0,0 +1 @@
<this>is some xml</this>
+2
View File
@@ -0,0 +1,2 @@
a: apple is included
b: cool.
+8
View File
@@ -0,0 +1,8 @@
FROM mikefarah/yq:4
COPY entrypoint.sh /entrypoint.sh
# this seems to be the default user in github actions
USER 1001
ENTRYPOINT ["/entrypoint.sh"]
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh -l
set -e
echo "::debug::\$cmd: $1"
RESULT=$(eval "$1")
RESULT="${RESULT//'%'/'%25'}"
RESULT="${RESULT//$'\n'/'%0A'}"
RESULT="${RESULT//$'\r'/'%0D'}"
echo "::debug::\$RESULT: $RESULT"
echo ::set-output name=result::"$RESULT"
+30
View File
@@ -0,0 +1,30 @@
module github.com/mikefarah/yq/v4
require (
github.com/a8m/envsubst v1.3.0
github.com/alecthomas/participle/v2 v2.0.0-beta.4
github.com/alecthomas/repr v0.1.0
github.com/elliotchance/orderedmap v1.4.0
github.com/fatih/color v1.13.0
github.com/goccy/go-json v0.9.10
github.com/goccy/go-yaml v1.9.5
github.com/jinzhu/copier v0.3.5
github.com/magiconair/properties v1.8.6
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e
github.com/spf13/cobra v1.5.0
golang.org/x/net v0.0.0-20220708220712-1185a9018129
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
gopkg.in/yaml.v3 v3.0.1
)
require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
)
go 1.18
+81
View File
@@ -0,0 +1,81 @@
github.com/a8m/envsubst v1.3.0 h1:GmXKmVssap0YtlU3E230W98RWtWCyIZzjtf1apWWyAg=
github.com/a8m/envsubst v1.3.0/go.mod h1:MVUTQNGQ3tsjOOtKCNd+fl8RzhsXcDvvAEzkhGtlsbY=
github.com/alecthomas/assert/v2 v2.0.3 h1:WKqJODfOiQG0nEJKFKzDIG3E29CN2/4zR9XGJzKIkbg=
github.com/alecthomas/participle/v2 v2.0.0-beta.4 h1:ublfGBm+x+p2j7KotHhrUMbKtejT7M0Gv1Mt1u3absw=
github.com/alecthomas/participle/v2 v2.0.0-beta.4/go.mod h1:RC764t6n4L8D8ITAJv0qdokritYSNR3wV5cVwmIEaMM=
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
github.com/alecthomas/repr v0.1.0/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
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/goccy/go-json v0.9.10 h1:hCeNmprSNLB8B8vQKWl6DpuH0t60oEs+TAk9a7CScKc=
github.com/goccy/go-json v0.9.10/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-yaml v1.9.5 h1:Eh/+3uk9kLxG4koCX6lRMAPS1OaMSAi+FJcya0INdB0=
github.com/goccy/go-yaml v1.9.5/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
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.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
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/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
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=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20220708220712-1185a9018129 h1:vucSRfWwTsoXro7P+3Cjlr6flUMtzCwzlvkxEQtHHB0=
golang.org/x/net v0.0.0-20220708220712-1185a9018129/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/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-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e h1:NHvCuwuS43lGnYhten69ZWqi2QOj/CiDNcKbVqwVoew=
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f h1:uF6paiQQebLeSXkrTqHqz0MXhXXS1KgF41eUdBNvxK0=
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
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/yaml.v2 v2.2.2/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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+129
View File
@@ -0,0 +1,129 @@
# How it works
In `yq` expressions are made up of operators and pipes. A context of nodes is passed through the expression and each operation takes the context as input and returns a new context as output. That output is piped in as input for the next operation in the expression. To begin with, the context is set to the first yaml document of the first yaml file (if processing in sequence using eval).
Lets look at a couple of examples.
## Simple assignment example
Given a document like:
```yaml
a: cat
b: dog
```
with an expression:
```
.a = .b
```
Like math expressions - operator precedence is important.
The `=` operator takes two arguments, a `lhs` expression, which in this case is `.a` and `rhs` expression which is `.b`.
It pipes the current, lets call it 'root' context through the `lhs` expression of `.a` to return the node
```yaml
cat
```
Sidenote: this node holds not only its value 'cat', but comments and metadata too, including path and parent information.
The `=` operator then pipes the 'root' context through the `rhs` expression of `.b` to return the node
```yaml
dog
```
Both sides have now been evaluated, so now the operator copies across the value from the RHS (`.b`) to the the LHS (`.a`), and it returns the now updated context:
```yaml
a: dog
b: dog
```
## Complex assignment, operator precedence rules
Just like math expressions - `yq` expressions have an order of precedence. The pipe `|` operator has a low order of precedence, so operators with higher precedence will get evaluated first.
Most of the time, this is intuitively what you'd want, for instance `.a = "cat" | .b = "dog"` is effectively: `(.a = "cat") | (.b = "dog")`.
However, this is not always the case, particularly if you have a complex LHS or RHS expression, for instance if you want to select particular nodes to update.
Lets say you had:
```yaml
- name: bob
fruit: apple
- name: sally
fruit: orange
```
Lets say you wanted to update the `sally` entry to have fruit: 'mango'. The _incorrect_ way to do that is:
`.[] | select(.name == "sally") | .fruit = "mango"`.
Because `|` has a low operator precedence, this will be evaluated (_incorrectly_) as : `(.[]) | (select(.name == "sally")) | (.fruit = "mango")`. What you'll see is only the updated segment returned:
```yaml
name: sally
fruit: mango
```
To properly update this yaml, you will need to use brackets (think BODMAS from maths) and wrap the entire LHS:
`(.[] | select(.name == "sally") | .fruit) = "mango"`
Now that entire LHS expression is passed to the 'assign' (`=`) operator, and the yaml is correctly updated and returned:
```yaml
- name: bob
fruit: apple
- name: sally
fruit: mango
```
## Relative update (e.g. `|=`)
There is another form of the `=` operator which we call the relative form. It's very similar to `=` but with one key difference when evaluating the RHS expression.
In the plain form, we pass in the 'root' level context to the RHS expression. In relative form, we pass in _each result of the LHS_ to the RHS expression. Let's go through an example.
Given a document like:
```yaml
a: 1
b: thing
```
with an expression:
```
.a |= . + 1
```
Similar to the `=` operator, `|=` takes two operands, the LHS and RHS.
It pipes the current context (the whole document) through the LHS expression of `.a` to get the node value:
```
1
```
Now it pipes _that LHS context_ into the RHS expression `. + 1` (whereas in the `=` plain form it piped the original document context into the RHS) to yield:
```
2
```
The assignment operator then copies across the value from the RHS to the value on the LHS, and it returns the now updated 'root' context:
```yaml
a: 2
b: thing
```
+7
View 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'
-55
View File
@@ -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
}
-42
View File
@@ -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)
}
}
+90
View File
@@ -0,0 +1,90 @@
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, leadingContentPreProcessing bool, decoder Decoder) 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
}
func NewAllAtOnceEvaluator() Evaluator {
InitExpressionParser()
return &allAtOnceEvaluator{treeNavigator: NewDataTreeNavigator()}
}
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 := ExpressionParser.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, leadingContentPreProcessing bool, decoder Decoder) error {
fileIndex := 0
firstFileLeadingContent := ""
var allDocuments = list.New()
for _, filename := range filenames {
reader, leadingContent, err := readStream(filename, fileIndex == 0 && leadingContentPreProcessing)
if err != nil {
return err
}
if fileIndex == 0 {
firstFileLeadingContent = leadingContent
}
fileDocuments, err := readDocuments(reader, filename, fileIndex, decoder)
if err != nil {
return err
}
allDocuments.PushBackList(fileDocuments)
fileIndex = fileIndex + 1
}
if allDocuments.Len() == 0 {
candidateNode := &CandidateNode{
Document: 0,
Filename: "",
Node: &yaml.Node{Kind: yaml.DocumentNode, Content: []*yaml.Node{{Tag: "!!null", Kind: yaml.ScalarNode}}},
FileIndex: 0,
LeadingContent: firstFileLeadingContent,
}
allDocuments.PushBack(candidateNode)
} else {
allDocuments.Front().Value.(*CandidateNode).LeadingContent = firstFileLeadingContent
}
matches, err := e.EvaluateCandidateNodes(expression, allDocuments)
if err != nil {
return err
}
return printer.PrintResults(matches)
}
+40
View 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(t, list))
}
}
+189
View File
@@ -0,0 +1,189 @@
package yqlib
import (
"container/list"
"fmt"
"strings"
"github.com/jinzhu/copier"
yaml "gopkg.in/yaml.v3"
)
type CandidateNode struct {
Node *yaml.Node // the actual node
Parent *CandidateNode // parent node
Key *yaml.Node // node key, if this is a value from a map (or index in an array)
LeadingContent string
TrailingContent string
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 propagate 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) GetNiceTag() string {
return unwrapDoc(n.Node).Tag
}
func (n *CandidateNode) GetNicePath() string {
if n.Path != nil && len(n.Path) >= 0 {
pathStr := make([]string, len(n.Path))
for i, v := range n.Path {
pathStr[i] = fmt.Sprintf("%v", v)
}
return strings.Join(pathStr, ".")
}
return ""
}
func (n *CandidateNode) AsList() *list.List {
elMap := list.New()
elMap.PushBack(n)
return elMap
}
func (n *CandidateNode) CreateChildInMap(key *yaml.Node, node *yaml.Node) *CandidateNode {
var value interface{}
if key != nil {
value = key.Value
}
return &CandidateNode{
Node: node,
Path: n.createChildPath(value),
Parent: n,
Key: key,
Document: n.Document,
Filename: n.Filename,
FileIndex: n.FileIndex,
}
}
func (n *CandidateNode) CreateChildInArray(index int, node *yaml.Node) *CandidateNode {
return &CandidateNode{
Node: node,
Path: n.createChildPath(index),
Parent: n,
Key: &yaml.Node{Kind: yaml.ScalarNode, Value: fmt.Sprintf("%v", index), Tag: "!!int"},
Document: n.Document,
Filename: n.Filename,
FileIndex: n.FileIndex,
}
}
func (n *CandidateNode) CreateReplacement(node *yaml.Node) *CandidateNode {
return &CandidateNode{
Node: node,
Path: n.createChildPath(nil),
Parent: n.Parent,
Key: n.Key,
IsMapKey: n.IsMapKey,
Document: n.Document,
Filename: n.Filename,
FileIndex: n.FileIndex,
}
}
func (n *CandidateNode) CreateReplacementWithDocWrappers(node *yaml.Node) *CandidateNode {
replacement := n.CreateReplacement(node)
replacement.LeadingContent = n.LeadingContent
replacement.TrailingContent = n.TrailingContent
return replacement
}
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
}
clone.Node = deepClone(n.Node)
return clone, nil
}
// updates this candidate from the given candidate node
func (n *CandidateNode) UpdateFrom(other *CandidateNode, prefs assignPreferences) {
// if this is an empty map or empty array, use the style of other node.
if (n.Node.Kind != yaml.ScalarNode && len(n.Node.Content) == 0) ||
// if the tag has changed (e.g. from str to bool)
(guessTagFromCustomType(n.Node) != guessTagFromCustomType(other.Node)) {
n.Node.Style = other.Node.Style
}
n.Node.Content = deepCloneContent(other.Node.Content)
n.Node.Kind = other.Node.Kind
n.Node.Value = other.Node.Value
n.UpdateAttributesFrom(other, prefs)
}
func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode, prefs assignPreferences) {
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
// don't clobber custom tags...
if strings.HasPrefix(n.Node.Tag, "!!") || n.Node.Tag == "" {
n.Node.Tag = other.Node.Tag
}
n.Node.Alias = other.Node.Alias
if !prefs.DontOverWriteAnchor {
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.TrailingContent != "" {
n.TrailingContent = other.TrailingContent
}
if other.Node.HeadComment != "" {
n.Node.HeadComment = other.Node.HeadComment
}
if other.Node.LineComment != "" {
n.Node.LineComment = other.Node.LineComment
}
}
+61
View 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
}
+133
View File
@@ -0,0 +1,133 @@
package yqlib
import (
"fmt"
"strconv"
"time"
yaml "gopkg.in/yaml.v3"
)
type compareTypePref struct {
OrEqual bool
Greater bool
}
func compareOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
log.Debugf("-- compareOperator")
prefs := expressionNode.Operation.Preferences.(compareTypePref)
return crossFunction(d, context.ReadOnlyClone(), expressionNode, compare(prefs), true)
}
func compare(prefs compareTypePref) func(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
return func(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
log.Debugf("-- compare cross function")
if lhs == nil && rhs == nil {
owner := &CandidateNode{}
return createBooleanCandidate(owner, prefs.OrEqual), nil
} else if lhs == nil {
log.Debugf("lhs nil, but rhs is not")
return createBooleanCandidate(rhs, false), nil
} else if rhs == nil {
log.Debugf("rhs nil, but rhs is not")
return createBooleanCandidate(lhs, false), nil
}
lhs.Node = unwrapDoc(lhs.Node)
rhs.Node = unwrapDoc(rhs.Node)
switch lhs.Node.Kind {
case yaml.MappingNode:
return nil, fmt.Errorf("maps not yet supported for comparison")
case yaml.SequenceNode:
return nil, fmt.Errorf("arrays not yet supported for comparison")
default:
if rhs.Node.Kind != yaml.ScalarNode {
return nil, fmt.Errorf("%v (%v) cannot be subtracted from %v", rhs.Node.Tag, rhs.Path, lhs.Node.Tag)
}
target := lhs.CreateReplacement(&yaml.Node{})
boolV, err := compareScalars(context, prefs, lhs.Node, rhs.Node)
return createBooleanCandidate(target, boolV), err
}
}
}
func compareDateTime(layout string, prefs compareTypePref, lhs *yaml.Node, rhs *yaml.Node) (bool, error) {
lhsTime, err := time.Parse(layout, lhs.Value)
if err != nil {
return false, err
}
rhsTime, err := time.Parse(layout, rhs.Value)
if err != nil {
return false, err
}
if prefs.OrEqual && lhsTime.Equal(rhsTime) {
return true, nil
}
if prefs.Greater {
return lhsTime.After(rhsTime), nil
}
return lhsTime.Before(rhsTime), nil
}
func compareScalars(context Context, prefs compareTypePref, lhs *yaml.Node, rhs *yaml.Node) (bool, error) {
lhsTag := guessTagFromCustomType(lhs)
rhsTag := guessTagFromCustomType(rhs)
isDateTime := lhs.Tag == "!!timestamp"
// if the lhs is a string, it might be a timestamp in a custom format.
if lhsTag == "!!str" && context.GetDateTimeLayout() != time.RFC3339 {
_, err := time.Parse(context.GetDateTimeLayout(), lhs.Value)
isDateTime = err == nil
}
if isDateTime {
return compareDateTime(context.GetDateTimeLayout(), prefs, lhs, rhs)
} else if lhsTag == "!!int" && rhsTag == "!!int" {
_, lhsNum, err := parseInt64(lhs.Value)
if err != nil {
return false, err
}
_, rhsNum, err := parseInt64(rhs.Value)
if err != nil {
return false, err
}
if prefs.OrEqual && lhsNum == rhsNum {
return true, nil
}
if prefs.Greater {
return lhsNum > rhsNum, nil
}
return lhsNum < rhsNum, nil
} else if (lhsTag == "!!int" || lhsTag == "!!float") && (rhsTag == "!!int" || rhsTag == "!!float") {
lhsNum, err := strconv.ParseFloat(lhs.Value, 64)
if err != nil {
return false, err
}
rhsNum, err := strconv.ParseFloat(rhs.Value, 64)
if err != nil {
return false, err
}
if prefs.OrEqual && lhsNum == rhsNum {
return true, nil
}
if prefs.Greater {
return lhsNum > rhsNum, nil
}
return lhsNum < rhsNum, nil
} else if lhsTag == "!!str" && rhsTag == "!!str" {
if prefs.OrEqual && lhs.Value == rhs.Value {
return true, nil
}
if prefs.Greater {
return lhs.Value > rhs.Value, nil
}
return lhs.Value < rhs.Value, nil
}
return false, fmt.Errorf("%v not yet supported for comparison", lhs.Tag)
}
+371
View File
@@ -0,0 +1,371 @@
package yqlib
import (
"testing"
)
var compareOperatorScenarios = []expressionScenario{
// ints, not equal
{
description: "Compare numbers (>)",
document: "a: 5\nb: 4",
expression: ".a > .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: 5\nb: 4",
expression: ".a < .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
description: "Compare integers (>=)",
document: "a: 5\nb: 4",
expression: ".a >= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: 5\nb: 4",
expression: ".a <= .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
// ints, equal
{
skipDoc: true,
description: "Compare equal numbers (>)",
document: "a: 5\nb: 5",
expression: ".a > .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: "a: 5\nb: 5",
expression: ".a < .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
description: "Compare equal numbers (>=)",
document: "a: 5\nb: 5",
expression: ".a >= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: 5\nb: 5",
expression: ".a <= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
// floats, not equal
{
skipDoc: true,
document: "a: 5.2\nb: 4.1",
expression: ".a > .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: 5.2\nb: 4.1",
expression: ".a < .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: "a: 5.2\nb: 4.1",
expression: ".a >= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: 5.5\nb: 4.1",
expression: ".a <= .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
// floats, equal
{
skipDoc: true,
document: "a: 5.5\nb: 5.5",
expression: ".a > .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: "a: 5.5\nb: 5.5",
expression: ".a < .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: "a: 5.1\nb: 5.1",
expression: ".a >= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: 5.1\nb: 5.1",
expression: ".a <= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
// strings, not equal
{
description: "Compare strings",
subdescription: "Compares strings by their bytecode.",
document: "a: zoo\nb: apple",
expression: ".a > .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: zoo\nb: apple",
expression: ".a < .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: "a: zoo\nb: apple",
expression: ".a >= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: zoo\nb: apple",
expression: ".a <= .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
// strings, equal
{
skipDoc: true,
document: "a: cat\nb: cat",
expression: ".a > .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: "a: cat\nb: cat",
expression: ".a < .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: "a: cat\nb: cat",
expression: ".a >= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: cat\nb: cat",
expression: ".a <= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
// datetime, not equal
{
description: "Compare date times",
subdescription: "You can compare date times. Assumes RFC3339 date time format, see [date-time operators](https://mikefarah.gitbook.io/yq/operators/date-time-operators) for more information.",
document: "a: 2021-01-01T03:10:00Z\nb: 2020-01-01T03:10:00Z",
expression: ".a > .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: 2021-01-01T03:10:00Z\nb: 2020-01-01T03:10:00Z",
expression: ".a < .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: "a: 2021-01-01T03:10:00Z\nb: 2020-01-01T03:10:00Z",
expression: ".a >= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: 2021-01-01T03:10:00Z\nb: 2020-01-01T03:10:00Z",
expression: ".a <= .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
// datetime, equal
{
skipDoc: true,
document: "a: 2021-01-01T03:10:00Z\nb: 2021-01-01T03:10:00Z",
expression: ".a > .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: "a: 2021-01-01T03:10:00Z\nb: 2021-01-01T03:10:00Z",
expression: ".a < .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: "a: 2021-01-01T03:10:00Z\nb: 2021-01-01T03:10:00Z",
expression: ".a >= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "a: 2021-01-01T03:10:00Z\nb: 2021-01-01T03:10:00Z",
expression: ".a <= .b",
expected: []string{
"D0, P[a], (!!bool)::true\n",
},
},
// both null
{
description: "Both sides are null: > is false",
expression: ".a > .b",
expected: []string{
"D0, P[], (!!bool)::false\n",
},
},
{
skipDoc: true,
expression: ".a < .b",
expected: []string{
"D0, P[], (!!bool)::false\n",
},
},
{
description: "Both sides are null: >= is true",
expression: ".a >= .b",
expected: []string{
"D0, P[], (!!bool)::true\n",
},
},
{
skipDoc: true,
expression: ".a <= .b",
expected: []string{
"D0, P[], (!!bool)::true\n",
},
},
// one null
{
skipDoc: true,
description: "One side is null: > is false",
document: `a: 5`,
expression: ".a > .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: `a: 5`,
expression: ".a < .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
description: "One side is null: >= is false",
document: `a: 5`,
expression: ".a >= .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: `a: 5`,
expression: ".a <= .b",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: `a: 5`,
expression: ".b <= .a",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: `a: 5`,
expression: ".b < .a",
expected: []string{
"D0, P[a], (!!bool)::false\n",
},
},
}
func TestCompareOperatorScenarios(t *testing.T) {
for _, tt := range compareOperatorScenarios {
testScenario(t, &tt)
}
documentOperatorScenarios(t, "compare", compareOperatorScenarios)
}
+122
View File
@@ -0,0 +1,122 @@
package yqlib
import (
"container/list"
"fmt"
"time"
"github.com/jinzhu/copier"
logging "gopkg.in/op/go-logging.v1"
)
type Context struct {
MatchingNodes *list.List
Variables map[string]*list.List
DontAutoCreate bool
datetimeLayout string
}
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) SetDateTimeLayout(newDateTimeLayout string) {
n.datetimeLayout = newDateTimeLayout
}
func (n *Context) GetDateTimeLayout() string {
if n.datetimeLayout != "" {
return n.datetimeLayout
}
return time.RFC3339
}
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{DontAutoCreate: n.DontAutoCreate, datetimeLayout: n.datetimeLayout}
clone.Variables = make(map[string]*list.List)
if len(n.Variables) > 0 {
err := copier.Copy(&clone.Variables, n.Variables)
if err != nil {
log.Error("Error cloning context :(")
panic(err)
}
}
clone.MatchingNodes = results
return clone
}
func (n *Context) ToString() string {
if !log.IsEnabledFor(logging.DEBUG) {
return ""
}
result := fmt.Sprintf("Context\nDontAutoCreate: %v\n", n.DontAutoCreate)
return result + NodesToString(n.MatchingNodes)
}
func (n *Context) DeepClone() Context {
clone := Context{}
err := copier.Copy(&clone, n)
// copier doesn't do lists properly for some reason
clone.MatchingNodes = list.New()
for el := n.MatchingNodes.Front(); el != nil; el = el.Next() {
clonedNode, err := el.Value.(*CandidateNode).Copy()
if err != nil {
log.Error("Error cloning context :(")
panic(err)
}
clone.MatchingNodes.PushBack(clonedNode)
}
if err != nil {
log.Error("Error cloning context :(")
panic(err)
}
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
}
func (n *Context) WritableClone() Context {
clone := n.Clone()
clone.DontAutoCreate = false
return clone
}
+273
View File
@@ -0,0 +1,273 @@
package yqlib
import (
"bufio"
"fmt"
"testing"
"github.com/mikefarah/yq/v4/test"
)
const csvSimple = `name,numberOfCats,likesApples,height
Gary,1,true,168.8
Samantha's Rabbit,2,false,-188.8
`
const expectedUpdatedSimpleCsv = `name,numberOfCats,likesApples,height
Gary,3,true,168.8
Samantha's Rabbit,2,false,-188.8
`
const csvSimpleShort = `Name,Number of Cats
Gary,1
Samantha's Rabbit,2
`
const tsvSimple = `name numberOfCats likesApples height
Gary 1 true 168.8
Samantha's Rabbit 2 false -188.8
`
const expectedYamlFromCSV = `- name: Gary
numberOfCats: 1
likesApples: true
height: 168.8
- name: Samantha's Rabbit
numberOfCats: 2
likesApples: false
height: -188.8
`
const expectedYamlFromCSVMissingData = `- name: Gary
numberOfCats: 1
height: 168.8
- name: Samantha's Rabbit
height: -188.8
likesApples: false
`
const csvSimpleMissingData = `name,numberOfCats,height
Gary,1,168.8
Samantha's Rabbit,,-188.8
`
const csvTestSimpleYaml = `- [i, like, csv]
- [because, excel, is, cool]`
const expectedSimpleCsv = `i,like,csv
because,excel,is,cool
`
const tsvTestExpectedSimpleCsv = `i like csv
because excel is cool
`
var csvScenarios = []formatScenario{
{
description: "Encode CSV simple",
input: csvTestSimpleYaml,
expected: expectedSimpleCsv,
scenarioType: "encode-csv",
},
{
description: "Encode TSV simple",
input: csvTestSimpleYaml,
expected: tsvTestExpectedSimpleCsv,
scenarioType: "encode-tsv",
},
{
description: "Encode Empty",
skipDoc: true,
input: `[]`,
expected: "",
scenarioType: "encode-csv",
},
{
description: "Comma in value",
skipDoc: true,
input: `["comma, in, value", things]`,
expected: "\"comma, in, value\",things\n",
scenarioType: "encode-csv",
},
{
description: "Encode array of objects to csv",
input: expectedYamlFromCSV,
expected: csvSimple,
scenarioType: "encode-csv",
},
{
description: "Encode array of objects to custom csv format",
subdescription: "Add the header row manually, then the we convert each object into an array of values - resulting in an array of arrays. Pick the columns and call the header whatever you like.",
input: expectedYamlFromCSV,
expected: csvSimpleShort,
expression: `[["Name", "Number of Cats"]] + [.[] | [.name, .numberOfCats ]]`,
scenarioType: "encode-csv",
},
{
description: "Encode array of objects to csv - missing fields behaviour",
subdescription: "First entry is used to determine the headers, and it is missing 'likesApples', so it is not included in the csv. Second entry does not have 'numberOfCats' so that is blank",
input: expectedYamlFromCSVMissingData,
expected: csvSimpleMissingData,
scenarioType: "encode-csv",
},
{
description: "Parse CSV into an array of objects",
subdescription: "First row is assumed to be the header row.",
input: csvSimple,
expected: expectedYamlFromCSV,
scenarioType: "decode-csv-object",
},
{
description: "Parse TSV into an array of objects",
subdescription: "First row is assumed to be the header row.",
input: tsvSimple,
expected: expectedYamlFromCSV,
scenarioType: "decode-tsv-object",
},
{
description: "Round trip",
input: csvSimple,
expected: expectedUpdatedSimpleCsv,
expression: `(.[] | select(.name == "Gary") | .numberOfCats) = 3`,
scenarioType: "roundtrip-csv",
},
}
func testCSVScenario(t *testing.T, s formatScenario) {
switch s.scenarioType {
case "encode-csv":
test.AssertResultWithContext(t, s.expected, processFormatScenario(s, NewYamlDecoder(), NewCsvEncoder(',')), s.description)
case "encode-tsv":
test.AssertResultWithContext(t, s.expected, processFormatScenario(s, NewYamlDecoder(), NewCsvEncoder('\t')), s.description)
case "decode-csv-object":
test.AssertResultWithContext(t, s.expected, processFormatScenario(s, NewCSVObjectDecoder(','), NewYamlEncoder(2, false, true, true)), s.description)
case "decode-tsv-object":
test.AssertResultWithContext(t, s.expected, processFormatScenario(s, NewCSVObjectDecoder('\t'), NewYamlEncoder(2, false, true, true)), s.description)
case "roundtrip-csv":
test.AssertResultWithContext(t, s.expected, processFormatScenario(s, NewCSVObjectDecoder(','), NewCsvEncoder(',')), s.description)
default:
panic(fmt.Sprintf("unhandled scenario type %q", s.scenarioType))
}
}
func documentCSVDecodeObjectScenario(t *testing.T, w *bufio.Writer, s formatScenario, formatType string) {
writeOrPanic(w, fmt.Sprintf("## %v\n", s.description))
if s.subdescription != "" {
writeOrPanic(w, s.subdescription)
writeOrPanic(w, "\n\n")
}
writeOrPanic(w, fmt.Sprintf("Given a sample.%v file of:\n", formatType))
writeOrPanic(w, fmt.Sprintf("```%v\n%v\n```\n", formatType, s.input))
writeOrPanic(w, "then\n")
writeOrPanic(w, fmt.Sprintf("```bash\nyq -p=%v sample.%v\n```\n", formatType, formatType))
writeOrPanic(w, "will output\n")
separator := ','
if formatType == "tsv" {
separator = '\t'
}
writeOrPanic(w, fmt.Sprintf("```yaml\n%v```\n\n",
processFormatScenario(s, NewCSVObjectDecoder(separator), NewYamlEncoder(s.indent, false, true, true))),
)
}
func documentCSVEncodeScenario(w *bufio.Writer, s formatScenario, formatType string) {
writeOrPanic(w, fmt.Sprintf("## %v\n", s.description))
if s.subdescription != "" {
writeOrPanic(w, s.subdescription)
writeOrPanic(w, "\n\n")
}
writeOrPanic(w, "Given a sample.yml file of:\n")
writeOrPanic(w, fmt.Sprintf("```yaml\n%v\n```\n", s.input))
writeOrPanic(w, "then\n")
expression := s.expression
if expression != "" {
writeOrPanic(w, fmt.Sprintf("```bash\nyq -o=%v '%v' sample.yml\n```\n", formatType, expression))
} else {
writeOrPanic(w, fmt.Sprintf("```bash\nyq -o=%v sample.yml\n```\n", formatType))
}
writeOrPanic(w, "will output\n")
separator := ','
if formatType == "tsv" {
separator = '\t'
}
writeOrPanic(w, fmt.Sprintf("```%v\n%v```\n\n", formatType,
processFormatScenario(s, NewYamlDecoder(), NewCsvEncoder(separator))),
)
}
func documentCSVRoundTripScenario(w *bufio.Writer, s formatScenario, formatType string) {
writeOrPanic(w, fmt.Sprintf("## %v\n", s.description))
if s.subdescription != "" {
writeOrPanic(w, s.subdescription)
writeOrPanic(w, "\n\n")
}
writeOrPanic(w, fmt.Sprintf("Given a sample.%v file of:\n", formatType))
writeOrPanic(w, fmt.Sprintf("```%v\n%v\n```\n", formatType, s.input))
writeOrPanic(w, "then\n")
expression := s.expression
if expression != "" {
writeOrPanic(w, fmt.Sprintf("```bash\nyq -p=%v -o=%v '%v' sample.%v\n```\n", formatType, formatType, expression, formatType))
} else {
writeOrPanic(w, fmt.Sprintf("```bash\nyq -p=%v -o=%v sample.%v\n```\n", formatType, formatType, formatType))
}
writeOrPanic(w, "will output\n")
separator := ','
if formatType == "tsv" {
separator = '\t'
}
writeOrPanic(w, fmt.Sprintf("```%v\n%v```\n\n", formatType,
processFormatScenario(s, NewCSVObjectDecoder(separator), NewCsvEncoder(separator))),
)
}
func documentCSVScenario(t *testing.T, w *bufio.Writer, i interface{}) {
s := i.(formatScenario)
if s.skipDoc {
return
}
switch s.scenarioType {
case "encode-csv":
documentCSVEncodeScenario(w, s, "csv")
case "encode-tsv":
documentCSVEncodeScenario(w, s, "tsv")
case "decode-csv-object":
documentCSVDecodeObjectScenario(t, w, s, "csv")
case "decode-tsv-object":
documentCSVDecodeObjectScenario(t, w, s, "tsv")
case "roundtrip-csv":
documentCSVRoundTripScenario(w, s, "csv")
default:
panic(fmt.Sprintf("unhandled scenario type %q", s.scenarioType))
}
}
func TestCSVScenarios(t *testing.T) {
for _, tt := range csvScenarios {
testCSVScenario(t, tt)
}
genericScenarios := make([]interface{}, len(csvScenarios))
for i, s := range csvScenarios {
genericScenarios[i] = s
}
documentScenarios(t, "usage", "csv-tsv", genericScenarios, documentCSVScenario)
}

Some files were not shown because too many files have changed in this diff Show More