mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
Compare commits
408 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fae2b2643c | ||
|
dd86b5e7f2 | ||
|
f1f75683c1 | ||
|
38b9856f50 | ||
|
48eeb2a9df | ||
|
af283315f2 | ||
|
d18a6963f6 | ||
|
77edbb9f5c | ||
|
179c44aacc | ||
|
bc70c1fb16 | ||
|
0b71a40797 | ||
|
3f51a44596 | ||
|
afebf0e621 | ||
|
dc464a5b10 | ||
|
5340ed0ad3 | ||
|
7b52c5fe0e | ||
|
f4392f8658 | ||
|
8e14b3b393 | ||
|
8627441705 | ||
|
aa95ecd012 | ||
|
a2bd463a91 | ||
|
6c3965dca3 | ||
|
bb3ffd40b5 | ||
|
cc08afc435 | ||
|
941a453163 | ||
|
77630ca179 | ||
|
ae4b606707 | ||
|
37f3e21970 | ||
|
25d0787011 | ||
|
b5b8da0a1d | ||
|
fa21510194 | ||
|
f541194250 | ||
|
38666f4db6 | ||
|
8b327d0414 | ||
|
c8630fe4f3 | ||
|
87df9b1ae6 | ||
|
2483c38eeb | ||
|
b2a538bdfc | ||
|
6c26344449 | ||
|
daf0bfe1b9 | ||
|
750a00ec35 | ||
|
25e0a824c5 | ||
|
095f921f62 | ||
|
12d3425b4a | ||
|
0249f00bd5 | ||
|
42b1bf9678 | ||
|
c632fd3641 | ||
|
0470e5cd69 | ||
|
35c6d07248 | ||
|
3f0be107d4 | ||
|
21a9e506cb | ||
|
3722367fbb | ||
|
f7b50e9853 | ||
|
4f3fe256aa | ||
|
2595a929c9 | ||
|
b2186d5404 | ||
|
e93c43f7a0 | ||
|
b1a5387cdd | ||
|
5911ab2929 | ||
|
2ed5b2ff59 | ||
|
111c6e0be1 | ||
|
81136ad57e | ||
|
a6cd250987 | ||
|
ee1f55630f | ||
|
9072e8d3b3 | ||
|
99b08fd612 | ||
|
b2317a14ef | ||
|
3e5f7b147f | ||
|
c4faa70143 | ||
|
4d6d07ec43 | ||
|
bd0818c481 | ||
|
26742b2597 | ||
|
64c618c041 | ||
|
c4c8e5e7b0 | ||
|
e02ad4d7e8 | ||
|
dd17f072cf | ||
|
429c3ca65b | ||
|
cfcac6d1dc | ||
|
a5ddbca97f | ||
|
30027a8cf4 | ||
|
f92a42e4f8 | ||
|
3c466dc66e | ||
|
0816e16d30 | ||
|
802d54e14e | ||
|
10600dd29a | ||
|
3a464272d4 | ||
|
691efadfac | ||
|
6efe4c4797 | ||
|
9e56b364c2 | ||
|
85ec32e3db | ||
|
5c73132c8e | ||
|
c6efd5519b | ||
|
3bae44be68 | ||
|
48a7c59c4b | ||
|
851fbd8cf5 | ||
|
820a3320be | ||
|
61f569aebb | ||
|
9ff51cd066 | ||
|
9dd6d11362 | ||
|
83139e21d9 | ||
|
c77001f969 | ||
|
1be3b31bbc | ||
|
6c14a80991 | ||
|
76bd1896e9 | ||
|
c63801a8a5 | ||
|
f7cfdc29e1 | ||
|
07c6549a58 | ||
|
29f40dad59 | ||
|
fe33e7fcfe | ||
|
0707525b29 | ||
|
62acee54c3 | ||
|
d21c94cf4f | ||
|
626e9cacaf | ||
|
02ef99560d | ||
|
c59209f041 | ||
|
947ffb6986 | ||
|
1a03031297 | ||
|
2c7db0071a | ||
|
0484d0232b | ||
|
91c72d2d9e | ||
|
09ec740d45 | ||
|
532dbd81a5 | ||
|
e86f83fb69 | ||
|
7d5b6b5442 | ||
|
b749973fe0 | ||
|
ba223df4ac | ||
|
e6336bcb85 | ||
|
9ae03e0a1c | ||
|
55712afea6 | ||
|
7518dac99c | ||
|
49ac2bac13 | ||
|
e28df367eb | ||
|
90ec05be54 | ||
|
8f5270cc63 | ||
|
286590b01e | ||
|
c1cf8b4e34 | ||
|
461661112c | ||
|
578f2c27f9 | ||
|
6ed037a9f6 | ||
|
69386316f3 | ||
|
a0e1f65b20 | ||
|
8027f4c568 | ||
|
b13eb7083e | ||
|
b505240d09 | ||
|
7a184bef78 | ||
|
34bc33d5c5 | ||
|
4d8b64d05c | ||
|
2d9cc3c107 | ||
|
018a6e616d | ||
|
7fa2b20b48 | ||
|
316e0d4d5a | ||
|
a0d4c51e27 | ||
|
ceff2cc18d | ||
|
db62a16007 | ||
|
2a6e423d2d | ||
|
5a1b81cbfc | ||
|
8c1f7dfbd7 | ||
|
2e81384eed | ||
|
fbf36037c9 | ||
|
2957210e65 | ||
|
bde419aaee | ||
|
9b185a4409 | ||
|
0c777a4967 | ||
|
e9591e0cd5 | ||
|
04491e13c3 | ||
|
5aff50a345 | ||
|
90d55fb52a | ||
|
e6f97518f3 | ||
|
f4a44e7313 | ||
|
edb5f213d7 | ||
|
5cfd9b05ee | ||
|
0e764c59ce | ||
|
1b887e23b3 | ||
|
a76b72e691 | ||
|
9509831cff | ||
|
e92180e89d | ||
|
a6ae33c3f1 | ||
|
94a563dfd8 | ||
|
0328cfd619 | ||
|
88663a6ce3 | ||
|
b10a9ccfc6 | ||
|
9e9e15df73 | ||
|
6cc6fdf322 | ||
|
a88c2dc5d3 | ||
|
ea231006ed | ||
|
80f187f1a4 | ||
|
98e8b3479f | ||
|
eb539ff326 | ||
|
c09f7aa707 | ||
|
7f5c380d16 | ||
|
6a05e517f1 | ||
|
8ee6f7dc1a | ||
|
8bd54cd603 | ||
|
f2f7b6db0f | ||
|
e082fee5d4 | ||
|
412911561f | ||
|
52ae633cb7 | ||
|
9356ca59bb | ||
|
6dec167f74 | ||
|
00f6981314 | ||
|
4c60a2a967 | ||
|
f4529614c4 | ||
|
f059e13f94 | ||
|
4dbf158505 | ||
|
39a93a2836 | ||
|
7c158fce26 | ||
|
0bf43d2a55 | ||
|
1b0bce5da6 | ||
|
f112bde5fe | ||
|
e5aa4a87a4 | ||
|
f305e8fa12 | ||
|
d2d0c2c111 | ||
|
2aab79431c | ||
|
540d4953f5 | ||
|
7849232255 | ||
|
57cd67f055 | ||
|
6b17fd4fc1 | ||
|
ca8cd78616 | ||
|
9876b0ce8f | ||
|
a23272727d | ||
|
1fb37785d6 | ||
|
efb9027540 | ||
|
2577fe5425 | ||
|
f39c57fed9 | ||
|
1e8f755e7c | ||
|
bb088f6aa2 | ||
|
a96b74e779 | ||
|
09a9e1e7f0 | ||
|
db60746e4e | ||
|
8846255d1c | ||
|
a3e422ff76 | ||
|
2c3357702d | ||
|
c9dbf04da3 | ||
|
fbe53885ae | ||
|
da027f69d7 | ||
|
8cd290c00b | ||
|
363fe5d283 | ||
|
773b1a3517 | ||
|
cf4915d786 | ||
|
08f579f4e3 | ||
|
c9229439f7 | ||
|
9bc66c80b6 | ||
|
8de10e550d | ||
|
1258fa199e | ||
|
3a030651a3 | ||
|
3f48201a19 | ||
|
3cecb4e383 | ||
|
13679e51e2 | ||
|
f42728eef7 | ||
|
93136ba840 | ||
|
5665dc7b71 | ||
|
9302279dd2 | ||
|
5205f01248 | ||
|
0a66bb797d | ||
|
5972bb2f23 | ||
|
ec43f5e7c3 | ||
|
1ce30b25dc | ||
|
3d6a231722 | ||
|
3f04a1b52e | ||
|
aed598c736 | ||
|
e9fa873af8 | ||
|
064cff1341 | ||
|
fc3af441e5 | ||
|
e451119014 | ||
|
d38caf6bc2 | ||
|
4e385a1b93 | ||
|
356aac5a1f | ||
|
663413cd7a | ||
|
f03005f86d | ||
|
bc87aca8d7 | ||
|
62f262147c | ||
|
0259bb44c1 | ||
|
c08980e70f | ||
|
e07a5b6065 | ||
|
f69a81b79b | ||
|
9674acf684 | ||
|
8e1ce4ca70 | ||
|
9bd9468526 | ||
|
75044e480c | ||
|
36084a60a9 | ||
|
9b48cf80e0 | ||
|
bb3b08e648 | ||
|
dcacad1e7e | ||
|
3356061e1e | ||
|
2c062bc2a5 | ||
|
088ec36acd | ||
|
83cb6421df | ||
|
a57944d123 | ||
|
79867473d5 | ||
|
b3efcdc202 | ||
|
af2aa9ad91 | ||
|
db4762ef7c | ||
|
860655b4cd | ||
|
d91b25840a | ||
|
019acfe456 | ||
|
af39fc737d | ||
|
f8a700e400 | ||
|
708ff02e8d | ||
|
2edf64182b | ||
|
b290a65602 | ||
|
05520c2168 | ||
|
5ab584afac | ||
|
b1f139c965 | ||
|
0cb2ff5b2e | ||
|
d6ff198d63 | ||
|
e515b8c2db | ||
|
b63b9644aa | ||
|
461c3e719c | ||
|
643f2467ee | ||
|
4edb3e9021 | ||
|
41c08891d3 | ||
|
85d059340b | ||
|
badd476730 | ||
|
65e6e492cd | ||
|
6a698332dd | ||
|
49615f5581 | ||
|
4f574efdc4 | ||
|
ccb718cd0f | ||
|
73cf6224f2 | ||
|
815edef86a | ||
|
4bc98776a6 | ||
|
1910563bfe | ||
|
2ddf8dd4ed | ||
|
cd83d94b6a | ||
|
6afc2e9189 | ||
|
49b810cedd | ||
|
391ab8d70c | ||
|
b026ebf2c3 | ||
|
5e544a5b7e | ||
|
60511f5f92 | ||
|
59296b7d12 | ||
|
fccd03036f | ||
|
6829d8cb78 | ||
|
449fb8952c | ||
|
afffb2c3ba | ||
|
829ca3b424 | ||
|
d19e9f6917 | ||
|
6a0a4efa7b | ||
|
288aec942c | ||
|
7c4cf72468 | ||
|
b025000f20 | ||
|
1ba1e90e58 | ||
|
e0d1aed5b9 | ||
|
e6fd6905eb | ||
|
0a2a3c4374 | ||
|
ac076cd34a | ||
|
8170eec6d1 | ||
|
23083ed974 | ||
|
93aaa8ccee | ||
|
d7716551cf | ||
|
c791e5c663 | ||
|
a6d4dbb8b8 | ||
|
c7ebdda530 | ||
|
a0d940638c | ||
|
c09513803a | ||
|
f95226e267 | ||
|
f479a7e8e3 | ||
|
f7d4695837 | ||
|
5ee52f9506 | ||
|
c2159d9861 | ||
|
95bc1e1599 | ||
|
e037c57725 | ||
|
e32bc43c4e | ||
|
a8bdc12d83 | ||
|
ae59ad57f4 | ||
|
c321600afa | ||
|
4c95efa469 | ||
|
996ee0b433 | ||
|
bb9cb0c60e | ||
|
a125495eec | ||
|
7fa2835e13 | ||
|
e0f5cb3c59 | ||
|
87550b7fe5 | ||
|
5554301c29 | ||
|
3b0aaac626 | ||
|
65cb472604 | ||
|
fbba38c9b7 | ||
|
e5948c4f16 | ||
|
4eaadf98d0 | ||
|
eedbb0a99f | ||
|
7dabc57b65 | ||
|
fcd3a90f67 | ||
|
88e99e5336 | ||
|
a8cfccd3af | ||
|
3355e80d85 | ||
|
f528b28938 | ||
|
5b7b390a33 | ||
|
4f12e09e78 | ||
|
ee732fbf0b | ||
|
1507f929a2 | ||
|
c11c3df84f | ||
|
06bb3ac826 | ||
|
778f8c6916 | ||
|
9f43a4a265 | ||
|
bb6f07d147 | ||
|
759456e375 | ||
|
5e59803037 | ||
|
a0cb691601 | ||
|
fea8510061 | ||
|
b380ea2892 | ||
|
d66a709213 | ||
|
2fc39b3865 | ||
|
ee07edbd88 | ||
|
b11661a1be | ||
|
eac218980e | ||
|
80e7f46538 | ||
|
086f0ec6b9 | ||
|
89cbe63343 |
@ -1 +1 @@
|
|||||||
bin
|
bin/*
|
||||||
|
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
github: mikefarah
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
name: Bug report
|
name: Bug report - V3
|
||||||
about: Create a report to help us improve
|
about: Create a report to help us improve
|
||||||
title: ''
|
title: ''
|
||||||
labels: bug
|
labels: bug, v3
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -10,8 +10,14 @@ assignees: ''
|
|||||||
**Describe the bug**
|
**Describe the bug**
|
||||||
A clear and concise description of what the bug is.
|
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**
|
**Input Yaml**
|
||||||
Concise yaml document(s) (as simple as possible to show the bug)
|
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
|
||||||
data1.yml:
|
data1.yml:
|
||||||
```yaml
|
```yaml
|
||||||
this: should really work
|
this: should really work
|
51
.github/ISSUE_TEMPLATE/bug_report_v4.md
vendored
Normal file
51
.github/ISSUE_TEMPLATE/bug_report_v4.md
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
---
|
||||||
|
name: Bug report - V4
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: bug, v4
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
Note that any how to questions should be posted in the discussion board and not raised as an issue.
|
||||||
|
|
||||||
|
Version of yq: 4.X.X
|
||||||
|
Operating system: mac/linux/windows/....
|
||||||
|
Installed via: docker/binary release/homebrew/snap/...
|
||||||
|
|
||||||
|
**Input Yaml**
|
||||||
|
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
|
||||||
|
data1.yml:
|
||||||
|
```yaml
|
||||||
|
this: should really work
|
||||||
|
```
|
||||||
|
|
||||||
|
data2.yml:
|
||||||
|
```yaml
|
||||||
|
but: it strangely didn't
|
||||||
|
```
|
||||||
|
|
||||||
|
**Command**
|
||||||
|
The command you ran:
|
||||||
|
```
|
||||||
|
yq eval-all 'select(fileIndex==0) | .a.b.c' data1.yml data2.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
**Actual behavior**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
cat: meow
|
||||||
|
```
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
this: should really work
|
||||||
|
but: it strangely didn't
|
||||||
|
```
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
16
.github/ISSUE_TEMPLATE/feature_request.md
vendored
16
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -1,17 +1,23 @@
|
|||||||
---
|
---
|
||||||
name: Feature request
|
name: Feature request - V4
|
||||||
about: Suggest an idea for this project
|
about: Suggest an idea for this project
|
||||||
title: ''
|
title: ''
|
||||||
labels: enhancement
|
labels: enhancement, v4
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
**Please describe your feature request.**
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
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**
|
**Describe the solution you'd like**
|
||||||
If we have data1.yml like:
|
If we have data1.yml like:
|
||||||
|
(please keep to around 10 lines )
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
country: Australia
|
country: Australia
|
||||||
@ -20,7 +26,7 @@ country: Australia
|
|||||||
And we run a command:
|
And we run a command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yq predictWeather data1.yml
|
yq eval 'predictWeatherOf(.country)'
|
||||||
```
|
```
|
||||||
|
|
||||||
it could output
|
it could output
|
||||||
|
7
.github/workflows/go.yml
vendored
7
.github/workflows/go.yml
vendored
@ -7,10 +7,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.14
|
- name: Set up Go 1.15
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v1
|
||||||
with:
|
with:
|
||||||
go-version: 1.14
|
go-version: 1.15
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
@ -28,7 +28,4 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
export PATH=${PATH}:`go env GOPATH`/bin
|
export PATH=${PATH}:`go env GOPATH`/bin
|
||||||
scripts/devtools.sh
|
scripts/devtools.sh
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
export PATH=${PATH}:`go env GOPATH`/bin
|
|
||||||
make local build
|
make local build
|
70
.github/workflows/release.yml
vendored
Normal file
70
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
name: Release YQ
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publishGitRelease:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: '^1.15'
|
||||||
|
- name: Cross compile
|
||||||
|
run: |
|
||||||
|
sudo apt-get install rhash -y
|
||||||
|
go get github.com/mitchellh/gox
|
||||||
|
./scripts/xcompile.sh
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1.0.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
release_name: ${{ github.ref }}
|
||||||
|
draft: true
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
|
- uses: shogo82148/actions-upload-release-asset@v1
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: build/*
|
||||||
|
|
||||||
|
publishDocker:
|
||||||
|
environment: dockerhub
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: mikefarah/yq
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
with:
|
||||||
|
platforms: all
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
|
||||||
|
- name: Available platforms
|
||||||
|
run: echo ${{ steps.buildx.outputs.platforms }} && docker version
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
run: |
|
||||||
|
IMAGE_V_VERSION="$(git describe --tags --abbrev=0)"
|
||||||
|
IMAGE_VERSION=${IMAGE_V_VERSION:1}
|
||||||
|
|
||||||
|
SHORT_SHA1=$(git rev-parse --short HEAD)
|
||||||
|
PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64"
|
||||||
|
echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}"
|
||||||
|
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
||||||
|
docker buildx build --platform "${PLATFORMS}" -t "${IMAGE_NAME}:${IMAGE_VERSION}" -t "${IMAGE_NAME}:latest" -t "${IMAGE_NAME}:4" \
|
||||||
|
--push .
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.14 as builder
|
FROM golang:1.15 as builder
|
||||||
|
|
||||||
WORKDIR /go/src/mikefarah/yq
|
WORKDIR /go/src/mikefarah/yq
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ RUN CGO_ENABLED=0 make local build
|
|||||||
|
|
||||||
# Choose alpine as a base image to make this useful for CI, as many
|
# Choose alpine as a base image to make this useful for CI, as many
|
||||||
# CI tools expect an interactive shell inside the container
|
# CI tools expect an interactive shell inside the container
|
||||||
FROM alpine:3.8 as production
|
FROM alpine:3.12.3 as production
|
||||||
|
|
||||||
COPY --from=builder /go/src/mikefarah/yq/yq /usr/bin/yq
|
COPY --from=builder /go/src/mikefarah/yq/yq /usr/bin/yq
|
||||||
RUN chmod +x /usr/bin/yq
|
RUN chmod +x /usr/bin/yq
|
||||||
@ -21,3 +21,5 @@ ARG VERSION=none
|
|||||||
LABEL version=${VERSION}
|
LABEL version=${VERSION}
|
||||||
|
|
||||||
WORKDIR /workdir
|
WORKDIR /workdir
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/bin/yq"]
|
||||||
|
@ -1,30 +1,10 @@
|
|||||||
FROM golang:1.14
|
FROM golang:1.15
|
||||||
|
|
||||||
COPY scripts/devtools.sh /opt/devtools.sh
|
COPY scripts/devtools.sh /opt/devtools.sh
|
||||||
|
|
||||||
RUN set -e -x \
|
RUN set -e -x \
|
||||||
&& /opt/devtools.sh
|
&& /opt/devtools.sh
|
||||||
|
ENV PATH=/go/bin:$PATH
|
||||||
# install mkdocs
|
|
||||||
RUN set -ex \
|
|
||||||
&& buildDeps=' \
|
|
||||||
build-essential \
|
|
||||||
python3-dev \
|
|
||||||
' \
|
|
||||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
$buildDeps \
|
|
||||||
python3 \
|
|
||||||
python3-setuptools \
|
|
||||||
python3-wheel \
|
|
||||||
python3-pip \
|
|
||||||
&& pip3 install --upgrade \
|
|
||||||
pip \
|
|
||||||
'Markdown>=2.6.9' \
|
|
||||||
'mkdocs>=0.16.3' \
|
|
||||||
'mkdocs-material>=1.10.1' \
|
|
||||||
'markdown-include>=0.5.1' \
|
|
||||||
&& apt-get purge -y --auto-remove $buildDeps \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
ENV CGO_ENABLED 0
|
ENV CGO_ENABLED 0
|
||||||
ENV GOPATH /go:/yq
|
ENV GOPATH /go:/yq
|
||||||
|
10
Makefile
10
Makefile
@ -17,6 +17,7 @@ help:
|
|||||||
@echo ' make vendor Install dependencies to vendor directory.'
|
@echo ' make vendor Install dependencies to vendor directory.'
|
||||||
@echo ' make format Run code formatter.'
|
@echo ' make format Run code formatter.'
|
||||||
@echo ' make check Run static code analysis (lint).'
|
@echo ' make check Run static code analysis (lint).'
|
||||||
|
@echo ' make secure Run gosec.'
|
||||||
@echo ' make test Run tests on project.'
|
@echo ' make test Run tests on project.'
|
||||||
@echo ' make cover Run tests and capture code coverage metrics 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 ' make clean Clean the directory tree of produced artifacts.'
|
||||||
@ -84,6 +85,10 @@ format: vendor
|
|||||||
check: format
|
check: format
|
||||||
${DOCKRUN} bash ./scripts/check.sh
|
${DOCKRUN} bash ./scripts/check.sh
|
||||||
|
|
||||||
|
.PHONY: secure
|
||||||
|
secure:
|
||||||
|
${DOCKRUN} bash ./scripts/secure.sh
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: check
|
test: check
|
||||||
${DOCKRUN} bash ./scripts/test.sh
|
${DOCKRUN} bash ./scripts/test.sh
|
||||||
@ -96,11 +101,6 @@ cover: check
|
|||||||
@find cover -type d -exec chmod 755 {} \; || :
|
@find cover -type d -exec chmod 755 {} \; || :
|
||||||
@find cover -type f -exec chmod 644 {} \; || :
|
@find cover -type f -exec chmod 644 {} \; || :
|
||||||
|
|
||||||
.PHONY: build-docs
|
|
||||||
build-docs: prepare mkdocs.yml mkdocs/*
|
|
||||||
${DOCKRUN} mkdocs build
|
|
||||||
@find docs -type d -exec chmod 755 {} \; || :
|
|
||||||
@find docs -type f -exec chmod 644 {} \; || :
|
|
||||||
|
|
||||||
.PHONY: release
|
.PHONY: release
|
||||||
release: xcompile
|
release: xcompile
|
||||||
|
214
README.md
214
README.md
@ -3,51 +3,146 @@
|
|||||||
   
|
   
|
||||||
|
|
||||||
|
|
||||||
a lightweight and portable command-line YAML processor
|
a lightweight and portable command-line YAML processor. `yq` uses [jq](https://github.com/stedolan/jq) like syntax but works with yaml files as well as json. It doesn't yet support everything `jq` does - but it does support the most common operations and functions, and more is being added continuously.
|
||||||
|
|
||||||
The aim of the project is to be the [jq](https://github.com/stedolan/jq) or sed of yaml files.
|
yq is written in go - so you can download a dependency free binary for your platform and you are good to go! If you prefer there are a variety of package managers that can be used as well as docker, all listed below.
|
||||||
|
|
||||||
## New version!
|
## V4 released!
|
||||||
V3 is officially out - if you've been using v2 and want/need to upgrade, checkout the [upgrade guide](https://mikefarah.gitbook.io/yq/upgrading-from-v2).
|
V4 is now officially released, it's quite different from V3 (sorry for the migration), however it is much more similar to ```jq```, using a similar expression syntax and therefore support much more complex functionality!
|
||||||
|
|
||||||
|
If you've been using v3 and want/need to upgrade, checkout the [upgrade guide](https://mikefarah.gitbook.io/yq/v/v4.x/upgrading-from-v3).
|
||||||
|
|
||||||
|
Support for v3 will cease August 2021, until then, critical bug and security fixes will still get applied if required.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
### [Download the latest binary](https://github.com/mikefarah/yq/releases/latest)
|
### [Download the latest binary](https://github.com/mikefarah/yq/releases/latest)
|
||||||
|
|
||||||
### MacOS:
|
### 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
|
brew install yq
|
||||||
```
|
```
|
||||||
|
|
||||||
### Windows:
|
or, for the (deprecated) v3 version:
|
||||||
```
|
|
||||||
choco install yq
|
|
||||||
```
|
|
||||||
Supported by @chillum
|
|
||||||
|
|
||||||
### Ubuntu and other Linux distros supporting `snap` packages:
|
```
|
||||||
|
brew install yq@3
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that for v3, as it is a versioned brew it will not add the `yq` command to your path automatically. Please follow the instructions given by brew upon installation.
|
||||||
|
|
||||||
|
### Linux via snap:
|
||||||
```
|
```
|
||||||
snap install yq
|
snap install yq
|
||||||
```
|
```
|
||||||
|
|
||||||
|
or, for the (deprecated) v3 version:
|
||||||
|
|
||||||
|
```
|
||||||
|
snap install yq --channel=v3/stable
|
||||||
|
```
|
||||||
|
|
||||||
#### Snap notes
|
#### 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:
|
`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 r - a.path
|
sudo cat /etc/myfile | yq e '.a.path' -
|
||||||
```
|
```
|
||||||
|
|
||||||
And to write to a root file you can either use [sponge](https://linux.die.net/man/1/sponge):
|
And to write to a root file you can either use [sponge](https://linux.die.net/man/1/sponge):
|
||||||
```
|
```
|
||||||
sudo cat /etc/myfile | yq w - a.path value | sudo sponge /etc/myfile
|
sudo cat /etc/myfile | yq e '.a.path = "value"' - | sudo sponge /etc/myfile
|
||||||
```
|
```
|
||||||
or write to a temporary file:
|
or write to a temporary file:
|
||||||
```
|
```
|
||||||
sudo cat /etc/myfile | yq w - a.path value | sudo tee /etc/myfile.tmp
|
sudo cat /etc/myfile | yq e '.a.path = "value"' | sudo tee /etc/myfile.tmp
|
||||||
sudo mv /etc/myfile.tmp /etc/myfile
|
sudo mv /etc/myfile.tmp /etc/myfile
|
||||||
rm /etc/myfile.tmp
|
rm /etc/myfile.tmp
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Run with Docker
|
||||||
|
|
||||||
|
#### Oneshot use:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -v "${PWD}":/workdir mikefarah/yq <command> [flags] [expression ]FILE...
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Run commands interactively:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker 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 "$@"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Go Get:
|
||||||
|
```
|
||||||
|
GO111MODULE=on go get github.com/mikefarah/yq/v4
|
||||||
|
```
|
||||||
|
|
||||||
|
## Community Supported Installation methods
|
||||||
|
As these are supported by the community :heart: - however, they may be out of date with the officially supported releases.
|
||||||
|
|
||||||
|
# Webi
|
||||||
|
|
||||||
|
```
|
||||||
|
webi yq
|
||||||
|
```
|
||||||
|
|
||||||
|
See [webi](https://webinstall.dev/)
|
||||||
|
Supported by @adithyasunil26 (https://github.com/webinstall/webi-installers/tree/master/yq)
|
||||||
|
|
||||||
|
### Windows:
|
||||||
|
[](https://chocolatey.org/packages/yq)
|
||||||
|
[](https://chocolatey.org/packages/yq)
|
||||||
|
```
|
||||||
|
choco install yq
|
||||||
|
```
|
||||||
|
Supported by @chillum (https://chocolatey.org/packages/yq)
|
||||||
|
|
||||||
|
### Mac:
|
||||||
|
Using [MacPorts](https://www.macports.org/)
|
||||||
|
```
|
||||||
|
sudo port selfupdate
|
||||||
|
sudo port install yq
|
||||||
|
```
|
||||||
|
Supported by @herbygillot (https://ports.macports.org/maintainer/github/herbygillot)
|
||||||
|
|
||||||
|
### Alpine Linux
|
||||||
|
- Enable edge/community repo by adding ```$MIRROR/alpine/edge/community``` to ```/etc/apk/repositories```
|
||||||
|
- Update database index with ```apk update```
|
||||||
|
- Install yq with ```apk add yq```
|
||||||
|
|
||||||
|
Supported by Tuan Hoang
|
||||||
|
https://pkgs.alpinelinux.org/package/edge/community/x86/yq
|
||||||
|
|
||||||
|
|
||||||
### On Ubuntu 16.04 or higher from Debian package:
|
### On Ubuntu 16.04 or higher from Debian package:
|
||||||
```sh
|
```sh
|
||||||
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
|
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
|
||||||
@ -55,53 +150,24 @@ sudo add-apt-repository ppa:rmescandon/yq
|
|||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install yq -y
|
sudo apt install yq -y
|
||||||
```
|
```
|
||||||
Supported by @rmescandon
|
Supported by @rmescandon (https://launchpad.net/~rmescandon/+archive/ubuntu/yq)
|
||||||
|
|
||||||
### Go Get:
|
|
||||||
```
|
|
||||||
GO111MODULE=on go get github.com/mikefarah/yq/v3
|
|
||||||
```
|
|
||||||
|
|
||||||
## Run with Docker
|
|
||||||
|
|
||||||
Oneshot use:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run --rm -v "${PWD}":/workdir mikefarah/yq yq [flags] <command> FILE...
|
|
||||||
```
|
|
||||||
|
|
||||||
Run commands interactively:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run --rm -it -v "${PWD}":/workdir mikefarah/yq sh
|
|
||||||
```
|
|
||||||
|
|
||||||
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 yq "$@"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
- [Detailed documentation with many examples](https://mikefarah.gitbook.io/yq/)
|
||||||
- Written in portable go, so you can download a lovely dependency free binary
|
- Written in portable go, so you can download a lovely dependency free binary
|
||||||
- [Colorize the output](https://mikefarah.gitbook.io/yq/usage/output-format#colorize-output)
|
- Uses similar syntax as `jq` but works with YAML and JSON files
|
||||||
- [Deep read a yaml file with a given path expression](https://mikefarah.gitbook.io/yq/commands/read#basic)
|
- Fully supports multi document yaml files
|
||||||
- [List matching paths of a given path expression](https://mikefarah.gitbook.io/yq/commands/read#path-only)
|
- Colorized yaml output
|
||||||
- [Return the lengths of arrays/object/scalars](https://mikefarah.gitbook.io/yq/commands/read#printing-length-of-the-results)
|
- [Deeply traverse yaml](https://mikefarah.gitbook.io/yq/operators/traverse-read)
|
||||||
- Update a yaml file given a [path expression](https://mikefarah.gitbook.io/yq/commands/write-update#basic) or [script file](https://mikefarah.gitbook.io/yq/commands/write-update#basic)
|
- [Sort yaml by keys](https://mikefarah.gitbook.io/yq/operators/sort-keys)
|
||||||
- Update creates any missing entries in the path on the fly
|
- 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).
|
||||||
- Deeply [compare](https://mikefarah.gitbook.io/yq/commands/compare) yaml files
|
- [Update yaml inplace](https://mikefarah.gitbook.io/yq/v/v4.x/commands/evaluate#flags)
|
||||||
- Keeps yaml formatting and comments when updating
|
- [Complex expressions to select and update](https://mikefarah.gitbook.io/yq/operators/select#select-and-update-matching-values-in-map)
|
||||||
- [Validate a yaml file](https://mikefarah.gitbook.io/yq/commands/validate)
|
- Keeps yaml formatting and comments when updating (though there are issues with whitespace)
|
||||||
- Create a yaml file given a [deep path and value](https://mikefarah.gitbook.io/yq/commands/create#creating-a-simple-yaml-file) or a [script file](https://mikefarah.gitbook.io/yq/commands/create#creating-using-a-create-script)
|
- [Convert to/from json to yaml](https://mikefarah.gitbook.io/yq/v/v4.x/usage/convert)
|
||||||
- [Prefix a path to a yaml file](https://mikefarah.gitbook.io/yq/commands/prefix)
|
- [Pipe data in by using '-'](https://mikefarah.gitbook.io/yq/v/v4.x/commands/evaluate)
|
||||||
- [Convert to/from json to yaml](https://mikefarah.gitbook.io/yq/usage/convert)
|
- [General shell completion scripts (bash/zsh/fish/powershell)](https://mikefarah.gitbook.io/yq/v/v4.x/commands/shell-completion)
|
||||||
- [Pipe data in by using '-'](https://mikefarah.gitbook.io/yq/commands/read#from-stdin)
|
- [Reduce](https://mikefarah.gitbook.io/yq/operators/reduce) to merge multiple files or sum an array or other fancy things.
|
||||||
- [Merge](https://mikefarah.gitbook.io/yq/commands/merge) multiple yaml files with various options for [overriding](https://mikefarah.gitbook.io/yq/commands/merge#overwrite-values) and [appending](https://mikefarah.gitbook.io/yq/commands/merge#append-values-with-arrays)
|
|
||||||
- Supports multiple documents in a single yaml file for [reading](https://mikefarah.gitbook.io/yq/commands/read#multiple-documents), [writing](https://mikefarah.gitbook.io/yq/commands/write-update#multiple-documents) and [merging](https://mikefarah.gitbook.io/yq/commands/merge#multiple-documents)
|
|
||||||
- General shell completion scripts (bash/zsh/fish/powershell) (https://mikefarah.gitbook.io/yq/commands/shell-completion)
|
|
||||||
|
|
||||||
## [Usage](https://mikefarah.gitbook.io/yq/)
|
## [Usage](https://mikefarah.gitbook.io/yq/)
|
||||||
|
|
||||||
@ -113,25 +179,33 @@ Usage:
|
|||||||
yq [command]
|
yq [command]
|
||||||
|
|
||||||
Available Commands:
|
Available Commands:
|
||||||
compare yq x [--prettyPrint/-P] dataA.yaml dataB.yaml 'b.e(name==fr*).value'
|
eval Apply expression to each document in each yaml file given in sequence
|
||||||
delete yq d [--inplace/-i] [--doc/-d index] sample.yaml 'b.e(name==fred)'
|
eval-all Loads _all_ yaml documents of _all_ yaml files and runs expression once
|
||||||
help Help about any command
|
help Help about any command
|
||||||
merge yq m [--inplace/-i] [--doc/-d index] [--overwrite/-x] [--append/-a] sample.yaml sample2.yaml
|
shell-completion Generate completion script
|
||||||
new yq n [--script/-s script_file] a.b.c newValue
|
|
||||||
prefix yq p [--inplace/-i] [--doc/-d index] sample.yaml a.b.c
|
|
||||||
read yq r [--printMode/-p pv] sample.yaml 'b.e(name==fr*).value'
|
|
||||||
shell-completion Generates shell completion scripts
|
|
||||||
validate yq v sample.yaml
|
|
||||||
write yq w [--inplace/-i] [--script/-s script_file] [--doc/-d index] sample.yaml 'b.e(name==fr*).value' newValue
|
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-C, --colors print with colors
|
-C, --colors force print with colors
|
||||||
|
-e, --exit-status set exit status if there are no matches or null or false is returned
|
||||||
-h, --help help for yq
|
-h, --help help for yq
|
||||||
-I, --indent int sets indent level for output (default 2)
|
-I, --indent int sets indent level for output (default 2)
|
||||||
-P, --prettyPrint pretty print
|
-i, --inplace update the yaml file inplace of first yaml file given.
|
||||||
-j, --tojson output as json. By default it prints a json document in one line, use the prettyPrint flag to print a formatted doc.
|
-M, --no-colors force print with no colors
|
||||||
|
-N, --no-doc Don't print document separators (---)
|
||||||
|
-n, --null-input Don't read input, simply evaluate the expression given. Useful for creating yaml docs from scratch.
|
||||||
|
-P, --prettyPrint pretty print, shorthand for '... style = ""'
|
||||||
|
-j, --tojson output as json. Set indent to 0 to print json in one line.
|
||||||
-v, --verbose verbose mode
|
-v, --verbose verbose mode
|
||||||
-V, --version Print version information and quit
|
-V, --version Print version information and quit
|
||||||
|
|
||||||
Use "yq [command] --help" for more information about a command.
|
Use "yq [command] --help" for more information about a command.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Simple Example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yq e '.a.b | length' f1.yml f2.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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)
|
||||||
|
@ -1,83 +1,83 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"strings"
|
// "strings"
|
||||||
"testing"
|
// "testing"
|
||||||
|
|
||||||
"github.com/mikefarah/yq/v3/test"
|
// "github.com/mikefarah/yq/v3/test"
|
||||||
"github.com/spf13/cobra"
|
// "github.com/spf13/cobra"
|
||||||
)
|
// )
|
||||||
|
|
||||||
func getRootCommand() *cobra.Command {
|
// func getRootCommand() *cobra.Command {
|
||||||
return New()
|
// return New()
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TestRootCmd(t *testing.T) {
|
// func TestRootCmd(t *testing.T) {
|
||||||
cmd := getRootCommand()
|
// cmd := getRootCommand()
|
||||||
result := test.RunCmd(cmd, "")
|
// result := test.RunCmd(cmd, "")
|
||||||
if result.Error != nil {
|
// if result.Error != nil {
|
||||||
t.Error(result.Error)
|
// t.Error(result.Error)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if !strings.Contains(result.Output, "Usage:") {
|
// if !strings.Contains(result.Output, "Usage:") {
|
||||||
t.Error("Expected usage message to be printed out, but the usage message was not found.")
|
// t.Error("Expected usage message to be printed out, but the usage message was not found.")
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TestRootCmd_Help(t *testing.T) {
|
// func TestRootCmd_Help(t *testing.T) {
|
||||||
cmd := getRootCommand()
|
// cmd := getRootCommand()
|
||||||
result := test.RunCmd(cmd, "--help")
|
// result := test.RunCmd(cmd, "--help")
|
||||||
if result.Error != nil {
|
// if result.Error != nil {
|
||||||
t.Error(result.Error)
|
// t.Error(result.Error)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if !strings.Contains(result.Output, "yq is a lightweight and portable command-line YAML processor. It aims to be the jq or sed of yaml files.") {
|
// if !strings.Contains(result.Output, "yq is a lightweight and portable command-line YAML processor. It aims to be the jq or sed of yaml files.") {
|
||||||
t.Error("Expected usage message to be printed out, but the usage message was not found.")
|
// t.Error("Expected usage message to be printed out, but the usage message was not found.")
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TestRootCmd_VerboseLong(t *testing.T) {
|
// func TestRootCmd_VerboseLong(t *testing.T) {
|
||||||
cmd := getRootCommand()
|
// cmd := getRootCommand()
|
||||||
result := test.RunCmd(cmd, "--verbose")
|
// result := test.RunCmd(cmd, "--verbose")
|
||||||
if result.Error != nil {
|
// if result.Error != nil {
|
||||||
t.Error(result.Error)
|
// t.Error(result.Error)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if !verbose {
|
// if !verbose {
|
||||||
t.Error("Expected verbose to be true")
|
// t.Error("Expected verbose to be true")
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TestRootCmd_VerboseShort(t *testing.T) {
|
// func TestRootCmd_VerboseShort(t *testing.T) {
|
||||||
cmd := getRootCommand()
|
// cmd := getRootCommand()
|
||||||
result := test.RunCmd(cmd, "-v")
|
// result := test.RunCmd(cmd, "-v")
|
||||||
if result.Error != nil {
|
// if result.Error != nil {
|
||||||
t.Error(result.Error)
|
// t.Error(result.Error)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if !verbose {
|
// if !verbose {
|
||||||
t.Error("Expected verbose to be true")
|
// t.Error("Expected verbose to be true")
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TestRootCmd_VersionShort(t *testing.T) {
|
// func TestRootCmd_VersionShort(t *testing.T) {
|
||||||
cmd := getRootCommand()
|
// cmd := getRootCommand()
|
||||||
result := test.RunCmd(cmd, "-V")
|
// result := test.RunCmd(cmd, "-V")
|
||||||
if result.Error != nil {
|
// if result.Error != nil {
|
||||||
t.Error(result.Error)
|
// t.Error(result.Error)
|
||||||
}
|
// }
|
||||||
if !strings.Contains(result.Output, "yq version") {
|
// if !strings.Contains(result.Output, "yq version") {
|
||||||
t.Error("expected version message to be printed out, but the message was not found.")
|
// t.Error("expected version message to be printed out, but the message was not found.")
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TestRootCmd_VersionLong(t *testing.T) {
|
// func TestRootCmd_VersionLong(t *testing.T) {
|
||||||
cmd := getRootCommand()
|
// cmd := getRootCommand()
|
||||||
result := test.RunCmd(cmd, "--version")
|
// result := test.RunCmd(cmd, "--version")
|
||||||
if result.Error != nil {
|
// if result.Error != nil {
|
||||||
t.Error(result.Error)
|
// t.Error(result.Error)
|
||||||
}
|
// }
|
||||||
if !strings.Contains(result.Output, "yq version") {
|
// if !strings.Contains(result.Output, "yq version") {
|
||||||
t.Error("expected version message to be printed out, but the message was not found.")
|
// t.Error("expected version message to be printed out, but the message was not found.")
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"bytes"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/kylelemons/godebug/diff"
|
|
||||||
"github.com/mikefarah/yq/v3/pkg/yqlib"
|
|
||||||
errors "github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
// turn off for unit tests :(
|
|
||||||
var forceOsExit = true
|
|
||||||
|
|
||||||
func createCompareCmd() *cobra.Command {
|
|
||||||
var cmdCompare = &cobra.Command{
|
|
||||||
Use: "compare [yaml_file_a] [yaml_file_b]",
|
|
||||||
Aliases: []string{"x"},
|
|
||||||
Short: "yq x [--prettyPrint/-P] dataA.yaml dataB.yaml 'b.e(name==fr*).value'",
|
|
||||||
Example: `
|
|
||||||
yq x - data2.yml # reads from stdin
|
|
||||||
yq x -pp dataA.yaml dataB.yaml '**' # compare paths
|
|
||||||
yq x -d1 dataA.yaml dataB.yaml 'a.b.c'
|
|
||||||
`,
|
|
||||||
Long: "Deeply compares two yaml files, prints the difference. Use with prettyPrint flag to ignore formatting differences.",
|
|
||||||
RunE: compareDocuments,
|
|
||||||
}
|
|
||||||
cmdCompare.PersistentFlags().StringVarP(&docIndex, "doc", "d", "0", "process document index number (0 based, * for all documents)")
|
|
||||||
cmdCompare.PersistentFlags().StringVarP(&printMode, "printMode", "p", "v", "print mode (v (values, default), p (paths), pv (path and value pairs)")
|
|
||||||
cmdCompare.PersistentFlags().StringVarP(&defaultValue, "defaultValue", "D", "", "default value printed when there are no results")
|
|
||||||
cmdCompare.PersistentFlags().BoolVarP(&stripComments, "stripComments", "", false, "strip comments out before comparing")
|
|
||||||
cmdCompare.PersistentFlags().BoolVarP(&explodeAnchors, "explodeAnchors", "X", false, "explode anchors")
|
|
||||||
return cmdCompare
|
|
||||||
}
|
|
||||||
|
|
||||||
func compareDocuments(cmd *cobra.Command, args []string) error {
|
|
||||||
var path = ""
|
|
||||||
|
|
||||||
if len(args) < 2 {
|
|
||||||
return errors.New("Must provide at 2 yaml files")
|
|
||||||
} else if len(args) > 2 {
|
|
||||||
path = args[2]
|
|
||||||
}
|
|
||||||
|
|
||||||
var updateAll, docIndexInt, errorParsingDocIndex = parseDocumentIndex()
|
|
||||||
if errorParsingDocIndex != nil {
|
|
||||||
return errorParsingDocIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
var matchingNodesA []*yqlib.NodeContext
|
|
||||||
var matchingNodesB []*yqlib.NodeContext
|
|
||||||
var errorDoingThings error
|
|
||||||
|
|
||||||
matchingNodesA, errorDoingThings = readYamlFile(args[0], path, updateAll, docIndexInt)
|
|
||||||
|
|
||||||
if errorDoingThings != nil {
|
|
||||||
return errorDoingThings
|
|
||||||
}
|
|
||||||
|
|
||||||
matchingNodesB, errorDoingThings = readYamlFile(args[1], path, updateAll, docIndexInt)
|
|
||||||
if errorDoingThings != nil {
|
|
||||||
return errorDoingThings
|
|
||||||
}
|
|
||||||
|
|
||||||
var dataBufferA bytes.Buffer
|
|
||||||
var dataBufferB bytes.Buffer
|
|
||||||
errorDoingThings = printResults(matchingNodesA, bufio.NewWriter(&dataBufferA))
|
|
||||||
if errorDoingThings != nil {
|
|
||||||
return errorDoingThings
|
|
||||||
}
|
|
||||||
errorDoingThings = printResults(matchingNodesB, bufio.NewWriter(&dataBufferB))
|
|
||||||
if errorDoingThings != nil {
|
|
||||||
return errorDoingThings
|
|
||||||
}
|
|
||||||
|
|
||||||
diffString := diff.Diff(strings.TrimSuffix(dataBufferA.String(), "\n"), strings.TrimSuffix(dataBufferB.String(), "\n"))
|
|
||||||
|
|
||||||
if len(diffString) > 1 {
|
|
||||||
cmd.Print(diffString)
|
|
||||||
cmd.Print("\n")
|
|
||||||
if forceOsExit {
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -1,115 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/mikefarah/yq/v3/test"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestCompareSameCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "compare ../examples/data1.yaml ../examples/data1.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := ``
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCompareIgnoreCommentsCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "compare --stripComments ../examples/data1.yaml ../examples/data1-no-comments.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := ``
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCompareDontIgnoreCommentsCmd(t *testing.T) {
|
|
||||||
forceOsExit = false
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "compare ../examples/data1.yaml ../examples/data1-no-comments.yaml")
|
|
||||||
|
|
||||||
expectedOutput := `-a: simple # just the best
|
|
||||||
+a: simple
|
|
||||||
b: [1, 2]
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCompareExplodeAnchorsCommentsCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "compare --explodeAnchors ../examples/simple-anchor.yaml ../examples/simple-anchor-exploded.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := ``
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCompareDontExplodeAnchorsCmd(t *testing.T) {
|
|
||||||
forceOsExit = false
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "compare ../examples/simple-anchor.yaml ../examples/simple-anchor-exploded.yaml")
|
|
||||||
|
|
||||||
expectedOutput := `-foo: &foo
|
|
||||||
+foo:
|
|
||||||
a: 1
|
|
||||||
foobar:
|
|
||||||
- !!merge <<: *foo
|
|
||||||
+ a: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCompareDifferentCmd(t *testing.T) {
|
|
||||||
forceOsExit = false
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "compare ../examples/data1.yaml ../examples/data3.yaml")
|
|
||||||
|
|
||||||
expectedOutput := `-a: simple # just the best
|
|
||||||
-b: [1, 2]
|
|
||||||
+a: "simple" # just the best
|
|
||||||
+b: [1, 3]
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestComparePrettyCmd(t *testing.T) {
|
|
||||||
forceOsExit = false
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "compare -P ../examples/data1.yaml ../examples/data3.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := ` a: simple # just the best
|
|
||||||
b:
|
|
||||||
- 1
|
|
||||||
- - 2
|
|
||||||
+ - 3
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestComparePathsCmd(t *testing.T) {
|
|
||||||
forceOsExit = false
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "compare -P -ppv ../examples/data1.yaml ../examples/data3.yaml **")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := ` a: simple # just the best
|
|
||||||
b.[0]: 1
|
|
||||||
-b.[1]: 2
|
|
||||||
+b.[1]: 3
|
|
||||||
c.test: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
@ -1,35 +1,19 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/mikefarah/yq/v3/pkg/yqlib"
|
|
||||||
logging "gopkg.in/op/go-logging.v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
var customTag = ""
|
|
||||||
var printMode = "v"
|
|
||||||
var printLength = false
|
|
||||||
var unwrapScalar = true
|
var unwrapScalar = true
|
||||||
var customStyle = ""
|
|
||||||
var anchorName = ""
|
|
||||||
var makeAlias = false
|
|
||||||
var stripComments = false
|
|
||||||
var collectIntoArray = false
|
|
||||||
var writeInplace = false
|
var writeInplace = false
|
||||||
var writeScript = ""
|
|
||||||
var sourceYamlFile = ""
|
|
||||||
var outputToJSON = false
|
var outputToJSON = false
|
||||||
|
|
||||||
var exitStatus = false
|
var exitStatus = false
|
||||||
var prettyPrint = false
|
var forceColor = false
|
||||||
var explodeAnchors = false
|
var forceNoColor = false
|
||||||
var colorsEnabled = false
|
var colorsEnabled = false
|
||||||
var defaultValue = ""
|
|
||||||
var indent = 2
|
var indent = 2
|
||||||
var overwriteFlag = false
|
var noDocSeparators = false
|
||||||
var autoCreateFlag = true
|
var nullInput = false
|
||||||
var appendFlag = false
|
|
||||||
var verbose = false
|
var verbose = false
|
||||||
var version = false
|
var version = false
|
||||||
var docIndex = "0"
|
var prettyPrint = false
|
||||||
var log = logging.MustGetLogger("yq")
|
|
||||||
var lib = yqlib.NewYqLib()
|
var completedSuccessfully = false
|
||||||
var valueParser = yqlib.NewValueParser()
|
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/mikefarah/yq/v3/pkg/yqlib"
|
|
||||||
errors "github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func createDeleteCmd() *cobra.Command {
|
|
||||||
var cmdDelete = &cobra.Command{
|
|
||||||
Use: "delete [yaml_file] [path_expression]",
|
|
||||||
Aliases: []string{"d"},
|
|
||||||
Short: "yq d [--inplace/-i] [--doc/-d index] sample.yaml 'b.e(name==fred)'",
|
|
||||||
Example: `
|
|
||||||
yq delete things.yaml 'a.b.c'
|
|
||||||
yq delete things.yaml 'a.*.c'
|
|
||||||
yq delete things.yaml 'a.(child.subchild==co*).c'
|
|
||||||
yq delete things.yaml 'a.**'
|
|
||||||
yq delete --inplace things.yaml 'a.b.c'
|
|
||||||
yq delete --inplace -- things.yaml '--key-starting-with-dash' # need to use '--' to stop processing arguments as flags
|
|
||||||
yq d -i things.yaml 'a.b.c'
|
|
||||||
`,
|
|
||||||
Long: `Deletes the nodes matching the given path expression from the YAML file.
|
|
||||||
Outputs to STDOUT unless the inplace flag is used, in which case the file is updated instead.
|
|
||||||
`,
|
|
||||||
RunE: deleteProperty,
|
|
||||||
}
|
|
||||||
cmdDelete.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace")
|
|
||||||
cmdDelete.PersistentFlags().StringVarP(&docIndex, "doc", "d", "0", "process document index number (0 based, * for all documents)")
|
|
||||||
return cmdDelete
|
|
||||||
}
|
|
||||||
|
|
||||||
func deleteProperty(cmd *cobra.Command, args []string) error {
|
|
||||||
if len(args) < 2 {
|
|
||||||
return errors.New("Must provide <filename> <path_to_delete>")
|
|
||||||
}
|
|
||||||
var updateCommands []yqlib.UpdateCommand = make([]yqlib.UpdateCommand, 1)
|
|
||||||
updateCommands[0] = yqlib.UpdateCommand{Command: "delete", Path: args[1]}
|
|
||||||
|
|
||||||
return updateDoc(args[0], updateCommands, cmd.OutOrStdout())
|
|
||||||
}
|
|
@ -1,246 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/mikefarah/yq/v3/test"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestDeleteYamlCmd(t *testing.T) {
|
|
||||||
content := `a: 2
|
|
||||||
b:
|
|
||||||
c: things
|
|
||||||
d: something else
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("delete %s b.c", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedOutput := `a: 2
|
|
||||||
b:
|
|
||||||
d: something else
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeleteDeepDoesNotExistCmd(t *testing.T) {
|
|
||||||
content := `a: 2`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("delete %s b.c", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedOutput := `a: 2
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeleteSplatYaml(t *testing.T) {
|
|
||||||
content := `a: other
|
|
||||||
b: [3, 4]
|
|
||||||
c:
|
|
||||||
toast: leave
|
|
||||||
test: 1
|
|
||||||
tell: 1
|
|
||||||
tasty.taco: cool
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("delete %s c.te*", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedOutput := `a: other
|
|
||||||
b: [3, 4]
|
|
||||||
c:
|
|
||||||
toast: leave
|
|
||||||
tasty.taco: cool
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeleteSplatArrayYaml(t *testing.T) {
|
|
||||||
content := `a: 2
|
|
||||||
b:
|
|
||||||
hi:
|
|
||||||
- thing: item1
|
|
||||||
name: fred
|
|
||||||
- thing: item2
|
|
||||||
name: sam
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("delete %s b.hi[*].thing", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedOutput := `a: 2
|
|
||||||
b:
|
|
||||||
hi:
|
|
||||||
- name: fred
|
|
||||||
- name: sam
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeleteDeepSplatArrayYaml(t *testing.T) {
|
|
||||||
content := `thing: 123
|
|
||||||
b:
|
|
||||||
hi:
|
|
||||||
- thing: item1
|
|
||||||
name: fred
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("delete %s **.thing", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedOutput := `b:
|
|
||||||
hi:
|
|
||||||
- name: fred
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeleteSplatPrefixYaml(t *testing.T) {
|
|
||||||
content := `a: 2
|
|
||||||
b:
|
|
||||||
hi:
|
|
||||||
c: things
|
|
||||||
d: something else
|
|
||||||
there:
|
|
||||||
c: more things
|
|
||||||
d: more something else
|
|
||||||
there2:
|
|
||||||
c: more things also
|
|
||||||
d: more something else also
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("delete %s b.there*.c", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedOutput := `a: 2
|
|
||||||
b:
|
|
||||||
hi:
|
|
||||||
c: things
|
|
||||||
d: something else
|
|
||||||
there:
|
|
||||||
d: more something else
|
|
||||||
there2:
|
|
||||||
d: more something else also
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeleteYamlArrayCmd(t *testing.T) {
|
|
||||||
content := `- 1
|
|
||||||
- 2
|
|
||||||
- 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("delete %s [1]", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedOutput := `- 1
|
|
||||||
- 3
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeleteYamlArrayExpressionCmd(t *testing.T) {
|
|
||||||
content := `- name: fred
|
|
||||||
- name: cat
|
|
||||||
- name: thing
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("delete %s (name==cat)", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedOutput := `- name: fred
|
|
||||||
- name: thing
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeleteYamlMulti(t *testing.T) {
|
|
||||||
content := `apples: great
|
|
||||||
---
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
- 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("delete -d 1 %s [1]", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedOutput := `apples: great
|
|
||||||
---
|
|
||||||
- 1
|
|
||||||
- 3
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeleteYamlMultiAllCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
apples: great
|
|
||||||
---
|
|
||||||
apples: great
|
|
||||||
something: else
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("delete %s -d * apples", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 3
|
|
||||||
---
|
|
||||||
something: else`
|
|
||||||
test.AssertResult(t, expectedOutput, strings.Trim(result.Output, "\n "))
|
|
||||||
}
|
|
104
cmd/evaluate_all_command.go
Normal file
104
cmd/evaluate_all_command.go
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/mikefarah/yq/v4/pkg/yqlib"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func createEvaluateAllCommand() *cobra.Command {
|
||||||
|
var cmdEvalAll = &cobra.Command{
|
||||||
|
Use: "eval-all [expression] [yaml_file1]...",
|
||||||
|
Aliases: []string{"ea"},
|
||||||
|
Short: "Loads _all_ yaml documents of _all_ yaml files and runs expression once",
|
||||||
|
Example: `
|
||||||
|
# merges f2.yml into f1.yml (inplace)
|
||||||
|
yq eval-all --inplace 'select(fileIndex == 0) * select(fileIndex == 1)' f1.yml f2.yml
|
||||||
|
|
||||||
|
# use '-' as a filename to read from STDIN
|
||||||
|
cat file2.yml | yq ea '.a.b' file1.yml - file3.yml
|
||||||
|
`,
|
||||||
|
Long: "Evaluate All:\nUseful when you need to run an expression across several yaml documents or files. Consumes more memory than eval",
|
||||||
|
RunE: evaluateAll,
|
||||||
|
}
|
||||||
|
return cmdEvalAll
|
||||||
|
}
|
||||||
|
func evaluateAll(cmd *cobra.Command, args []string) error {
|
||||||
|
cmd.SilenceUsage = true
|
||||||
|
// 0 args, read std in
|
||||||
|
// 1 arg, null input, process expression
|
||||||
|
// 1 arg, read file in sequence
|
||||||
|
// 2+ args, [0] = expression, file the rest
|
||||||
|
|
||||||
|
var err error
|
||||||
|
stat, _ := os.Stdin.Stat()
|
||||||
|
pipingStdIn := (stat.Mode() & os.ModeCharDevice) == 0
|
||||||
|
|
||||||
|
out := cmd.OutOrStdout()
|
||||||
|
|
||||||
|
fileInfo, _ := os.Stdout.Stat()
|
||||||
|
|
||||||
|
if forceColor || (!forceNoColor && (fileInfo.Mode()&os.ModeCharDevice) != 0) {
|
||||||
|
colorsEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
firstFileIndex := -1
|
||||||
|
if !nullInput && len(args) == 1 {
|
||||||
|
firstFileIndex = 0
|
||||||
|
} else if len(args) > 1 {
|
||||||
|
firstFileIndex = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if writeInplace && (firstFileIndex == -1) {
|
||||||
|
return fmt.Errorf("Write inplace flag only applicable when giving an expression and at least one file")
|
||||||
|
}
|
||||||
|
|
||||||
|
if writeInplace {
|
||||||
|
// only use colors if its forced
|
||||||
|
colorsEnabled = forceColor
|
||||||
|
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[firstFileIndex])
|
||||||
|
out, err = writeInPlaceHandler.CreateTempFile()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// need to indirectly call the function so that completedSuccessfully is
|
||||||
|
// passed when we finish execution as opposed to now
|
||||||
|
defer func() { writeInPlaceHandler.FinishWriteInPlace(completedSuccessfully) }()
|
||||||
|
}
|
||||||
|
|
||||||
|
if nullInput && len(args) > 1 {
|
||||||
|
return errors.New("Cannot pass files in when using null-input flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
printer := yqlib.NewPrinter(out, outputToJSON, unwrapScalar, colorsEnabled, indent, !noDocSeparators)
|
||||||
|
|
||||||
|
allAtOnceEvaluator := yqlib.NewAllAtOnceEvaluator()
|
||||||
|
switch len(args) {
|
||||||
|
case 0:
|
||||||
|
if pipingStdIn {
|
||||||
|
err = allAtOnceEvaluator.EvaluateFiles(processExpression(""), []string{"-"}, printer)
|
||||||
|
} else {
|
||||||
|
cmd.Println(cmd.UsageString())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
if nullInput {
|
||||||
|
err = yqlib.NewStreamEvaluator().EvaluateNew(processExpression(args[0]), printer)
|
||||||
|
} else {
|
||||||
|
err = allAtOnceEvaluator.EvaluateFiles(processExpression(""), []string{args[0]}, printer)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
err = allAtOnceEvaluator.EvaluateFiles(processExpression(args[0]), args[1:], printer)
|
||||||
|
}
|
||||||
|
|
||||||
|
completedSuccessfully = err == nil
|
||||||
|
|
||||||
|
if err == nil && exitStatus && !printer.PrintedAnything() {
|
||||||
|
return errors.New("no matches found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
124
cmd/evalute_sequence_command.go
Normal file
124
cmd/evalute_sequence_command.go
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/mikefarah/yq/v4/pkg/yqlib"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func createEvaluateSequenceCommand() *cobra.Command {
|
||||||
|
var cmdEvalSequence = &cobra.Command{
|
||||||
|
Use: "eval [expression] [yaml_file1]...",
|
||||||
|
Aliases: []string{"e"},
|
||||||
|
Short: "Apply expression to each document in each yaml file given in sequence",
|
||||||
|
Example: `
|
||||||
|
# runs the expression against each file, in series
|
||||||
|
yq e '.a.b | length' f1.yml f2.yml
|
||||||
|
|
||||||
|
# prints out the file
|
||||||
|
yq e sample.yaml
|
||||||
|
|
||||||
|
# use '-' as a filename to read from STDIN
|
||||||
|
cat file2.yml | yq e '.a.b' file1.yml - file3.yml
|
||||||
|
|
||||||
|
# prints a new yaml document
|
||||||
|
yq e -n '.a.b.c = "cat"'
|
||||||
|
|
||||||
|
|
||||||
|
# updates file.yaml directly
|
||||||
|
yq e '.a.b = "cool"' -i file.yaml
|
||||||
|
`,
|
||||||
|
Long: "Evaluate Sequence:\nIterate over each yaml document, apply the expression and print the results, in sequence.",
|
||||||
|
RunE: evaluateSequence,
|
||||||
|
}
|
||||||
|
return cmdEvalSequence
|
||||||
|
}
|
||||||
|
|
||||||
|
func processExpression(expression string) string {
|
||||||
|
if prettyPrint && expression == "" {
|
||||||
|
return `... style=""`
|
||||||
|
} else if prettyPrint {
|
||||||
|
return fmt.Sprintf("%v | ... style= \"\"", expression)
|
||||||
|
}
|
||||||
|
return expression
|
||||||
|
}
|
||||||
|
|
||||||
|
func evaluateSequence(cmd *cobra.Command, args []string) error {
|
||||||
|
cmd.SilenceUsage = true
|
||||||
|
// 0 args, read std in
|
||||||
|
// 1 arg, null input, process expression
|
||||||
|
// 1 arg, read file in sequence
|
||||||
|
// 2+ args, [0] = expression, file the rest
|
||||||
|
|
||||||
|
var err error
|
||||||
|
stat, _ := os.Stdin.Stat()
|
||||||
|
pipingStdIn := (stat.Mode() & os.ModeCharDevice) == 0
|
||||||
|
|
||||||
|
out := cmd.OutOrStdout()
|
||||||
|
|
||||||
|
fileInfo, _ := os.Stdout.Stat()
|
||||||
|
|
||||||
|
if forceColor || (!forceNoColor && (fileInfo.Mode()&os.ModeCharDevice) != 0) {
|
||||||
|
colorsEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
firstFileIndex := -1
|
||||||
|
if !nullInput && len(args) == 1 {
|
||||||
|
firstFileIndex = 0
|
||||||
|
} else if len(args) > 1 {
|
||||||
|
firstFileIndex = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if writeInplace && (firstFileIndex == -1) {
|
||||||
|
return fmt.Errorf("Write inplace flag only applicable when giving an expression and at least one file")
|
||||||
|
}
|
||||||
|
|
||||||
|
if writeInplace {
|
||||||
|
// only use colors if its forced
|
||||||
|
colorsEnabled = forceColor
|
||||||
|
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[firstFileIndex])
|
||||||
|
out, err = writeInPlaceHandler.CreateTempFile()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// need to indirectly call the function so that completedSuccessfully is
|
||||||
|
// passed when we finish execution as opposed to now
|
||||||
|
defer func() { writeInPlaceHandler.FinishWriteInPlace(completedSuccessfully) }()
|
||||||
|
}
|
||||||
|
|
||||||
|
printer := yqlib.NewPrinter(out, outputToJSON, unwrapScalar, colorsEnabled, indent, !noDocSeparators)
|
||||||
|
|
||||||
|
streamEvaluator := yqlib.NewStreamEvaluator()
|
||||||
|
|
||||||
|
if nullInput && len(args) > 1 {
|
||||||
|
return errors.New("Cannot pass files in when using null-input flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch len(args) {
|
||||||
|
case 0:
|
||||||
|
if pipingStdIn {
|
||||||
|
err = streamEvaluator.EvaluateFiles(processExpression(""), []string{"-"}, printer)
|
||||||
|
} else {
|
||||||
|
cmd.Println(cmd.UsageString())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
if nullInput {
|
||||||
|
err = streamEvaluator.EvaluateNew(processExpression(args[0]), printer)
|
||||||
|
} else {
|
||||||
|
err = streamEvaluator.EvaluateFiles(processExpression(""), []string{args[0]}, printer)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
err = streamEvaluator.EvaluateFiles(processExpression(args[0]), args[1:], printer)
|
||||||
|
}
|
||||||
|
completedSuccessfully = err == nil
|
||||||
|
|
||||||
|
if err == nil && exitStatus && !printer.PrintedAnything() {
|
||||||
|
return errors.New("no matches found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
74
cmd/merge.go
74
cmd/merge.go
@ -1,74 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/mikefarah/yq/v3/pkg/yqlib"
|
|
||||||
errors "github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
yaml "gopkg.in/yaml.v3"
|
|
||||||
)
|
|
||||||
|
|
||||||
func createMergeCmd() *cobra.Command {
|
|
||||||
var cmdMerge = &cobra.Command{
|
|
||||||
Use: "merge [initial_yaml_file] [additional_yaml_file]...",
|
|
||||||
Aliases: []string{"m"},
|
|
||||||
Short: "yq m [--inplace/-i] [--doc/-d index] [--overwrite/-x] [--append/-a] sample.yaml sample2.yaml",
|
|
||||||
Example: `
|
|
||||||
yq merge things.yaml other.yaml
|
|
||||||
yq merge --inplace things.yaml other.yaml
|
|
||||||
yq m -i things.yaml other.yaml
|
|
||||||
yq m --overwrite things.yaml other.yaml
|
|
||||||
yq m -i -x things.yaml other.yaml
|
|
||||||
yq m -i -a things.yaml other.yaml
|
|
||||||
yq m -i --autocreate=false things.yaml other.yaml
|
|
||||||
`,
|
|
||||||
Long: `Updates the yaml file by adding/updating the path(s) and value(s) from additional yaml file(s).
|
|
||||||
Outputs to STDOUT unless the inplace flag is used, in which case the file is updated instead.
|
|
||||||
|
|
||||||
If overwrite flag is set then existing values will be overwritten using the values from each additional yaml file.
|
|
||||||
If append flag is set then existing arrays will be merged with the arrays from each additional yaml file.
|
|
||||||
`,
|
|
||||||
RunE: mergeProperties,
|
|
||||||
}
|
|
||||||
cmdMerge.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace")
|
|
||||||
cmdMerge.PersistentFlags().BoolVarP(&overwriteFlag, "overwrite", "x", false, "update the yaml file by overwriting existing values")
|
|
||||||
cmdMerge.PersistentFlags().BoolVarP(&autoCreateFlag, "autocreate", "c", true, "automatically create any missing entries")
|
|
||||||
cmdMerge.PersistentFlags().BoolVarP(&appendFlag, "append", "a", false, "update the yaml file by appending array values")
|
|
||||||
cmdMerge.PersistentFlags().StringVarP(&docIndex, "doc", "d", "0", "process document index number (0 based, * for all documents)")
|
|
||||||
return cmdMerge
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We don't deeply traverse arrays when appending a merge, instead we want to
|
|
||||||
* append the entire array element.
|
|
||||||
*/
|
|
||||||
func createReadFunctionForMerge() func(*yaml.Node) ([]*yqlib.NodeContext, error) {
|
|
||||||
return func(dataBucket *yaml.Node) ([]*yqlib.NodeContext, error) {
|
|
||||||
return lib.Get(dataBucket, "**", !appendFlag)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func mergeProperties(cmd *cobra.Command, args []string) error {
|
|
||||||
var updateCommands []yqlib.UpdateCommand = make([]yqlib.UpdateCommand, 0)
|
|
||||||
|
|
||||||
if len(args) < 1 {
|
|
||||||
return errors.New("Must provide at least 1 yaml file")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(args) > 1 {
|
|
||||||
// first generate update commands from the file
|
|
||||||
var filesToMerge = args[1:]
|
|
||||||
|
|
||||||
for _, fileToMerge := range filesToMerge {
|
|
||||||
matchingNodes, errorProcessingFile := doReadYamlFile(fileToMerge, createReadFunctionForMerge(), false, 0)
|
|
||||||
if errorProcessingFile != nil {
|
|
||||||
return errorProcessingFile
|
|
||||||
}
|
|
||||||
for _, matchingNode := range matchingNodes {
|
|
||||||
mergePath := lib.MergePathStackToString(matchingNode.PathStack, appendFlag)
|
|
||||||
updateCommands = append(updateCommands, yqlib.UpdateCommand{Command: "update", Path: mergePath, Value: matchingNode.Node, Overwrite: overwriteFlag})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return updateDoc(args[0], updateCommands, cmd.OutOrStdout())
|
|
||||||
}
|
|
@ -1,337 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"runtime"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/mikefarah/yq/v3/test"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestMergeCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge ../examples/data1.yaml ../examples/data2.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `a: simple # just the best
|
|
||||||
b: [1, 2]
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
toast: leave
|
|
||||||
tell: 1
|
|
||||||
tasty.taco: cool
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeOneFileCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge ../examples/data1.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `a: simple # just the best
|
|
||||||
b: [1, 2]
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeNoAutoCreateCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge -c=false ../examples/data1.yaml ../examples/data2.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `a: simple # just the best
|
|
||||||
b: [1, 2]
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeOverwriteCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge -c=false --overwrite ../examples/data1.yaml ../examples/data2.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `a: other # better than the original
|
|
||||||
b: [3, 4]
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeAppendCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge --autocreate=false --append ../examples/data1.yaml ../examples/data2.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `a: simple # just the best
|
|
||||||
b: [1, 2, 3, 4]
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeAppendArraysCmd(t *testing.T) {
|
|
||||||
content := `people:
|
|
||||||
- name: Barry
|
|
||||||
age: 21`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
mergeContent := `people:
|
|
||||||
- name: Roger
|
|
||||||
age: 44`
|
|
||||||
mergeFilename := test.WriteTempYamlFile(mergeContent)
|
|
||||||
defer test.RemoveTempYamlFile(mergeFilename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("merge --append -d* %s %s", filename, mergeFilename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `people:
|
|
||||||
- name: Barry
|
|
||||||
age: 21
|
|
||||||
- name: Roger
|
|
||||||
age: 44
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeOverwriteAndAppendCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge --autocreate=false --append --overwrite ../examples/data1.yaml ../examples/data2.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `a: other # better than the original
|
|
||||||
b: [1, 2, 3, 4]
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeArraysCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge --append ../examples/sample_array.yaml ../examples/sample_array_2.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `[1, 2, 3, 4, 5]
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeCmd_Multi(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge -d1 ../examples/multiple_docs_small.yaml ../examples/data1.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `a: Easy! as one two three
|
|
||||||
---
|
|
||||||
another:
|
|
||||||
document: here
|
|
||||||
a: simple # just the best
|
|
||||||
b:
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
---
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeYamlMultiAllCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
apples: green
|
|
||||||
---
|
|
||||||
something: else`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
mergeContent := `apples: red
|
|
||||||
something: good`
|
|
||||||
mergeFilename := test.WriteTempYamlFile(mergeContent)
|
|
||||||
defer test.RemoveTempYamlFile(mergeFilename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("merge -d* %s %s", filename, mergeFilename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 3
|
|
||||||
apples: green
|
|
||||||
something: good
|
|
||||||
---
|
|
||||||
something: else
|
|
||||||
apples: red
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeSpecialCharacterKeysCmd(t *testing.T) {
|
|
||||||
content := ``
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
mergeContent := `key[bracket]: value
|
|
||||||
key.bracket: value
|
|
||||||
key"value": value
|
|
||||||
key'value': value
|
|
||||||
`
|
|
||||||
mergeFilename := test.WriteTempYamlFile(mergeContent)
|
|
||||||
defer test.RemoveTempYamlFile(mergeFilename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("merge %s %s", filename, mergeFilename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
test.AssertResult(t, mergeContent, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeYamlMultiAllOverwriteCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
apples: green
|
|
||||||
---
|
|
||||||
something: else`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
mergeContent := `apples: red
|
|
||||||
something: good`
|
|
||||||
mergeFilename := test.WriteTempYamlFile(mergeContent)
|
|
||||||
defer test.RemoveTempYamlFile(mergeFilename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("merge --overwrite -d* %s %s", filename, mergeFilename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 3
|
|
||||||
apples: red
|
|
||||||
something: good
|
|
||||||
---
|
|
||||||
something: good
|
|
||||||
apples: red
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeYamlNullMapCmd(t *testing.T) {
|
|
||||||
content := `b:`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
mergeContent := `b:
|
|
||||||
thing: a frog
|
|
||||||
`
|
|
||||||
mergeFilename := test.WriteTempYamlFile(mergeContent)
|
|
||||||
defer test.RemoveTempYamlFile(mergeFilename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("merge %s %s", filename, mergeFilename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
test.AssertResult(t, mergeContent, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeCmd_Error(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge")
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail due to missing arg")
|
|
||||||
}
|
|
||||||
expectedOutput := `Must provide at least 1 yaml file`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeCmd_ErrorUnreadableFile(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge ../examples/data1.yaml fake-unknown")
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail due to unknown file")
|
|
||||||
}
|
|
||||||
var expectedOutput string
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
expectedOutput = `open fake-unknown: The system cannot find the file specified.`
|
|
||||||
} else {
|
|
||||||
expectedOutput = `open fake-unknown: no such file or directory`
|
|
||||||
}
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeCmd_Inplace(t *testing.T) {
|
|
||||||
filename := test.WriteTempYamlFile(test.ReadTempYamlFile("../examples/data1.yaml"))
|
|
||||||
err := os.Chmod(filename, os.FileMode(int(0666)))
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("merge -i %s ../examples/data2.yaml", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
info, _ := os.Stat(filename)
|
|
||||||
gotOutput := test.ReadTempYamlFile(filename)
|
|
||||||
expectedOutput := `a: simple # just the best
|
|
||||||
b: [1, 2]
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
toast: leave
|
|
||||||
tell: 1
|
|
||||||
tasty.taco: cool
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, gotOutput)
|
|
||||||
test.AssertResult(t, os.FileMode(int(0666)), info.Mode())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeAllowEmptyTargetCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge ../examples/empty.yaml ../examples/data1.yaml")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `a: simple # just the best
|
|
||||||
b:
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeAllowEmptyMergeCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "merge ../examples/data1.yaml ../examples/empty.yaml")
|
|
||||||
expectedOutput := `a: simple # just the best
|
|
||||||
b: [1, 2]
|
|
||||||
c:
|
|
||||||
test: 1
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
60
cmd/new.go
60
cmd/new.go
@ -1,60 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/mikefarah/yq/v3/pkg/yqlib"
|
|
||||||
errors "github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func createNewCmd() *cobra.Command {
|
|
||||||
var cmdNew = &cobra.Command{
|
|
||||||
Use: "new [path] [value]",
|
|
||||||
Aliases: []string{"n"},
|
|
||||||
Short: "yq n [--script/-s script_file] a.b.c newValue",
|
|
||||||
Example: `
|
|
||||||
yq new 'a.b.c' cat
|
|
||||||
yq n 'a.b.c' --tag '!!str' true # force 'true' to be interpreted as a string instead of bool
|
|
||||||
yq n 'a.b[+]' cat
|
|
||||||
yq n -- '--key-starting-with-dash' cat # need to use '--' to stop processing arguments as flags
|
|
||||||
yq n --script create_script.yaml
|
|
||||||
`,
|
|
||||||
Long: `Creates a new yaml w.r.t the given path and value.
|
|
||||||
Outputs to STDOUT
|
|
||||||
|
|
||||||
Create Scripts:
|
|
||||||
Note that you can give a create script to perform more sophisticated yaml. This follows the same format as the update script.
|
|
||||||
`,
|
|
||||||
RunE: newProperty,
|
|
||||||
}
|
|
||||||
cmdNew.PersistentFlags().StringVarP(&writeScript, "script", "s", "", "yaml script for creating yaml")
|
|
||||||
cmdNew.PersistentFlags().StringVarP(&customTag, "tag", "t", "", "set yaml tag (e.g. !!int)")
|
|
||||||
cmdNew.PersistentFlags().StringVarP(&customStyle, "style", "", "", "formatting style of the value: single, double, folded, flow, literal, tagged")
|
|
||||||
cmdNew.PersistentFlags().StringVarP(&anchorName, "anchorName", "", "", "anchor name")
|
|
||||||
cmdNew.PersistentFlags().BoolVarP(&makeAlias, "makeAlias", "", false, "create an alias using the value as the anchor name")
|
|
||||||
return cmdNew
|
|
||||||
}
|
|
||||||
|
|
||||||
func newProperty(cmd *cobra.Command, args []string) error {
|
|
||||||
var badArgsMessage = "Must provide <path_to_update> <value>"
|
|
||||||
if len(args) != 2 {
|
|
||||||
return errors.New(badArgsMessage)
|
|
||||||
}
|
|
||||||
|
|
||||||
var updateCommands, updateCommandsError = readUpdateCommands(args, 2, badArgsMessage)
|
|
||||||
if updateCommandsError != nil {
|
|
||||||
return updateCommandsError
|
|
||||||
}
|
|
||||||
newNode := lib.New(updateCommands[0].Path)
|
|
||||||
|
|
||||||
for _, updateCommand := range updateCommands {
|
|
||||||
|
|
||||||
errorUpdating := lib.Update(&newNode, updateCommand, true)
|
|
||||||
|
|
||||||
if errorUpdating != nil {
|
|
||||||
return errorUpdating
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var encoder = yqlib.NewYamlEncoder(cmd.OutOrStdout(), indent, colorsEnabled)
|
|
||||||
return encoder.Encode(&newNode)
|
|
||||||
}
|
|
101
cmd/new_test.go
101
cmd/new_test.go
@ -1,101 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/mikefarah/yq/v3/test"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestNewCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "new b.c 3")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewAnchorCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "new b.c 3 --anchorName=fred")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: &fred 3
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewAliasCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "new b.c foo --makeAlias")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: *foo
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewArrayCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "new b[0] 3")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
- 3
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewCmd_Error(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "new b.c")
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail due to missing arg")
|
|
||||||
}
|
|
||||||
expectedOutput := `Must provide <path_to_update> <value>`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewWithTaggedStyleCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "new b.c cat --tag=!!str --style=tagged")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: !!str cat
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewWithDoubleQuotedStyleCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "new b.c cat --style=double")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: "cat"
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewWithSingleQuotedStyleCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "new b.c cat --style=single")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 'cat'
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/mikefarah/yq/v3/pkg/yqlib"
|
|
||||||
errors "github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
yaml "gopkg.in/yaml.v3"
|
|
||||||
)
|
|
||||||
|
|
||||||
func createPrefixCmd() *cobra.Command {
|
|
||||||
var cmdPrefix = &cobra.Command{
|
|
||||||
Use: "prefix [yaml_file] [path]",
|
|
||||||
Aliases: []string{"p"},
|
|
||||||
Short: "yq p [--inplace/-i] [--doc/-d index] sample.yaml a.b.c",
|
|
||||||
Example: `
|
|
||||||
yq prefix things.yaml 'a.b.c'
|
|
||||||
yq prefix --inplace things.yaml 'a.b.c'
|
|
||||||
yq prefix --inplace -- things.yaml '--key-starting-with-dash' # need to use '--' to stop processing arguments as flags
|
|
||||||
yq p -i things.yaml 'a.b.c'
|
|
||||||
yq p --doc 2 things.yaml 'a.b.d'
|
|
||||||
yq p -d2 things.yaml 'a.b.d'
|
|
||||||
`,
|
|
||||||
Long: `Prefixes w.r.t to the yaml file at the given path.
|
|
||||||
Outputs to STDOUT unless the inplace flag is used, in which case the file is updated instead.
|
|
||||||
`,
|
|
||||||
RunE: prefixProperty,
|
|
||||||
}
|
|
||||||
cmdPrefix.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace")
|
|
||||||
cmdPrefix.PersistentFlags().StringVarP(&docIndex, "doc", "d", "0", "process document index number (0 based, * for all documents)")
|
|
||||||
return cmdPrefix
|
|
||||||
}
|
|
||||||
|
|
||||||
func prefixProperty(cmd *cobra.Command, args []string) error {
|
|
||||||
|
|
||||||
if len(args) < 2 {
|
|
||||||
return errors.New("Must provide <filename> <prefixed_path>")
|
|
||||||
}
|
|
||||||
updateCommand := yqlib.UpdateCommand{Command: "update", Path: args[1]}
|
|
||||||
log.Debugf("args %v", args)
|
|
||||||
|
|
||||||
var updateAll, docIndexInt, errorParsingDocIndex = parseDocumentIndex()
|
|
||||||
if errorParsingDocIndex != nil {
|
|
||||||
return errorParsingDocIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
var updateData = func(dataBucket *yaml.Node, currentIndex int) error {
|
|
||||||
return prefixDocument(updateAll, docIndexInt, currentIndex, dataBucket, updateCommand)
|
|
||||||
}
|
|
||||||
return readAndUpdate(cmd.OutOrStdout(), args[0], updateData)
|
|
||||||
}
|
|
@ -1,189 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/mikefarah/yq/v3/test"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestPrefixCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("prefix %s d", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `d:
|
|
||||||
b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrefixCmdArray(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("prefix %s [+].d.[+]", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `- d:
|
|
||||||
- b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrefixCmd_MultiLayer(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("prefix %s d.e.f", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `d:
|
|
||||||
e:
|
|
||||||
f:
|
|
||||||
b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrefixMultiCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
---
|
|
||||||
apples: great
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("prefix %s -d 1 d", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 3
|
|
||||||
---
|
|
||||||
d:
|
|
||||||
apples: great
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
func TestPrefixInvalidDocumentIndexCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("prefix %s -df d", filename))
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail due to invalid path")
|
|
||||||
}
|
|
||||||
expectedOutput := `Document index f is not a integer or *: strconv.ParseInt: parsing "f": invalid syntax`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrefixBadDocumentIndexCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("prefix %s -d 1 d", filename))
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail due to invalid path")
|
|
||||||
}
|
|
||||||
expectedOutput := `asked to process document index 1 but there are only 1 document(s)`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
||||||
func TestPrefixMultiAllCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
---
|
|
||||||
apples: great
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("prefix %s -d * d", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `d:
|
|
||||||
b:
|
|
||||||
c: 3
|
|
||||||
---
|
|
||||||
d:
|
|
||||||
apples: great`
|
|
||||||
test.AssertResult(t, expectedOutput, strings.Trim(result.Output, "\n "))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrefixCmd_Error(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "prefix")
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail due to missing arg")
|
|
||||||
}
|
|
||||||
expectedOutput := `Must provide <filename> <prefixed_path>`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrefixCmd_ErrorUnreadableFile(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "prefix fake-unknown a.b")
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail due to unknown file")
|
|
||||||
}
|
|
||||||
var expectedOutput string
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
expectedOutput = `open fake-unknown: The system cannot find the file specified.`
|
|
||||||
} else {
|
|
||||||
expectedOutput = `open fake-unknown: no such file or directory`
|
|
||||||
}
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrefixCmd_Inplace(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("prefix -i %s d", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
gotOutput := test.ReadTempYamlFile(filename)
|
|
||||||
expectedOutput := `d:
|
|
||||||
b:
|
|
||||||
c: 3`
|
|
||||||
test.AssertResult(t, expectedOutput, strings.Trim(gotOutput, "\n "))
|
|
||||||
}
|
|
66
cmd/read.go
66
cmd/read.go
@ -1,66 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
errors "github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func createReadCmd() *cobra.Command {
|
|
||||||
var cmdRead = &cobra.Command{
|
|
||||||
Use: "read [yaml_file] [path_expression]",
|
|
||||||
Aliases: []string{"r"},
|
|
||||||
Short: "yq r [--printMode/-p pv] sample.yaml 'b.e(name==fr*).value'",
|
|
||||||
Example: `
|
|
||||||
yq read things.yaml 'a.b.c'
|
|
||||||
yq r - 'a.b.c' # reads from stdin
|
|
||||||
yq r things.yaml 'a.*.c'
|
|
||||||
yq r things.yaml 'a.**.c' # deep splat
|
|
||||||
yq r things.yaml 'a.(child.subchild==co*).c'
|
|
||||||
yq r -d1 things.yaml 'a.array[0].blah'
|
|
||||||
yq r things.yaml 'a.array[*].blah'
|
|
||||||
yq r -- things.yaml '--key-starting-with-dashes.blah'
|
|
||||||
`,
|
|
||||||
Long: "Outputs the value of the given path in the yaml file to STDOUT",
|
|
||||||
RunE: readProperty,
|
|
||||||
}
|
|
||||||
cmdRead.PersistentFlags().StringVarP(&docIndex, "doc", "d", "0", "process document index number (0 based, * for all documents)")
|
|
||||||
cmdRead.PersistentFlags().StringVarP(&printMode, "printMode", "p", "v", "print mode (v (values, default), p (paths), pv (path and value pairs)")
|
|
||||||
cmdRead.PersistentFlags().StringVarP(&defaultValue, "defaultValue", "D", "", "default value printed when there are no results")
|
|
||||||
cmdRead.PersistentFlags().BoolVarP(&printLength, "length", "l", false, "print length of results")
|
|
||||||
cmdRead.PersistentFlags().BoolVarP(&collectIntoArray, "collect", "c", false, "collect results into array")
|
|
||||||
cmdRead.PersistentFlags().BoolVarP(&unwrapScalar, "unwrapScalar", "", true, "unwrap scalar, print the value with no quotes, colors or comments")
|
|
||||||
cmdRead.PersistentFlags().BoolVarP(&stripComments, "stripComments", "", false, "print yaml without any comments")
|
|
||||||
cmdRead.PersistentFlags().BoolVarP(&explodeAnchors, "explodeAnchors", "X", false, "explode anchors")
|
|
||||||
cmdRead.PersistentFlags().BoolVarP(&exitStatus, "exitStatus", "e", false, "set exit status if no matches are found")
|
|
||||||
return cmdRead
|
|
||||||
}
|
|
||||||
|
|
||||||
func readProperty(cmd *cobra.Command, args []string) error {
|
|
||||||
var path = ""
|
|
||||||
|
|
||||||
if len(args) < 1 {
|
|
||||||
return errors.New("Must provide filename")
|
|
||||||
} else if len(args) > 1 {
|
|
||||||
path = args[1]
|
|
||||||
}
|
|
||||||
|
|
||||||
var updateAll, docIndexInt, errorParsingDocIndex = parseDocumentIndex()
|
|
||||||
if errorParsingDocIndex != nil {
|
|
||||||
return errorParsingDocIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
matchingNodes, errorReadingStream := readYamlFile(args[0], path, updateAll, docIndexInt)
|
|
||||||
|
|
||||||
if exitStatus && len(matchingNodes) == 0 {
|
|
||||||
cmd.SilenceUsage = true
|
|
||||||
return errors.New("No matches found")
|
|
||||||
}
|
|
||||||
|
|
||||||
if errorReadingStream != nil {
|
|
||||||
cmd.SilenceUsage = true
|
|
||||||
return errorReadingStream
|
|
||||||
}
|
|
||||||
out := cmd.OutOrStdout()
|
|
||||||
|
|
||||||
return printResults(matchingNodes, out)
|
|
||||||
}
|
|
1361
cmd/read_test.go
1361
cmd/read_test.go
File diff suppressed because it is too large
Load Diff
28
cmd/root.go
28
cmd/root.go
@ -18,10 +18,11 @@ func New() *cobra.Command {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
cmd.Println(cmd.UsageString())
|
cmd.Println(cmd.UsageString())
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
},
|
},
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
cmd.SetOut(cmd.OutOrStdout())
|
||||||
var format = logging.MustStringFormatter(
|
var format = logging.MustStringFormatter(
|
||||||
`%{color}%{time:15:04:05} %{shortfunc} [%{level:.4s}]%{color:reset} %{message}`,
|
`%{color}%{time:15:04:05} %{shortfunc} [%{level:.4s}]%{color:reset} %{message}`,
|
||||||
)
|
)
|
||||||
@ -39,22 +40,23 @@ func New() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose mode")
|
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose mode")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&outputToJSON, "tojson", "j", false, "output as json. By default it prints a json document in one line, use the prettyPrint flag to print a formatted doc.")
|
rootCmd.PersistentFlags().BoolVarP(&outputToJSON, "tojson", "j", false, "output as json. Set indent to 0 to print json in one line.")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&prettyPrint, "prettyPrint", "P", false, "pretty print")
|
rootCmd.PersistentFlags().BoolVarP(&nullInput, "null-input", "n", false, "Don't read input, simply evaluate the expression given. Useful for creating yaml docs from scratch.")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&noDocSeparators, "no-doc", "N", false, "Don't print document separators (---)")
|
||||||
|
|
||||||
rootCmd.PersistentFlags().IntVarP(&indent, "indent", "I", 2, "sets indent level for output")
|
rootCmd.PersistentFlags().IntVarP(&indent, "indent", "I", 2, "sets indent level for output")
|
||||||
rootCmd.Flags().BoolVarP(&version, "version", "V", false, "Print version information and quit")
|
rootCmd.Flags().BoolVarP(&version, "version", "V", false, "Print version information and quit")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&colorsEnabled, "colors", "C", false, "print with colors")
|
rootCmd.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace of first yaml file given.")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&unwrapScalar, "unwrapScalar", "", true, "unwrap scalar, print the value with no quotes, colors or comments")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&prettyPrint, "prettyPrint", "P", false, "pretty print, shorthand for '... style = \"\"'")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&exitStatus, "exit-status", "e", false, "set exit status if there are no matches or null or false is returned")
|
||||||
|
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&forceColor, "colors", "C", false, "force print with colors")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&forceNoColor, "no-colors", "M", false, "force print with no colors")
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
createReadCmd(),
|
createEvaluateSequenceCommand(),
|
||||||
createCompareCmd(),
|
createEvaluateAllCommand(),
|
||||||
createValidateCmd(),
|
completionCmd,
|
||||||
createWriteCmd(),
|
|
||||||
createPrefixCmd(),
|
|
||||||
createDeleteCmd(),
|
|
||||||
createNewCmd(),
|
|
||||||
createMergeCmd(),
|
|
||||||
createBashCompletionCmd(rootCmd),
|
|
||||||
)
|
)
|
||||||
return rootCmd
|
return rootCmd
|
||||||
}
|
}
|
||||||
|
61
cmd/shell-completion.go
Normal file
61
cmd/shell-completion.go
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var completionCmd = &cobra.Command{
|
||||||
|
Use: "shell-completion [bash|zsh|fish|powershell]",
|
||||||
|
Short: "Generate completion script",
|
||||||
|
Long: `To load completions:
|
||||||
|
|
||||||
|
Bash:
|
||||||
|
|
||||||
|
$ source <(yq shell-completion bash)
|
||||||
|
|
||||||
|
# To load completions for each session, execute once:
|
||||||
|
Linux:
|
||||||
|
$ yq shell-completion bash > /etc/bash_completion.d/yq
|
||||||
|
MacOS:
|
||||||
|
$ yq shell-completion bash > /usr/local/etc/bash_completion.d/yq
|
||||||
|
|
||||||
|
Zsh:
|
||||||
|
|
||||||
|
# If shell completion is not already enabled in your environment you will need
|
||||||
|
# to enable it. You can execute the following once:
|
||||||
|
|
||||||
|
$ echo "autoload -U compinit; compinit" >> ~/.zshrc
|
||||||
|
|
||||||
|
# To load completions for each session, execute once:
|
||||||
|
$ yq shell-completion zsh > "${fpath[1]}/_yq"
|
||||||
|
|
||||||
|
# You will need to start a new shell for this setup to take effect.
|
||||||
|
|
||||||
|
Fish:
|
||||||
|
|
||||||
|
$ yq shell-completion fish | source
|
||||||
|
|
||||||
|
# To load completions for each session, execute once:
|
||||||
|
$ yq shell-completion fish > ~/.config/fish/completions/yq.fish
|
||||||
|
`,
|
||||||
|
DisableFlagsInUseLine: true,
|
||||||
|
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
||||||
|
Args: cobra.ExactValidArgs(1),
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
var err error = nil
|
||||||
|
switch args[0] {
|
||||||
|
case "bash":
|
||||||
|
err = cmd.Root().GenBashCompletion(os.Stdout)
|
||||||
|
case "zsh":
|
||||||
|
err = cmd.Root().GenZshCompletion(os.Stdout)
|
||||||
|
case "fish":
|
||||||
|
err = cmd.Root().GenFishCompletion(os.Stdout, true)
|
||||||
|
case "powershell":
|
||||||
|
err = cmd.Root().GenPowerShellCompletion(os.Stdout)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
@ -1,57 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
var shellVariant = "bash"
|
|
||||||
|
|
||||||
func createBashCompletionCmd(rootCmd *cobra.Command) *cobra.Command {
|
|
||||||
var completionCmd = &cobra.Command{
|
|
||||||
Use: "shell-completion",
|
|
||||||
Short: "Generates shell completion scripts",
|
|
||||||
Long: `To load completion for:
|
|
||||||
bash:
|
|
||||||
Run
|
|
||||||
. <(yq shell-completion)
|
|
||||||
|
|
||||||
To configure your bash shell to load completions for each session add to
|
|
||||||
your bashrc
|
|
||||||
|
|
||||||
# ~/.bashrc or ~/.profile
|
|
||||||
. <(yq shell-completion)
|
|
||||||
|
|
||||||
zsh:
|
|
||||||
The generated completion script should be put somewhere in your $fpath named _yq
|
|
||||||
|
|
||||||
powershell:
|
|
||||||
Users need PowerShell version 5.0 or above, which comes with Windows 10 and
|
|
||||||
can be downloaded separately for Windows 7 or 8.1. They can then write the
|
|
||||||
completions to a file and source this file from their PowerShell profile,
|
|
||||||
which is referenced by the $Profile environment variable.
|
|
||||||
|
|
||||||
fish:
|
|
||||||
Save the output to a fish file and add it to your completions directory.
|
|
||||||
|
|
||||||
`,
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
switch shellVariant {
|
|
||||||
case "bash", "":
|
|
||||||
return rootCmd.GenBashCompletion(os.Stdout)
|
|
||||||
case "zsh":
|
|
||||||
return rootCmd.GenZshCompletion(os.Stdout)
|
|
||||||
case "fish":
|
|
||||||
return rootCmd.GenFishCompletion(os.Stdout, true)
|
|
||||||
case "powershell":
|
|
||||||
return rootCmd.GenPowerShellCompletion(os.Stdout)
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("Unknown variant %v", shellVariant)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
completionCmd.PersistentFlags().StringVarP(&shellVariant, "variation", "V", "", "shell variation: bash (default), zsh, fish, powershell")
|
|
||||||
return completionCmd
|
|
||||||
}
|
|
609
cmd/utils.go
609
cmd/utils.go
@ -1,609 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/mikefarah/yq/v3/pkg/yqlib"
|
|
||||||
errors "github.com/pkg/errors"
|
|
||||||
yaml "gopkg.in/yaml.v3"
|
|
||||||
)
|
|
||||||
|
|
||||||
type readDataFn func(dataBucket *yaml.Node) ([]*yqlib.NodeContext, error)
|
|
||||||
|
|
||||||
func createReadFunction(path string) func(*yaml.Node) ([]*yqlib.NodeContext, error) {
|
|
||||||
return func(dataBucket *yaml.Node) ([]*yqlib.NodeContext, error) {
|
|
||||||
return lib.Get(dataBucket, path, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func readYamlFile(filename string, path string, updateAll bool, docIndexInt int) ([]*yqlib.NodeContext, error) {
|
|
||||||
return doReadYamlFile(filename, createReadFunction(path), updateAll, docIndexInt)
|
|
||||||
}
|
|
||||||
|
|
||||||
func doReadYamlFile(filename string, readFn readDataFn, updateAll bool, docIndexInt int) ([]*yqlib.NodeContext, error) {
|
|
||||||
var matchingNodes []*yqlib.NodeContext
|
|
||||||
|
|
||||||
var currentIndex = 0
|
|
||||||
var errorReadingStream = readStream(filename, func(decoder *yaml.Decoder) error {
|
|
||||||
for {
|
|
||||||
var dataBucket yaml.Node
|
|
||||||
errorReading := decoder.Decode(&dataBucket)
|
|
||||||
|
|
||||||
if errorReading == io.EOF {
|
|
||||||
return handleEOF(updateAll, docIndexInt, currentIndex)
|
|
||||||
} else if errorReading != nil {
|
|
||||||
return errorReading
|
|
||||||
}
|
|
||||||
|
|
||||||
var errorParsing error
|
|
||||||
matchingNodes, errorParsing = appendDocument(matchingNodes, dataBucket, readFn, updateAll, docIndexInt, currentIndex)
|
|
||||||
if errorParsing != nil {
|
|
||||||
return errorParsing
|
|
||||||
}
|
|
||||||
if !updateAll && currentIndex == docIndexInt {
|
|
||||||
log.Debug("all done")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
currentIndex = currentIndex + 1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return matchingNodes, errorReadingStream
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleEOF(updateAll bool, docIndexInt int, currentIndex int) error {
|
|
||||||
log.Debugf("done %v / %v", currentIndex, docIndexInt)
|
|
||||||
if !updateAll && currentIndex <= docIndexInt && docIndexInt != 0 {
|
|
||||||
return fmt.Errorf("Could not process document index %v as there are only %v document(s)", docIndex, currentIndex)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func appendDocument(originalMatchingNodes []*yqlib.NodeContext, dataBucket yaml.Node, readFn readDataFn, updateAll bool, docIndexInt int, currentIndex int) ([]*yqlib.NodeContext, error) {
|
|
||||||
log.Debugf("processing document %v - requested index %v", currentIndex, docIndexInt)
|
|
||||||
yqlib.DebugNode(&dataBucket)
|
|
||||||
if !updateAll && currentIndex != docIndexInt {
|
|
||||||
return originalMatchingNodes, nil
|
|
||||||
}
|
|
||||||
log.Debugf("reading in document %v", currentIndex)
|
|
||||||
matchingNodes, errorParsing := readFn(&dataBucket)
|
|
||||||
if errorParsing != nil {
|
|
||||||
return nil, errors.Wrapf(errorParsing, "Error reading path in document index %v", currentIndex)
|
|
||||||
}
|
|
||||||
return append(originalMatchingNodes, matchingNodes...), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func lengthOf(node *yaml.Node) int {
|
|
||||||
kindToCheck := node.Kind
|
|
||||||
if node.Kind == yaml.DocumentNode && len(node.Content) == 1 {
|
|
||||||
log.Debugf("length of document node, calculating length of child")
|
|
||||||
kindToCheck = node.Content[0].Kind
|
|
||||||
}
|
|
||||||
switch kindToCheck {
|
|
||||||
case yaml.ScalarNode:
|
|
||||||
return len(node.Value)
|
|
||||||
case yaml.MappingNode:
|
|
||||||
return len(node.Content) / 2
|
|
||||||
default:
|
|
||||||
return len(node.Content)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// transforms node before printing, if required
|
|
||||||
func transformNode(node *yaml.Node) *yaml.Node {
|
|
||||||
if printLength {
|
|
||||||
return &yaml.Node{Kind: yaml.ScalarNode, Value: fmt.Sprintf("%v", lengthOf(node))}
|
|
||||||
}
|
|
||||||
return node
|
|
||||||
}
|
|
||||||
|
|
||||||
func printNode(node *yaml.Node, writer io.Writer) error {
|
|
||||||
var encoder yqlib.Encoder
|
|
||||||
if node.Kind == yaml.ScalarNode && unwrapScalar && !outputToJSON {
|
|
||||||
return writeString(writer, node.Value+"\n")
|
|
||||||
}
|
|
||||||
if outputToJSON {
|
|
||||||
encoder = yqlib.NewJsonEncoder(writer, prettyPrint, indent)
|
|
||||||
} else {
|
|
||||||
encoder = yqlib.NewYamlEncoder(writer, indent, colorsEnabled)
|
|
||||||
}
|
|
||||||
return encoder.Encode(node)
|
|
||||||
}
|
|
||||||
|
|
||||||
func removeComments(matchingNodes []*yqlib.NodeContext) {
|
|
||||||
for _, nodeContext := range matchingNodes {
|
|
||||||
removeCommentOfNode(nodeContext.Node)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func removeCommentOfNode(node *yaml.Node) {
|
|
||||||
node.HeadComment = ""
|
|
||||||
node.LineComment = ""
|
|
||||||
node.FootComment = ""
|
|
||||||
|
|
||||||
for _, child := range node.Content {
|
|
||||||
removeCommentOfNode(child)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func setStyle(matchingNodes []*yqlib.NodeContext, style yaml.Style) {
|
|
||||||
for _, nodeContext := range matchingNodes {
|
|
||||||
updateStyleOfNode(nodeContext.Node, style)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func updateStyleOfNode(node *yaml.Node, style yaml.Style) {
|
|
||||||
node.Style = style
|
|
||||||
|
|
||||||
for _, child := range node.Content {
|
|
||||||
updateStyleOfNode(child, style)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func writeString(writer io.Writer, txt string) error {
|
|
||||||
_, errorWriting := writer.Write([]byte(txt))
|
|
||||||
return errorWriting
|
|
||||||
}
|
|
||||||
|
|
||||||
func setIfNotThere(node *yaml.Node, key string, value *yaml.Node) {
|
|
||||||
for index := 0; index < len(node.Content); index = index + 2 {
|
|
||||||
keyNode := node.Content[index]
|
|
||||||
if keyNode.Value == key {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// need to add it to the map
|
|
||||||
mapEntryKey := yaml.Node{Value: key, Kind: yaml.ScalarNode}
|
|
||||||
node.Content = append(node.Content, &mapEntryKey)
|
|
||||||
node.Content = append(node.Content, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func applyAlias(node *yaml.Node, alias *yaml.Node) {
|
|
||||||
for index := 0; index < len(alias.Content); index = index + 2 {
|
|
||||||
keyNode := alias.Content[index]
|
|
||||||
log.Debugf("applying alias key %v", keyNode.Value)
|
|
||||||
valueNode := alias.Content[index+1]
|
|
||||||
setIfNotThere(node, keyNode.Value, valueNode)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func explodeNode(node *yaml.Node) error {
|
|
||||||
node.Anchor = ""
|
|
||||||
switch node.Kind {
|
|
||||||
case yaml.SequenceNode, yaml.DocumentNode:
|
|
||||||
for index, contentNode := range node.Content {
|
|
||||||
log.Debugf("exploding index %v", index)
|
|
||||||
errorInContent := explodeNode(contentNode)
|
|
||||||
if errorInContent != nil {
|
|
||||||
return errorInContent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
case yaml.AliasNode:
|
|
||||||
log.Debugf("its an alias!")
|
|
||||||
node.Kind = node.Alias.Kind
|
|
||||||
node.Style = node.Alias.Style
|
|
||||||
node.Tag = node.Alias.Tag
|
|
||||||
node.Content = node.Alias.Content
|
|
||||||
node.Value = node.Alias.Value
|
|
||||||
node.Alias = nil
|
|
||||||
return nil
|
|
||||||
case yaml.MappingNode:
|
|
||||||
for index := 0; index < len(node.Content); index = index + 2 {
|
|
||||||
keyNode := node.Content[index]
|
|
||||||
valueNode := node.Content[index+1]
|
|
||||||
log.Debugf("traversing %v", keyNode.Value)
|
|
||||||
if keyNode.Value != "<<" {
|
|
||||||
errorInContent := explodeNode(valueNode)
|
|
||||||
if errorInContent != nil {
|
|
||||||
return errorInContent
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if valueNode.Kind == yaml.SequenceNode {
|
|
||||||
log.Debugf("an alias merge list!")
|
|
||||||
for index := len(valueNode.Content) - 1; index >= 0; index = index - 1 {
|
|
||||||
aliasNode := valueNode.Content[index]
|
|
||||||
applyAlias(node, aliasNode.Alias)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.Debugf("an alias merge!")
|
|
||||||
applyAlias(node, valueNode.Alias)
|
|
||||||
}
|
|
||||||
node.Content = append(node.Content[:index], node.Content[index+2:]...)
|
|
||||||
//replay that index, since the array is shorter now.
|
|
||||||
index = index - 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func explode(matchingNodes []*yqlib.NodeContext) error {
|
|
||||||
log.Debug("exploding nodes")
|
|
||||||
for _, nodeContext := range matchingNodes {
|
|
||||||
log.Debugf("exploding %v", nodeContext.Head)
|
|
||||||
errorExplodingNode := explodeNode(nodeContext.Node)
|
|
||||||
if errorExplodingNode != nil {
|
|
||||||
return errorExplodingNode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func printResults(matchingNodes []*yqlib.NodeContext, writer io.Writer) error {
|
|
||||||
if prettyPrint {
|
|
||||||
setStyle(matchingNodes, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if stripComments {
|
|
||||||
removeComments(matchingNodes)
|
|
||||||
}
|
|
||||||
|
|
||||||
//always explode anchors when printing json
|
|
||||||
if explodeAnchors || outputToJSON {
|
|
||||||
errorExploding := explode(matchingNodes)
|
|
||||||
if errorExploding != nil {
|
|
||||||
return errorExploding
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bufferedWriter := bufio.NewWriter(writer)
|
|
||||||
defer safelyFlush(bufferedWriter)
|
|
||||||
|
|
||||||
if len(matchingNodes) == 0 {
|
|
||||||
log.Debug("no matching results, nothing to print")
|
|
||||||
if defaultValue != "" {
|
|
||||||
return writeString(bufferedWriter, defaultValue)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var errorWriting error
|
|
||||||
|
|
||||||
var arrayCollection = yaml.Node{Kind: yaml.SequenceNode}
|
|
||||||
|
|
||||||
for _, mappedDoc := range matchingNodes {
|
|
||||||
switch printMode {
|
|
||||||
case "p":
|
|
||||||
errorWriting = writeString(bufferedWriter, lib.PathStackToString(mappedDoc.PathStack)+"\n")
|
|
||||||
if errorWriting != nil {
|
|
||||||
return errorWriting
|
|
||||||
}
|
|
||||||
case "pv", "vp":
|
|
||||||
// put it into a node and print that.
|
|
||||||
var parentNode = yaml.Node{Kind: yaml.MappingNode}
|
|
||||||
parentNode.Content = make([]*yaml.Node, 2)
|
|
||||||
parentNode.Content[0] = &yaml.Node{Kind: yaml.ScalarNode, Value: lib.PathStackToString(mappedDoc.PathStack)}
|
|
||||||
parentNode.Content[1] = transformNode(mappedDoc.Node)
|
|
||||||
if collectIntoArray {
|
|
||||||
arrayCollection.Content = append(arrayCollection.Content, &parentNode)
|
|
||||||
} else if err := printNode(&parentNode, bufferedWriter); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
if collectIntoArray {
|
|
||||||
arrayCollection.Content = append(arrayCollection.Content, mappedDoc.Node)
|
|
||||||
} else if err := printNode(transformNode(mappedDoc.Node), bufferedWriter); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if collectIntoArray {
|
|
||||||
if err := printNode(transformNode(&arrayCollection), bufferedWriter); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseDocumentIndex() (bool, int, error) {
|
|
||||||
if docIndex == "*" {
|
|
||||||
return true, -1, nil
|
|
||||||
}
|
|
||||||
docIndexInt64, err := strconv.ParseInt(docIndex, 10, 32)
|
|
||||||
if err != nil {
|
|
||||||
return false, -1, errors.Wrapf(err, "Document index %v is not a integer or *", docIndex)
|
|
||||||
}
|
|
||||||
return false, int(docIndexInt64), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type updateDataFn func(dataBucket *yaml.Node, currentIndex int) error
|
|
||||||
|
|
||||||
func isNullDocument(dataBucket *yaml.Node) bool {
|
|
||||||
return dataBucket.Kind == yaml.DocumentNode && (len(dataBucket.Content) == 0 ||
|
|
||||||
dataBucket.Content[0].Kind == yaml.ScalarNode && dataBucket.Content[0].Tag == "!!null")
|
|
||||||
}
|
|
||||||
|
|
||||||
func mapYamlDecoder(updateData updateDataFn, encoder yqlib.Encoder) yamlDecoderFn {
|
|
||||||
return func(decoder *yaml.Decoder) error {
|
|
||||||
var dataBucket yaml.Node
|
|
||||||
var errorReading error
|
|
||||||
var errorWriting error
|
|
||||||
var errorUpdating error
|
|
||||||
var currentIndex = 0
|
|
||||||
|
|
||||||
var updateAll, docIndexInt, errorParsingDocIndex = parseDocumentIndex()
|
|
||||||
if errorParsingDocIndex != nil {
|
|
||||||
return errorParsingDocIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
log.Debugf("Read doc %v", currentIndex)
|
|
||||||
errorReading = decoder.Decode(&dataBucket)
|
|
||||||
|
|
||||||
if errorReading == io.EOF && docIndexInt == 0 && currentIndex == 0 {
|
|
||||||
//empty document, lets just make one
|
|
||||||
dataBucket = yaml.Node{Kind: yaml.DocumentNode, Content: make([]*yaml.Node, 1)}
|
|
||||||
child := yaml.Node{Kind: yaml.MappingNode}
|
|
||||||
dataBucket.Content[0] = &child
|
|
||||||
} else if isNullDocument(&dataBucket) && (updateAll || docIndexInt == currentIndex) {
|
|
||||||
child := yaml.Node{Kind: yaml.MappingNode}
|
|
||||||
dataBucket.Content[0] = &child
|
|
||||||
} else if errorReading == io.EOF {
|
|
||||||
if !updateAll && currentIndex <= docIndexInt {
|
|
||||||
return fmt.Errorf("asked to process document index %v but there are only %v document(s)", docIndex, currentIndex)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
} else if errorReading != nil {
|
|
||||||
return errors.Wrapf(errorReading, "Error reading document at index %v, %v", currentIndex, errorReading)
|
|
||||||
}
|
|
||||||
errorUpdating = updateData(&dataBucket, currentIndex)
|
|
||||||
if errorUpdating != nil {
|
|
||||||
return errors.Wrapf(errorUpdating, "Error updating document at index %v", currentIndex)
|
|
||||||
}
|
|
||||||
|
|
||||||
if prettyPrint {
|
|
||||||
updateStyleOfNode(&dataBucket, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
errorWriting = encoder.Encode(&dataBucket)
|
|
||||||
|
|
||||||
if errorWriting != nil {
|
|
||||||
return errors.Wrapf(errorWriting, "Error writing document at index %v, %v", currentIndex, errorWriting)
|
|
||||||
}
|
|
||||||
currentIndex = currentIndex + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func prefixDocument(updateAll bool, docIndexInt int, currentIndex int, dataBucket *yaml.Node, updateCommand yqlib.UpdateCommand) error {
|
|
||||||
if updateAll || currentIndex == docIndexInt {
|
|
||||||
log.Debugf("Prefixing document %v", currentIndex)
|
|
||||||
yqlib.DebugNode(dataBucket)
|
|
||||||
updateCommand.Value = dataBucket.Content[0]
|
|
||||||
dataBucket.Content = make([]*yaml.Node, 1)
|
|
||||||
|
|
||||||
newNode := lib.New(updateCommand.Path)
|
|
||||||
dataBucket.Content[0] = &newNode
|
|
||||||
|
|
||||||
errorUpdating := lib.Update(dataBucket, updateCommand, true)
|
|
||||||
if errorUpdating != nil {
|
|
||||||
return errorUpdating
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func updateDoc(inputFile string, updateCommands []yqlib.UpdateCommand, writer io.Writer) error {
|
|
||||||
var updateAll, docIndexInt, errorParsingDocIndex = parseDocumentIndex()
|
|
||||||
if errorParsingDocIndex != nil {
|
|
||||||
return errorParsingDocIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
var updateData = func(dataBucket *yaml.Node, currentIndex int) error {
|
|
||||||
if updateAll || currentIndex == docIndexInt {
|
|
||||||
log.Debugf("Updating doc %v", currentIndex)
|
|
||||||
for _, updateCommand := range updateCommands {
|
|
||||||
log.Debugf("Processing update to Path %v", updateCommand.Path)
|
|
||||||
errorUpdating := lib.Update(dataBucket, updateCommand, autoCreateFlag)
|
|
||||||
if errorUpdating != nil {
|
|
||||||
return errorUpdating
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return readAndUpdate(writer, inputFile, updateData)
|
|
||||||
}
|
|
||||||
|
|
||||||
func readAndUpdate(stdOut io.Writer, inputFile string, updateData updateDataFn) error {
|
|
||||||
var destination io.Writer
|
|
||||||
var destinationName string
|
|
||||||
var completedSuccessfully = false
|
|
||||||
if writeInplace {
|
|
||||||
info, err := os.Stat(inputFile)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// mkdir temp dir as some docker images does not have temp dir
|
|
||||||
_, err = os.Stat(os.TempDir())
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
err = os.Mkdir(os.TempDir(), 0700)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
tempFile, err := ioutil.TempFile("", "temp")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
destinationName = tempFile.Name()
|
|
||||||
err = os.Chmod(destinationName, info.Mode())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
destination = tempFile
|
|
||||||
defer func() {
|
|
||||||
safelyCloseFile(tempFile)
|
|
||||||
if completedSuccessfully {
|
|
||||||
safelyRenameFile(tempFile.Name(), inputFile)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
} else {
|
|
||||||
destination = stdOut
|
|
||||||
destinationName = "Stdout"
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("Writing to %v from %v", destinationName, inputFile)
|
|
||||||
|
|
||||||
bufferedWriter := bufio.NewWriter(destination)
|
|
||||||
defer safelyFlush(bufferedWriter)
|
|
||||||
|
|
||||||
var encoder yqlib.Encoder
|
|
||||||
if outputToJSON {
|
|
||||||
encoder = yqlib.NewJsonEncoder(bufferedWriter, prettyPrint, indent)
|
|
||||||
} else {
|
|
||||||
encoder = yqlib.NewYamlEncoder(bufferedWriter, indent, colorsEnabled)
|
|
||||||
}
|
|
||||||
|
|
||||||
var errorProcessing = readStream(inputFile, mapYamlDecoder(updateData, encoder))
|
|
||||||
completedSuccessfully = errorProcessing == nil
|
|
||||||
return errorProcessing
|
|
||||||
}
|
|
||||||
|
|
||||||
type updateCommandParsed struct {
|
|
||||||
Command string
|
|
||||||
Path string
|
|
||||||
Value yaml.Node
|
|
||||||
}
|
|
||||||
|
|
||||||
func readUpdateCommands(args []string, expectedArgs int, badArgsMessage string) ([]yqlib.UpdateCommand, error) {
|
|
||||||
var updateCommands []yqlib.UpdateCommand = make([]yqlib.UpdateCommand, 0)
|
|
||||||
if writeScript != "" {
|
|
||||||
var parsedCommands = make([]updateCommandParsed, 0)
|
|
||||||
|
|
||||||
err := readData(writeScript, 0, &parsedCommands)
|
|
||||||
|
|
||||||
if err != nil && err != io.EOF {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("Read write commands file '%v'", parsedCommands)
|
|
||||||
for index := range parsedCommands {
|
|
||||||
parsedCommand := parsedCommands[index]
|
|
||||||
updateCommand := yqlib.UpdateCommand{Command: parsedCommand.Command, Path: parsedCommand.Path, Value: &parsedCommand.Value, Overwrite: true}
|
|
||||||
updateCommands = append(updateCommands, updateCommand)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("Read write commands file '%v'", updateCommands)
|
|
||||||
} else if sourceYamlFile != "" && len(args) == expectedArgs-1 {
|
|
||||||
log.Debugf("Reading value from %v", sourceYamlFile)
|
|
||||||
var value yaml.Node
|
|
||||||
err := readData(sourceYamlFile, 0, &value)
|
|
||||||
if err != nil && err != io.EOF {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
log.Debug("args %v", args[expectedArgs-2])
|
|
||||||
updateCommands = make([]yqlib.UpdateCommand, 1)
|
|
||||||
updateCommands[0] = yqlib.UpdateCommand{Command: "update", Path: args[expectedArgs-2], Value: value.Content[0], Overwrite: true}
|
|
||||||
} else if len(args) == expectedArgs {
|
|
||||||
updateCommands = make([]yqlib.UpdateCommand, 1)
|
|
||||||
log.Debug("args %v", args)
|
|
||||||
log.Debug("path %v", args[expectedArgs-2])
|
|
||||||
log.Debug("Value %v", args[expectedArgs-1])
|
|
||||||
updateCommands[0] = yqlib.UpdateCommand{Command: "update", Path: args[expectedArgs-2], Value: valueParser.Parse(args[expectedArgs-1], customTag, customStyle, anchorName, makeAlias), Overwrite: true}
|
|
||||||
} else if len(args) == expectedArgs-1 {
|
|
||||||
// don't update the value
|
|
||||||
updateCommands = make([]yqlib.UpdateCommand, 1)
|
|
||||||
log.Debug("args %v", args)
|
|
||||||
log.Debug("path %v", args[expectedArgs-2])
|
|
||||||
updateCommands[0] = yqlib.UpdateCommand{Command: "update", Path: args[expectedArgs-2], Value: valueParser.Parse("", customTag, customStyle, anchorName, makeAlias), Overwrite: true, DontUpdateNodeValue: true}
|
|
||||||
} else {
|
|
||||||
return nil, errors.New(badArgsMessage)
|
|
||||||
}
|
|
||||||
return updateCommands, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func safelyRenameFile(from string, to string) {
|
|
||||||
if renameError := os.Rename(from, to); renameError != nil {
|
|
||||||
log.Debugf("Error renaming from %v to %v, attempting to copy contents", from, to)
|
|
||||||
log.Debug(renameError.Error())
|
|
||||||
// can't do this rename when running in docker to a file targeted in a mounted volume,
|
|
||||||
// so gracefully degrade to copying the entire contents.
|
|
||||||
if copyError := copyFileContents(from, to); copyError != nil {
|
|
||||||
log.Errorf("Failed copying from %v to %v", from, to)
|
|
||||||
log.Error(copyError.Error())
|
|
||||||
} else {
|
|
||||||
removeErr := os.Remove(from)
|
|
||||||
if removeErr != nil {
|
|
||||||
log.Errorf("failed removing original file: %s", from)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// thanks https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang
|
|
||||||
func copyFileContents(src, dst string) (err error) {
|
|
||||||
in, err := os.Open(src) // nolint gosec
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer safelyCloseFile(in)
|
|
||||||
out, err := os.Create(dst)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer safelyCloseFile(out)
|
|
||||||
if _, err = io.Copy(out, in); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return out.Sync()
|
|
||||||
}
|
|
||||||
|
|
||||||
func safelyFlush(writer *bufio.Writer) {
|
|
||||||
if err := writer.Flush(); err != nil {
|
|
||||||
log.Error("Error flushing writer!")
|
|
||||||
log.Error(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
func safelyCloseFile(file *os.File) {
|
|
||||||
err := file.Close()
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Error closing file!")
|
|
||||||
log.Error(err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type yamlDecoderFn func(*yaml.Decoder) error
|
|
||||||
|
|
||||||
func readStream(filename string, yamlDecoder yamlDecoderFn) error {
|
|
||||||
if filename == "" {
|
|
||||||
return errors.New("Must provide filename")
|
|
||||||
}
|
|
||||||
|
|
||||||
var stream io.Reader
|
|
||||||
if filename == "-" {
|
|
||||||
stream = bufio.NewReader(os.Stdin)
|
|
||||||
} else {
|
|
||||||
file, err := os.Open(filename) // nolint gosec
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer safelyCloseFile(file)
|
|
||||||
stream = file
|
|
||||||
}
|
|
||||||
return yamlDecoder(yaml.NewDecoder(stream))
|
|
||||||
}
|
|
||||||
|
|
||||||
func readData(filename string, indexToRead int, parsedData interface{}) error {
|
|
||||||
return readStream(filename, func(decoder *yaml.Decoder) error {
|
|
||||||
for currentIndex := 0; currentIndex < indexToRead; currentIndex++ {
|
|
||||||
errorSkipping := decoder.Decode(parsedData)
|
|
||||||
if errorSkipping != nil {
|
|
||||||
return errors.Wrapf(errorSkipping, "Error processing document at index %v, %v", currentIndex, errorSkipping)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return decoder.Decode(parsedData)
|
|
||||||
})
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
errors "github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func createValidateCmd() *cobra.Command {
|
|
||||||
var cmdRead = &cobra.Command{
|
|
||||||
Use: "validate [yaml_file]",
|
|
||||||
Aliases: []string{"v"},
|
|
||||||
Short: "yq v sample.yaml",
|
|
||||||
Example: `
|
|
||||||
yq v - # reads from stdin
|
|
||||||
`,
|
|
||||||
RunE: validateProperty,
|
|
||||||
SilenceUsage: true,
|
|
||||||
SilenceErrors: true,
|
|
||||||
}
|
|
||||||
cmdRead.PersistentFlags().StringVarP(&docIndex, "doc", "d", "0", "process document index number (0 based, * for all documents)")
|
|
||||||
return cmdRead
|
|
||||||
}
|
|
||||||
|
|
||||||
func validateProperty(cmd *cobra.Command, args []string) error {
|
|
||||||
if len(args) < 1 {
|
|
||||||
return errors.New("Must provide filename")
|
|
||||||
}
|
|
||||||
|
|
||||||
var updateAll, docIndexInt, errorParsingDocIndex = parseDocumentIndex()
|
|
||||||
if errorParsingDocIndex != nil {
|
|
||||||
return errorParsingDocIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
_, errorReadingStream := readYamlFile(args[0], "", updateAll, docIndexInt)
|
|
||||||
|
|
||||||
return errorReadingStream
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/mikefarah/yq/v3/test"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestValidateCmd(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "validate ../examples/sample.yaml b.c")
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
test.AssertResult(t, "", result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestValidateBadDataCmd(t *testing.T) {
|
|
||||||
content := `[!Whatever]`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("validate %s", filename))
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail")
|
|
||||||
}
|
|
||||||
expectedOutput := `yaml: line 1: did not find expected ',' or ']'`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
@ -11,7 +11,7 @@ var (
|
|||||||
GitDescribe string
|
GitDescribe string
|
||||||
|
|
||||||
// Version is main version number that is being run at the moment.
|
// Version is main version number that is being run at the moment.
|
||||||
Version = "3.3.2"
|
Version = "4.9.3"
|
||||||
|
|
||||||
// VersionPrerelease is a pre-release marker for the version. If this is "" (empty string)
|
// 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
|
// then it means that it is a final release. Otherwise, this is a pre-release
|
||||||
|
61
cmd/write.go
61
cmd/write.go
@ -1,61 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func createWriteCmd() *cobra.Command {
|
|
||||||
var cmdWrite = &cobra.Command{
|
|
||||||
Use: "write [yaml_file] [path_expression] [value]",
|
|
||||||
Aliases: []string{"w"},
|
|
||||||
Short: "yq w [--inplace/-i] [--script/-s script_file] [--doc/-d index] sample.yaml 'b.e(name==fr*).value' newValue",
|
|
||||||
Example: `
|
|
||||||
yq write things.yaml 'a.b.c' true
|
|
||||||
yq write things.yaml 'a.*.c' true
|
|
||||||
yq write things.yaml 'a.**' true
|
|
||||||
yq write things.yaml 'a.(child.subchild==co*).c' true
|
|
||||||
yq write things.yaml 'a.b.c' --tag '!!str' true # force 'true' to be interpreted as a string instead of bool
|
|
||||||
yq write things.yaml 'a.b.c' --tag '!!float' 3
|
|
||||||
yq write --inplace -- things.yaml 'a.b.c' '--cat' # need to use '--' to stop processing arguments as flags
|
|
||||||
yq w -i things.yaml 'a.b.c' cat
|
|
||||||
yq w -i -s update_script.yaml things.yaml
|
|
||||||
yq w things.yaml 'a.b.d[+]' foo # appends a new node to the 'd' array
|
|
||||||
yq w --doc 2 things.yaml 'a.b.d[+]' foo # updates the 3rd document of the yaml file
|
|
||||||
`,
|
|
||||||
Long: `Updates the yaml file w.r.t the given path and value.
|
|
||||||
Outputs to STDOUT unless the inplace flag is used, in which case the file is updated instead.
|
|
||||||
|
|
||||||
Append value to array adds the value to the end of array.
|
|
||||||
|
|
||||||
Update Scripts:
|
|
||||||
Note that you can give an update script to perform more sophisticated update. Update script
|
|
||||||
format is list of update commands (update or delete) like so:
|
|
||||||
---
|
|
||||||
- command: update
|
|
||||||
path: b.c
|
|
||||||
value:
|
|
||||||
#great
|
|
||||||
things: frog # wow!
|
|
||||||
- command: delete
|
|
||||||
path: b.d
|
|
||||||
`,
|
|
||||||
RunE: writeProperty,
|
|
||||||
}
|
|
||||||
cmdWrite.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace")
|
|
||||||
cmdWrite.PersistentFlags().StringVarP(&writeScript, "script", "s", "", "yaml script for updating yaml")
|
|
||||||
cmdWrite.PersistentFlags().StringVarP(&sourceYamlFile, "from", "f", "", "yaml file for updating yaml (as-is)")
|
|
||||||
cmdWrite.PersistentFlags().StringVarP(&customTag, "tag", "t", "", "set yaml tag (e.g. !!int)")
|
|
||||||
cmdWrite.PersistentFlags().StringVarP(&docIndex, "doc", "d", "0", "process document index number (0 based, * for all documents)")
|
|
||||||
cmdWrite.PersistentFlags().StringVarP(&customStyle, "style", "", "", "formatting style of the value: single, double, folded, flow, literal, tagged")
|
|
||||||
cmdWrite.PersistentFlags().StringVarP(&anchorName, "anchorName", "", "", "anchor name")
|
|
||||||
cmdWrite.PersistentFlags().BoolVarP(&makeAlias, "makeAlias", "", false, "create an alias using the value as the anchor name")
|
|
||||||
return cmdWrite
|
|
||||||
}
|
|
||||||
|
|
||||||
func writeProperty(cmd *cobra.Command, args []string) error {
|
|
||||||
var updateCommands, updateCommandsError = readUpdateCommands(args, 3, "Must provide <filename> <path_to_update> <value>")
|
|
||||||
if updateCommandsError != nil {
|
|
||||||
return updateCommandsError
|
|
||||||
}
|
|
||||||
return updateDoc(args[0], updateCommands, cmd.OutOrStdout())
|
|
||||||
}
|
|
@ -1,593 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/mikefarah/yq/v3/test"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestWriteCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c 7", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 7
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteWithTaggedStyleCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: dog
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c cat --tag=!!str --style=tagged", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: !!str cat
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteWithDoubleQuotedStyleCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: dog
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c cat --style=double", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: "cat"
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteUpdateStyleOnlyCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: dog
|
|
||||||
d: things
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.* --style=single", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 'dog'
|
|
||||||
d: 'things'
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteUpdateTagOnlyCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: true
|
|
||||||
d: false
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.* --tag=!!str", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: "true"
|
|
||||||
d: "false"
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteWithSingleQuotedStyleCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: dog
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c cat --style=single", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 'cat'
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteWithLiteralStyleCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: dog
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c cat --style=literal", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: |-
|
|
||||||
cat
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteWithFoldedStyleCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: dog
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c cat --style=folded", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: >-
|
|
||||||
cat
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteEmptyMultiDocCmd(t *testing.T) {
|
|
||||||
content := `# this is empty
|
|
||||||
---
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s c 7", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `c: 7
|
|
||||||
|
|
||||||
# this is empty
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteSurroundingEmptyMultiDocCmd(t *testing.T) {
|
|
||||||
content := `---
|
|
||||||
# empty
|
|
||||||
---
|
|
||||||
cat: frog
|
|
||||||
---
|
|
||||||
|
|
||||||
# empty
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s -d1 c 7", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `
|
|
||||||
|
|
||||||
# empty
|
|
||||||
---
|
|
||||||
cat: frog
|
|
||||||
c: 7
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
# empty
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteFromFileCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
source := `kittens: are cute # sure are!`
|
|
||||||
fromFilename := test.WriteTempYamlFile(source)
|
|
||||||
defer test.RemoveTempYamlFile(fromFilename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c -f %s", filename, fromFilename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c:
|
|
||||||
kittens: are cute # sure are!
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteEmptyCmd(t *testing.T) {
|
|
||||||
content := ``
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c 7", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 7
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteAutoCreateCmd(t *testing.T) {
|
|
||||||
content := `applications:
|
|
||||||
- name: app
|
|
||||||
env:`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s applications[0].env.hello world", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `applications:
|
|
||||||
- name: app
|
|
||||||
env:
|
|
||||||
hello: world
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmdScript(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
updateScript := `- command: update
|
|
||||||
path: b.c
|
|
||||||
value: 7`
|
|
||||||
scriptFilename := test.WriteTempYamlFile(updateScript)
|
|
||||||
defer test.RemoveTempYamlFile(scriptFilename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write --script %s %s", scriptFilename, filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 7
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmdEmptyScript(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
updateScript := ``
|
|
||||||
scriptFilename := test.WriteTempYamlFile(updateScript)
|
|
||||||
defer test.RemoveTempYamlFile(scriptFilename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write --script %s %s", scriptFilename, filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteMultiCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
---
|
|
||||||
apples: great
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s -d 1 apples ok", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 3
|
|
||||||
---
|
|
||||||
apples: ok
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
func TestWriteInvalidDocumentIndexCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s -df apples ok", filename))
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail due to invalid path")
|
|
||||||
}
|
|
||||||
expectedOutput := `Document index f is not a integer or *: strconv.ParseInt: parsing "f": invalid syntax`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteBadDocumentIndexCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s -d 1 apples ok", filename))
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail due to invalid path")
|
|
||||||
}
|
|
||||||
expectedOutput := `asked to process document index 1 but there are only 1 document(s)`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
||||||
func TestWriteMultiAllCmd(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
---
|
|
||||||
apples: great
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s -d * apples ok", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 3
|
|
||||||
apples: ok
|
|
||||||
---
|
|
||||||
apples: ok`
|
|
||||||
test.AssertResult(t, expectedOutput, strings.Trim(result.Output, "\n "))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_EmptyArray(t *testing.T) {
|
|
||||||
content := `b: 3`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s a []", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b: 3
|
|
||||||
a: []
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_Error(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "write")
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail due to missing arg")
|
|
||||||
}
|
|
||||||
expectedOutput := `Must provide <filename> <path_to_update> <value>`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_ErrorUnreadableFile(t *testing.T) {
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, "write fake-unknown a.b 3")
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected command to fail due to unknown file")
|
|
||||||
}
|
|
||||||
var expectedOutput string
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
expectedOutput = `open fake-unknown: The system cannot find the file specified.`
|
|
||||||
} else {
|
|
||||||
expectedOutput = `open fake-unknown: no such file or directory`
|
|
||||||
}
|
|
||||||
test.AssertResult(t, expectedOutput, result.Error.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_Inplace(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write -i %s b.c 7", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
gotOutput := test.ReadTempYamlFile(filename)
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: 7`
|
|
||||||
test.AssertResult(t, expectedOutput, strings.Trim(gotOutput, "\n "))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_InplaceError(t *testing.T) {
|
|
||||||
content := `b: cat
|
|
||||||
c: 3
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write -i %s b.c 7", filename))
|
|
||||||
if result.Error == nil {
|
|
||||||
t.Error("Expected Error to occur!")
|
|
||||||
}
|
|
||||||
gotOutput := test.ReadTempYamlFile(filename)
|
|
||||||
test.AssertResult(t, content, gotOutput)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_Append(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
- foo
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b[+] 7", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
- foo
|
|
||||||
- 7
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_AppendInline(t *testing.T) {
|
|
||||||
content := `b: [foo]`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b[+] 7", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b: [foo, 7]
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_AppendInlinePretty(t *testing.T) {
|
|
||||||
content := `b: [foo]`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s -P b[+] 7", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
- foo
|
|
||||||
- 7
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_AppendEmptyArray(t *testing.T) {
|
|
||||||
content := `a: 2
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b[+] v", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `a: 2
|
|
||||||
b:
|
|
||||||
- v
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_SplatArray(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
- c: thing
|
|
||||||
- c: another thing
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b[*].c new", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
- c: new
|
|
||||||
- c: new
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_SplatMap(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: thing
|
|
||||||
d: another thing
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.* new", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: new
|
|
||||||
d: new
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteCmd_SplatMapEmpty(t *testing.T) {
|
|
||||||
content := `b:
|
|
||||||
c: thing
|
|
||||||
d: another thing
|
|
||||||
`
|
|
||||||
filename := test.WriteTempYamlFile(content)
|
|
||||||
defer test.RemoveTempYamlFile(filename)
|
|
||||||
|
|
||||||
cmd := getRootCommand()
|
|
||||||
result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c.* new", filename))
|
|
||||||
if result.Error != nil {
|
|
||||||
t.Error(result.Error)
|
|
||||||
}
|
|
||||||
expectedOutput := `b:
|
|
||||||
c: {}
|
|
||||||
d: another thing
|
|
||||||
`
|
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
|
||||||
}
|
|
13
compare.sh
13
compare.sh
@ -1,13 +0,0 @@
|
|||||||
GREEN='\033[0;32m'
|
|
||||||
NC='\033[0m'
|
|
||||||
|
|
||||||
echo "${GREEN}---Old---${NC}"
|
|
||||||
yq $@ > /tmp/yq-old-output
|
|
||||||
cat /tmp/yq-old-output
|
|
||||||
|
|
||||||
echo "${GREEN}---New---${NC}"
|
|
||||||
./yq $@ > /tmp/yq-new-output
|
|
||||||
cat /tmp/yq-new-output
|
|
||||||
|
|
||||||
echo "${GREEN}---Diff---${NC}"
|
|
||||||
colordiff /tmp/yq-old-output /tmp/yq-new-output
|
|
7
debian/changelog
vendored
7
debian/changelog
vendored
@ -1,3 +1,10 @@
|
|||||||
|
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
|
yq (3.3-0) focal; urgency=medium
|
||||||
|
|
||||||
* You can control string styles (quotes) using the new --style flag
|
* You can control string styles (quotes) using the new --style flag
|
||||||
|
268
docs/404.html
268
docs/404.html
@ -1,268 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en" class="no-js">
|
|
||||||
<head>
|
|
||||||
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
||||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<meta name="lang:clipboard.copy" content="Copy to clipboard">
|
|
||||||
|
|
||||||
<meta name="lang:clipboard.copied" content="Copied to clipboard">
|
|
||||||
|
|
||||||
<meta name="lang:search.language" content="en">
|
|
||||||
|
|
||||||
<meta name="lang:search.pipeline.stopwords" content="True">
|
|
||||||
|
|
||||||
<meta name="lang:search.pipeline.trimmer" content="True">
|
|
||||||
|
|
||||||
<meta name="lang:search.result.none" content="No matching documents">
|
|
||||||
|
|
||||||
<meta name="lang:search.result.one" content="1 matching document">
|
|
||||||
|
|
||||||
<meta name="lang:search.result.other" content="# matching documents">
|
|
||||||
|
|
||||||
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
|
||||||
|
|
||||||
<link rel="shortcut icon" href="/assets/images/favicon.png">
|
|
||||||
<meta name="generator" content="mkdocs-1.0.4, mkdocs-material-4.6.0">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<title>Yq</title>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="/assets/stylesheets/application.1b62728e.css">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="/assets/javascripts/modernizr.268332fc.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
|
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&display=fallback">
|
|
||||||
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="/assets/fonts/material-icons.css">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body dir="ltr">
|
|
||||||
|
|
||||||
<svg class="md-svg">
|
|
||||||
<defs>
|
|
||||||
|
|
||||||
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="__github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
|
||||||
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
|
|
||||||
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
|
|
||||||
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
|
|
||||||
|
|
||||||
|
|
||||||
<header class="md-header" data-md-component="header">
|
|
||||||
<nav class="md-header-nav md-grid">
|
|
||||||
<div class="md-flex">
|
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<a href="/." title="Yq" class="md-header-nav__button md-logo">
|
|
||||||
|
|
||||||
<i class="md-icon"></i>
|
|
||||||
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
|
|
||||||
</div>
|
|
||||||
<div class="md-flex__cell md-flex__cell--stretch">
|
|
||||||
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
|
|
||||||
|
|
||||||
<span class="md-header-nav__topic">
|
|
||||||
Yq
|
|
||||||
</span>
|
|
||||||
<span class="md-header-nav__topic">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</span>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
|
|
||||||
<label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
|
|
||||||
|
|
||||||
<div class="md-search" data-md-component="search" role="dialog">
|
|
||||||
<label class="md-search__overlay" for="__search"></label>
|
|
||||||
<div class="md-search__inner" role="search">
|
|
||||||
<form class="md-search__form" name="search">
|
|
||||||
<input type="text" class="md-search__input" name="query" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query" data-md-state="active">
|
|
||||||
<label class="md-icon md-search__icon" for="__search"></label>
|
|
||||||
<button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">
|
|
||||||

|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
<div class="md-search__output">
|
|
||||||
<div class="md-search__scrollwrap" data-md-scrollfix>
|
|
||||||
<div class="md-search-result" data-md-component="result">
|
|
||||||
<div class="md-search-result__meta">
|
|
||||||
Type to start searching
|
|
||||||
</div>
|
|
||||||
<ol class="md-search-result__list"></ol>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<div class="md-header-nav__source">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
|
||||||
|
|
||||||
<div class="md-source__icon">
|
|
||||||
<svg viewBox="0 0 24 24" width="24" height="24">
|
|
||||||
<use xlink:href="#__github" width="24" height="24"></use>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="md-source__repository">
|
|
||||||
mikefarah/yq
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="md-container">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<main class="md-main" role="main">
|
|
||||||
<div class="md-main__inner md-grid" data-md-component="container">
|
|
||||||
|
|
||||||
|
|
||||||
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
|
|
||||||
<div class="md-sidebar__scrollwrap">
|
|
||||||
<div class="md-sidebar__inner">
|
|
||||||
<nav class="md-nav md-nav--primary" data-md-level="0">
|
|
||||||
<label class="md-nav__title md-nav__title--site" for="__drawer">
|
|
||||||
<a href="/." title="Yq" class="md-nav__button md-logo">
|
|
||||||
|
|
||||||
<i class="md-icon"></i>
|
|
||||||
|
|
||||||
</a>
|
|
||||||
Yq
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div class="md-nav__source">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
|
||||||
|
|
||||||
<div class="md-source__icon">
|
|
||||||
<svg viewBox="0 0 24 24" width="24" height="24">
|
|
||||||
<use xlink:href="#__github" width="24" height="24"></use>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="md-source__repository">
|
|
||||||
mikefarah/yq
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ul class="md-nav__list" data-md-scrollfix>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<li class="md-nav__item">
|
|
||||||
<a href="/." title="Home" class="md-nav__link">
|
|
||||||
Home
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="md-content">
|
|
||||||
<article class="md-content__inner md-typeset">
|
|
||||||
|
|
||||||
<h1>404 - Not found</h1>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
|
|
||||||
<footer class="md-footer">
|
|
||||||
|
|
||||||
<div class="md-footer-meta md-typeset">
|
|
||||||
<div class="md-footer-meta__inner md-grid">
|
|
||||||
<div class="md-footer-copyright">
|
|
||||||
|
|
||||||
powered by
|
|
||||||
<a href="https://www.mkdocs.org">MkDocs</a>
|
|
||||||
and
|
|
||||||
<a href="https://squidfunk.github.io/mkdocs-material/">
|
|
||||||
Material for MkDocs</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="/assets/javascripts/application.808e90bb.js"></script>
|
|
||||||
|
|
||||||
<script>app.initialize({version:"1.0.4",url:{base:"/"}})</script>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
4
docs/assets/fonts/font-awesome.css
vendored
4
docs/assets/fonts/font-awesome.css
vendored
File diff suppressed because one or more lines are too long
@ -1,13 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
|
||||||
* of the License at:
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE
|
|
||||||
* DISTRIBUTED UNDER THE LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
* SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND
|
|
||||||
* LIMITATIONS UNDER THE LICENSE.
|
|
||||||
*/@font-face{font-family:"Material Icons";font-style:normal;font-weight:400;src:local("Material Icons"),local("MaterialIcons-Regular"),url("specimen/MaterialIcons-Regular.woff2") format("woff2"),url("specimen/MaterialIcons-Regular.woff") format("woff"),url("specimen/MaterialIcons-Regular.ttf") format("truetype")}
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 521 B |
@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="352" height="448" viewBox="0 0 352 448" id="__bitbucket"><path fill="currentColor" d="M203.75 214.75q2 15.75-12.625 25.25t-27.875 1.5q-9.75-4.25-13.375-14.5t-.125-20.5 13-14.5q9-4.5 18.125-3t16 8.875 6.875 16.875zm27.75-5.25q-3.5-26.75-28.25-41T154 165.25q-15.75 7-25.125 22.125t-8.625 32.375q1 22.75 19.375 38.75t41.375 14q22.75-2 38-21t12.5-42zM291.25 74q-5-6.75-14-11.125t-14.5-5.5T245 54.25q-72.75-11.75-141.5.5-10.75 1.75-16.5 3t-13.75 5.5T60.75 74q7.5 7 19 11.375t18.375 5.5T120 93.75Q177 101 232 94q15.75-2 22.375-3t18.125-5.375T291.25 74zm14.25 258.75q-2 6.5-3.875 19.125t-3.5 21-7.125 17.5-14.5 14.125q-21.5 12-47.375 17.875t-50.5 5.5-50.375-4.625q-11.5-2-20.375-4.5T88.75 412 70.5 401.125t-13-15.375q-6.25-24-14.25-73l1.5-4 4.5-2.25q55.75 37 126.625 37t126.875-37q5.25 1.5 6 5.75t-1.25 11.25-2 9.25zM350.75 92.5q-6.5 41.75-27.75 163.75-1.25 7.5-6.75 14t-10.875 10T291.75 288q-63 31.5-152.5 22-62-6.75-98.5-34.75-3.75-3-6.375-6.625t-4.25-8.75-2.25-8.5-1.5-9.875T25 232.75q-2.25-12.5-6.625-37.5t-7-40.375T5.5 118 0 78.5Q.75 72 4.375 66.375T12.25 57t11.25-7.5T35 43.875t12-4.625q31.25-11.5 78.25-16 94.75-9.25 169 12.5Q333 47.25 348 66.25q4 5 4.125 12.75t-1.375 13.5z"/></svg>
|
|
Before Width: | Height: | Size: 1.2 KiB |
@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="__github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
|
Before Width: | Height: | Size: 993 B |
@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" viewBox="0 0 500 500" id="__gitlab"><path fill="currentColor" d="M93.667 473.347l90.684-279.097H2.983l90.684 279.097z" transform="translate(156.198 1.16)"/><path fill="currentColor" d="M221.333 473.345L130.649 194.25H3.557l217.776 279.095z" transform="translate(28.531 1.16)" opacity=".7"/><path fill="currentColor" d="M32 195.155L4.441 279.97a18.773 18.773 0 0 0 6.821 20.99l238.514 173.29L32 195.155z" transform="translate(.089 .256)" opacity=".5"/><path fill="currentColor" d="M2.667-84.844h127.092L75.14-252.942c-2.811-8.649-15.047-8.649-17.856 0L2.667-84.844z" transform="translate(29.422 280.256)"/><path fill="currentColor" d="M2.667 473.345L93.351 194.25h127.092L2.667 473.345z" transform="translate(247.198 1.16)" opacity=".7"/><path fill="currentColor" d="M221.334 195.155l27.559 84.815a18.772 18.772 0 0 1-6.821 20.99L3.557 474.25l217.777-279.095z" transform="translate(246.307 .256)" opacity=".5"/><path fill="currentColor" d="M130.667-84.844H3.575l54.618-168.098c2.811-8.649 15.047-8.649 17.856 0l54.618 168.098z" transform="translate(336.974 280.256)"/></svg>
|
|
Before Width: | Height: | Size: 1.1 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,17 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Lunr languages, `Danish` language
|
|
||||||
* https://github.com/MihaiValentin/lunr-languages
|
|
||||||
*
|
|
||||||
* Copyright 2014, Mihai Valentin
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
/*!
|
|
||||||
* based on
|
|
||||||
* Snowball JavaScript Library v0.3
|
|
||||||
* http://code.google.com/p/urim/
|
|
||||||
* http://snowball.tartarus.org/
|
|
||||||
*
|
|
||||||
* Copyright 2010, Oleg Mazko
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var r,m,i;e.da=function(){this.pipeline.reset(),this.pipeline.add(e.da.trimmer,e.da.stopWordFilter,e.da.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.da.stemmer))},e.da.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.da.trimmer=e.trimmerSupport.generateTrimmer(e.da.wordCharacters),e.Pipeline.registerFunction(e.da.trimmer,"trimmer-da"),e.da.stemmer=(r=e.stemmerSupport.Among,m=e.stemmerSupport.SnowballProgram,i=new function(){var i,t,n,s=[new r("hed",-1,1),new r("ethed",0,1),new r("ered",-1,1),new r("e",-1,1),new r("erede",3,1),new r("ende",3,1),new r("erende",5,1),new r("ene",3,1),new r("erne",3,1),new r("ere",3,1),new r("en",-1,1),new r("heden",10,1),new r("eren",10,1),new r("er",-1,1),new r("heder",13,1),new r("erer",13,1),new r("s",-1,2),new r("heds",16,1),new r("es",16,1),new r("endes",18,1),new r("erendes",19,1),new r("enes",18,1),new r("ernes",18,1),new r("eres",18,1),new r("ens",16,1),new r("hedens",24,1),new r("erens",24,1),new r("ers",16,1),new r("ets",16,1),new r("erets",28,1),new r("et",-1,1),new r("eret",30,1)],o=[new r("gd",-1,-1),new r("dt",-1,-1),new r("gt",-1,-1),new r("kt",-1,-1)],a=[new r("ig",-1,1),new r("lig",0,1),new r("elig",1,1),new r("els",-1,1),new r("løst",-1,2)],d=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],u=[239,254,42,3,0,0,0,0,0,0,0,0,0,0,0,0,16],c=new m;function l(){var e,r=c.limit-c.cursor;c.cursor>=t&&(e=c.limit_backward,c.limit_backward=t,c.ket=c.cursor,c.find_among_b(o,4)?(c.bra=c.cursor,c.limit_backward=e,c.cursor=c.limit-r,c.cursor>c.limit_backward&&(c.cursor--,c.bra=c.cursor,c.slice_del())):c.limit_backward=e)}this.setCurrent=function(e){c.setCurrent(e)},this.getCurrent=function(){return c.getCurrent()},this.stem=function(){var e,r=c.cursor;return function(){var e,r=c.cursor+3;if(t=c.limit,0<=r&&r<=c.limit){for(i=r;;){if(e=c.cursor,c.in_grouping(d,97,248)){c.cursor=e;break}if((c.cursor=e)>=c.limit)return;c.cursor++}for(;!c.out_grouping(d,97,248);){if(c.cursor>=c.limit)return;c.cursor++}(t=c.cursor)<i&&(t=i)}}(),c.limit_backward=r,c.cursor=c.limit,function(){var e,r;if(c.cursor>=t&&(r=c.limit_backward,c.limit_backward=t,c.ket=c.cursor,e=c.find_among_b(s,32),c.limit_backward=r,e))switch(c.bra=c.cursor,e){case 1:c.slice_del();break;case 2:c.in_grouping_b(u,97,229)&&c.slice_del()}}(),c.cursor=c.limit,l(),c.cursor=c.limit,function(){var e,r,i,n=c.limit-c.cursor;if(c.ket=c.cursor,c.eq_s_b(2,"st")&&(c.bra=c.cursor,c.eq_s_b(2,"ig")&&c.slice_del()),c.cursor=c.limit-n,c.cursor>=t&&(r=c.limit_backward,c.limit_backward=t,c.ket=c.cursor,e=c.find_among_b(a,5),c.limit_backward=r,e))switch(c.bra=c.cursor,e){case 1:c.slice_del(),i=c.limit-c.cursor,l(),c.cursor=c.limit-i;break;case 2:c.slice_from("løs")}}(),c.cursor=c.limit,c.cursor>=t&&(e=c.limit_backward,c.limit_backward=t,c.ket=c.cursor,c.out_grouping_b(d,97,248)?(c.bra=c.cursor,n=c.slice_to(n),c.limit_backward=e,c.eq_v_b(n)&&c.slice_del()):c.limit_backward=e),!0}},function(e){return"function"==typeof e.update?e.update(function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}):(i.setCurrent(e),i.stem(),i.getCurrent())}),e.Pipeline.registerFunction(e.da.stemmer,"stemmer-da"),e.da.stopWordFilter=e.generateStopWordFilter("ad af alle alt anden at blev blive bliver da de dem den denne der deres det dette dig din disse dog du efter eller en end er et for fra ham han hans har havde have hende hendes her hos hun hvad hvis hvor i ikke ind jeg jer jo kunne man mange med meget men mig min mine mit mod ned noget nogle nu når og også om op os over på selv sig sin sine sit skal skulle som sådan thi til ud under var vi vil ville vor være været".split(" ")),e.Pipeline.registerFunction(e.da.stopWordFilter,"stopWordFilter-da")}});
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,17 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Lunr languages, `Japanese` language
|
|
||||||
* https://github.com/MihaiValentin/lunr-languages
|
|
||||||
*
|
|
||||||
* Copyright 2014, Chad Liu
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
/*!
|
|
||||||
* based on
|
|
||||||
* Snowball JavaScript Library v0.3
|
|
||||||
* http://code.google.com/p/urim/
|
|
||||||
* http://snowball.tartarus.org/
|
|
||||||
*
|
|
||||||
* Copyright 2010, Oleg Mazko
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(m){if(void 0===m)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===m.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var l="2"==m.version[0];m.ja=function(){this.pipeline.reset(),this.pipeline.add(m.ja.trimmer,m.ja.stopWordFilter,m.ja.stemmer),l?this.tokenizer=m.ja.tokenizer:(m.tokenizer&&(m.tokenizer=m.ja.tokenizer),this.tokenizerFn&&(this.tokenizerFn=m.ja.tokenizer))};var j=new m.TinySegmenter;m.ja.tokenizer=function(e){var r,t,i,n,o,s,p,a,u;if(!arguments.length||null==e||null==e)return[];if(Array.isArray(e))return e.map(function(e){return l?new m.Token(e.toLowerCase()):e.toLowerCase()});for(r=(t=e.toString().toLowerCase().replace(/^\s+/,"")).length-1;0<=r;r--)if(/\S/.test(t.charAt(r))){t=t.substring(0,r+1);break}for(o=[],i=t.length,p=a=0;a<=i;a++)if(s=a-p,t.charAt(a).match(/\s/)||a==i){if(0<s)for(n=j.segment(t.slice(p,a)).filter(function(e){return!!e}),u=p,r=0;r<n.length;r++)l?o.push(new m.Token(n[r],{position:[u,n[r].length],index:o.length})):o.push(n[r]),u+=n[r].length;p=a+1}return o},m.ja.stemmer=function(e){return e},m.Pipeline.registerFunction(m.ja.stemmer,"stemmer-ja"),m.ja.wordCharacters="一二三四五六七八九十百千万億兆一-龠々〆ヵヶぁ-んァ-ヴーア-ン゙a-zA-Za-zA-Z0-90-9",m.ja.trimmer=m.trimmerSupport.generateTrimmer(m.ja.wordCharacters),m.Pipeline.registerFunction(m.ja.trimmer,"trimmer-ja"),m.ja.stopWordFilter=m.generateStopWordFilter("これ それ あれ この その あの ここ そこ あそこ こちら どこ だれ なに なん 何 私 貴方 貴方方 我々 私達 あの人 あのかた 彼女 彼 です あります おります います は が の に を で え から まで より も どの と し それで しかし".split(" ")),m.Pipeline.registerFunction(m.ja.stopWordFilter,"stopWordFilter-ja"),m.jp=m.ja,m.Pipeline.registerFunction(m.jp.stemmer,"stemmer-jp"),m.Pipeline.registerFunction(m.jp.trimmer,"trimmer-jp"),m.Pipeline.registerFunction(m.jp.stopWordFilter,"stopWordFilter-jp")}});
|
|
@ -1 +0,0 @@
|
|||||||
module.exports=require("./lunr.ja");
|
|
@ -1 +0,0 @@
|
|||||||
!function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():t()(e.lunr)}(this,function(){return function(o){o.multiLanguage=function(){for(var e=Array.prototype.slice.call(arguments),t=e.join("-"),i="",r=[],n=[],s=0;s<e.length;++s)"en"==e[s]?(i+="\\w",r.unshift(o.stopWordFilter),r.push(o.stemmer),n.push(o.stemmer)):(i+=o[e[s]].wordCharacters,o[e[s]].stopWordFilter&&r.unshift(o[e[s]].stopWordFilter),o[e[s]].stemmer&&(r.push(o[e[s]].stemmer),n.push(o[e[s]].stemmer)));var p=o.trimmerSupport.generateTrimmer(i);return o.Pipeline.registerFunction(p,"lunr-multi-trimmer-"+t),r.unshift(p),function(){this.pipeline.reset(),this.pipeline.add.apply(this.pipeline,r),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add.apply(this.searchPipeline,n))}}}});
|
|
File diff suppressed because one or more lines are too long
@ -1,17 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Lunr languages, `Norwegian` language
|
|
||||||
* https://github.com/MihaiValentin/lunr-languages
|
|
||||||
*
|
|
||||||
* Copyright 2014, Mihai Valentin
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
/*!
|
|
||||||
* based on
|
|
||||||
* Snowball JavaScript Library v0.3
|
|
||||||
* http://code.google.com/p/urim/
|
|
||||||
* http://snowball.tartarus.org/
|
|
||||||
*
|
|
||||||
* Copyright 2010, Oleg Mazko
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var r,n,i;e.no=function(){this.pipeline.reset(),this.pipeline.add(e.no.trimmer,e.no.stopWordFilter,e.no.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.no.stemmer))},e.no.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.no.trimmer=e.trimmerSupport.generateTrimmer(e.no.wordCharacters),e.Pipeline.registerFunction(e.no.trimmer,"trimmer-no"),e.no.stemmer=(r=e.stemmerSupport.Among,n=e.stemmerSupport.SnowballProgram,i=new function(){var o,s,a=[new r("a",-1,1),new r("e",-1,1),new r("ede",1,1),new r("ande",1,1),new r("ende",1,1),new r("ane",1,1),new r("ene",1,1),new r("hetene",6,1),new r("erte",1,3),new r("en",-1,1),new r("heten",9,1),new r("ar",-1,1),new r("er",-1,1),new r("heter",12,1),new r("s",-1,2),new r("as",14,1),new r("es",14,1),new r("edes",16,1),new r("endes",16,1),new r("enes",16,1),new r("hetenes",19,1),new r("ens",14,1),new r("hetens",21,1),new r("ers",14,1),new r("ets",14,1),new r("et",-1,1),new r("het",25,1),new r("ert",-1,3),new r("ast",-1,1)],m=[new r("dt",-1,-1),new r("vt",-1,-1)],l=[new r("leg",-1,1),new r("eleg",0,1),new r("ig",-1,1),new r("eig",2,1),new r("lig",2,1),new r("elig",4,1),new r("els",-1,1),new r("lov",-1,1),new r("elov",7,1),new r("slov",7,1),new r("hetslov",9,1)],u=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],d=[119,125,149,1],c=new n;this.setCurrent=function(e){c.setCurrent(e)},this.getCurrent=function(){return c.getCurrent()},this.stem=function(){var e,r,n,i,t=c.cursor;return function(){var e,r=c.cursor+3;if(s=c.limit,0<=r||r<=c.limit){for(o=r;;){if(e=c.cursor,c.in_grouping(u,97,248)){c.cursor=e;break}if(e>=c.limit)return;c.cursor=e+1}for(;!c.out_grouping(u,97,248);){if(c.cursor>=c.limit)return;c.cursor++}(s=c.cursor)<o&&(s=o)}}(),c.limit_backward=t,c.cursor=c.limit,function(){var e,r,n;if(c.cursor>=s&&(r=c.limit_backward,c.limit_backward=s,c.ket=c.cursor,e=c.find_among_b(a,29),c.limit_backward=r,e))switch(c.bra=c.cursor,e){case 1:c.slice_del();break;case 2:n=c.limit-c.cursor,c.in_grouping_b(d,98,122)?c.slice_del():(c.cursor=c.limit-n,c.eq_s_b(1,"k")&&c.out_grouping_b(u,97,248)&&c.slice_del());break;case 3:c.slice_from("er")}}(),c.cursor=c.limit,r=c.limit-c.cursor,c.cursor>=s&&(e=c.limit_backward,c.limit_backward=s,c.ket=c.cursor,c.find_among_b(m,2)?(c.bra=c.cursor,c.limit_backward=e,c.cursor=c.limit-r,c.cursor>c.limit_backward&&(c.cursor--,c.bra=c.cursor,c.slice_del())):c.limit_backward=e),c.cursor=c.limit,c.cursor>=s&&(i=c.limit_backward,c.limit_backward=s,c.ket=c.cursor,(n=c.find_among_b(l,11))?(c.bra=c.cursor,c.limit_backward=i,1==n&&c.slice_del()):c.limit_backward=i),!0}},function(e){return"function"==typeof e.update?e.update(function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}):(i.setCurrent(e),i.stem(),i.getCurrent())}),e.Pipeline.registerFunction(e.no.stemmer,"stemmer-no"),e.no.stopWordFilter=e.generateStopWordFilter("alle at av bare begge ble blei bli blir blitt både båe da de deg dei deim deira deires dem den denne der dere deres det dette di din disse ditt du dykk dykkar då eg ein eit eitt eller elles en enn er et ett etter for fordi fra før ha hadde han hans har hennar henne hennes her hjå ho hoe honom hoss hossen hun hva hvem hver hvilke hvilken hvis hvor hvordan hvorfor i ikke ikkje ikkje ingen ingi inkje inn inni ja jeg kan kom korleis korso kun kunne kva kvar kvarhelst kven kvi kvifor man mange me med medan meg meget mellom men mi min mine mitt mot mykje ned no noe noen noka noko nokon nokor nokre nå når og også om opp oss over på samme seg selv si si sia sidan siden sin sine sitt sjøl skal skulle slik so som som somme somt så sånn til um upp ut uten var vart varte ved vere verte vi vil ville vore vors vort vår være være vært å".split(" ")),e.Pipeline.registerFunction(e.no.stopWordFilter,"stopWordFilter-no")}});
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,9 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Snowball JavaScript Library v0.3
|
|
||||||
* http://code.google.com/p/urim/
|
|
||||||
* http://snowball.tartarus.org/
|
|
||||||
*
|
|
||||||
* Copyright 2010, Oleg Mazko
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
!function(r,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():t()(r.lunr)}(this,function(){return function(r){r.stemmerSupport={Among:function(r,t,i,s){if(this.toCharArray=function(r){for(var t=r.length,i=new Array(t),s=0;s<t;s++)i[s]=r.charCodeAt(s);return i},!r&&""!=r||!t&&0!=t||!i)throw"Bad Among initialisation: s:"+r+", substring_i: "+t+", result: "+i;this.s_size=r.length,this.s=this.toCharArray(r),this.substring_i=t,this.result=i,this.method=s},SnowballProgram:function(){var b;return{bra:0,ket:0,limit:0,cursor:0,limit_backward:0,setCurrent:function(r){b=r,this.cursor=0,this.limit=r.length,this.limit_backward=0,this.bra=this.cursor,this.ket=this.limit},getCurrent:function(){var r=b;return b=null,r},in_grouping:function(r,t,i){if(this.cursor<this.limit){var s=b.charCodeAt(this.cursor);if(s<=i&&t<=s&&r[(s-=t)>>3]&1<<(7&s))return this.cursor++,!0}return!1},in_grouping_b:function(r,t,i){if(this.cursor>this.limit_backward){var s=b.charCodeAt(this.cursor-1);if(s<=i&&t<=s&&r[(s-=t)>>3]&1<<(7&s))return this.cursor--,!0}return!1},out_grouping:function(r,t,i){if(this.cursor<this.limit){var s=b.charCodeAt(this.cursor);if(i<s||s<t)return this.cursor++,!0;if(!(r[(s-=t)>>3]&1<<(7&s)))return this.cursor++,!0}return!1},out_grouping_b:function(r,t,i){if(this.cursor>this.limit_backward){var s=b.charCodeAt(this.cursor-1);if(i<s||s<t)return this.cursor--,!0;if(!(r[(s-=t)>>3]&1<<(7&s)))return this.cursor--,!0}return!1},eq_s:function(r,t){if(this.limit-this.cursor<r)return!1;for(var i=0;i<r;i++)if(b.charCodeAt(this.cursor+i)!=t.charCodeAt(i))return!1;return this.cursor+=r,!0},eq_s_b:function(r,t){if(this.cursor-this.limit_backward<r)return!1;for(var i=0;i<r;i++)if(b.charCodeAt(this.cursor-r+i)!=t.charCodeAt(i))return!1;return this.cursor-=r,!0},find_among:function(r,t){for(var i=0,s=t,e=this.cursor,n=this.limit,u=0,o=0,h=!1;;){for(var c=i+(s-i>>1),a=0,f=u<o?u:o,l=r[c],_=f;_<l.s_size;_++){if(e+f==n){a=-1;break}if(a=b.charCodeAt(e+f)-l.s[_])break;f++}if(a<0?(s=c,o=f):(i=c,u=f),s-i<=1){if(0<i||s==i||h)break;h=!0}}for(;;){if(u>=(l=r[i]).s_size){if(this.cursor=e+l.s_size,!l.method)return l.result;var m=l.method();if(this.cursor=e+l.s_size,m)return l.result}if((i=l.substring_i)<0)return 0}},find_among_b:function(r,t){for(var i=0,s=t,e=this.cursor,n=this.limit_backward,u=0,o=0,h=!1;;){for(var c=i+(s-i>>1),a=0,f=u<o?u:o,l=(_=r[c]).s_size-1-f;0<=l;l--){if(e-f==n){a=-1;break}if(a=b.charCodeAt(e-1-f)-_.s[l])break;f++}if(a<0?(s=c,o=f):(i=c,u=f),s-i<=1){if(0<i||s==i||h)break;h=!0}}for(;;){var _;if(u>=(_=r[i]).s_size){if(this.cursor=e-_.s_size,!_.method)return _.result;var m=_.method();if(this.cursor=e-_.s_size,m)return _.result}if((i=_.substring_i)<0)return 0}},replace_s:function(r,t,i){var s=i.length-(t-r);return b=b.substring(0,r)+i+b.substring(t),this.limit+=s,this.cursor>=t?this.cursor+=s:this.cursor>r&&(this.cursor=r),s},slice_check:function(){if(this.bra<0||this.bra>this.ket||this.ket>this.limit||this.limit>b.length)throw"faulty slice operation"},slice_from:function(r){this.slice_check(),this.replace_s(this.bra,this.ket,r)},slice_del:function(){this.slice_from("")},insert:function(r,t,i){var s=this.replace_s(r,t,i);r<=this.bra&&(this.bra+=s),r<=this.ket&&(this.ket+=s)},slice_to:function(){return this.slice_check(),b.substring(this.bra,this.ket)},eq_v_b:function(r){return this.eq_s_b(r.length,r)}}}},r.trimmerSupport={generateTrimmer:function(r){var t=new RegExp("^[^"+r+"]+"),i=new RegExp("[^"+r+"]+$");return function(r){return"function"==typeof r.update?r.update(function(r){return r.replace(t,"").replace(i,"")}):r.replace(t,"").replace(i,"")}}}}});
|
|
@ -1,17 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Lunr languages, `Swedish` language
|
|
||||||
* https://github.com/MihaiValentin/lunr-languages
|
|
||||||
*
|
|
||||||
* Copyright 2014, Mihai Valentin
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
/*!
|
|
||||||
* based on
|
|
||||||
* Snowball JavaScript Library v0.3
|
|
||||||
* http://code.google.com/p/urim/
|
|
||||||
* http://snowball.tartarus.org/
|
|
||||||
*
|
|
||||||
* Copyright 2010, Oleg Mazko
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var r,l,n;e.sv=function(){this.pipeline.reset(),this.pipeline.add(e.sv.trimmer,e.sv.stopWordFilter,e.sv.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.sv.stemmer))},e.sv.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.sv.trimmer=e.trimmerSupport.generateTrimmer(e.sv.wordCharacters),e.Pipeline.registerFunction(e.sv.trimmer,"trimmer-sv"),e.sv.stemmer=(r=e.stemmerSupport.Among,l=e.stemmerSupport.SnowballProgram,n=new function(){var n,t,i=[new r("a",-1,1),new r("arna",0,1),new r("erna",0,1),new r("heterna",2,1),new r("orna",0,1),new r("ad",-1,1),new r("e",-1,1),new r("ade",6,1),new r("ande",6,1),new r("arne",6,1),new r("are",6,1),new r("aste",6,1),new r("en",-1,1),new r("anden",12,1),new r("aren",12,1),new r("heten",12,1),new r("ern",-1,1),new r("ar",-1,1),new r("er",-1,1),new r("heter",18,1),new r("or",-1,1),new r("s",-1,2),new r("as",21,1),new r("arnas",22,1),new r("ernas",22,1),new r("ornas",22,1),new r("es",21,1),new r("ades",26,1),new r("andes",26,1),new r("ens",21,1),new r("arens",29,1),new r("hetens",29,1),new r("erns",21,1),new r("at",-1,1),new r("andet",-1,1),new r("het",-1,1),new r("ast",-1,1)],s=[new r("dd",-1,-1),new r("gd",-1,-1),new r("nn",-1,-1),new r("dt",-1,-1),new r("gt",-1,-1),new r("kt",-1,-1),new r("tt",-1,-1)],a=[new r("ig",-1,1),new r("lig",0,1),new r("els",-1,1),new r("fullt",-1,3),new r("löst",-1,2)],o=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,24,0,32],u=[119,127,149],m=new l;this.setCurrent=function(e){m.setCurrent(e)},this.getCurrent=function(){return m.getCurrent()},this.stem=function(){var e,r=m.cursor;return function(){var e,r=m.cursor+3;if(t=m.limit,0<=r||r<=m.limit){for(n=r;;){if(e=m.cursor,m.in_grouping(o,97,246)){m.cursor=e;break}if(m.cursor=e,m.cursor>=m.limit)return;m.cursor++}for(;!m.out_grouping(o,97,246);){if(m.cursor>=m.limit)return;m.cursor++}(t=m.cursor)<n&&(t=n)}}(),m.limit_backward=r,m.cursor=m.limit,function(){var e,r=m.limit_backward;if(m.cursor>=t&&(m.limit_backward=t,m.cursor=m.limit,m.ket=m.cursor,e=m.find_among_b(i,37),m.limit_backward=r,e))switch(m.bra=m.cursor,e){case 1:m.slice_del();break;case 2:m.in_grouping_b(u,98,121)&&m.slice_del()}}(),m.cursor=m.limit,e=m.limit_backward,m.cursor>=t&&(m.limit_backward=t,m.cursor=m.limit,m.find_among_b(s,7)&&(m.cursor=m.limit,m.ket=m.cursor,m.cursor>m.limit_backward&&(m.bra=--m.cursor,m.slice_del())),m.limit_backward=e),m.cursor=m.limit,function(){var e,r;if(m.cursor>=t){if(r=m.limit_backward,m.limit_backward=t,m.cursor=m.limit,m.ket=m.cursor,e=m.find_among_b(a,5))switch(m.bra=m.cursor,e){case 1:m.slice_del();break;case 2:m.slice_from("lös");break;case 3:m.slice_from("full")}m.limit_backward=r}}(),!0}},function(e){return"function"==typeof e.update?e.update(function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}):(n.setCurrent(e),n.stem(),n.getCurrent())}),e.Pipeline.registerFunction(e.sv.stemmer,"stemmer-sv"),e.sv.stopWordFilter=e.generateStopWordFilter("alla allt att av blev bli blir blivit de dem den denna deras dess dessa det detta dig din dina ditt du där då efter ej eller en er era ert ett från för ha hade han hans har henne hennes hon honom hur här i icke ingen inom inte jag ju kan kunde man med mellan men mig min mina mitt mot mycket ni nu när någon något några och om oss på samma sedan sig sin sina sitta själv skulle som så sådan sådana sådant till under upp ut utan vad var vara varför varit varje vars vart vem vi vid vilka vilkas vilken vilket vår våra vårt än är åt över".split(" ")),e.Pipeline.registerFunction(e.sv.stopWordFilter,"stopWordFilter-sv")}});
|
|
@ -1,17 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Lunr languages, `Thai` language
|
|
||||||
* https://github.com/MihaiValentin/lunr-languages
|
|
||||||
*
|
|
||||||
* Copyright 2017, Keerati Thiwanruk
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
/*!
|
|
||||||
* based on
|
|
||||||
* Snowball JavaScript Library v0.3
|
|
||||||
* http://code.google.com/p/urim/
|
|
||||||
* http://snowball.tartarus.org/
|
|
||||||
*
|
|
||||||
* Copyright 2010, Oleg Mazko
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(t){if(void 0===t)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===t.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var i="2"==t.version[0];t.th=function(){this.pipeline.reset(),this.pipeline.add(t.th.trimmer),i?this.tokenizer=t.th.tokenizer:(t.tokenizer&&(t.tokenizer=t.th.tokenizer),this.tokenizerFn&&(this.tokenizerFn=t.th.tokenizer))},t.th.wordCharacters="[-]",t.th.trimmer=t.trimmerSupport.generateTrimmer(t.th.wordCharacters),t.Pipeline.registerFunction(t.th.trimmer,"trimmer-th");var n=t.wordcut;n.init(),t.th.tokenizer=function(e){if(!arguments.length||null==e||null==e)return[];if(Array.isArray(e))return e.map(function(e){return i?new t.Token(e):e});var r=e.toString().replace(/^\s+/,"");return n.cut(r).split("|")}}});
|
|
File diff suppressed because one or more lines are too long
@ -1,17 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Lunr languages, `Vietnamese` language
|
|
||||||
* https://github.com/MihaiValentin/lunr-languages
|
|
||||||
*
|
|
||||||
* Copyright 2017, Keerati Thiwanruk
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
/*!
|
|
||||||
* based on
|
|
||||||
* Snowball JavaScript Library v0.3
|
|
||||||
* http://code.google.com/p/urim/
|
|
||||||
* http://snowball.tartarus.org/
|
|
||||||
*
|
|
||||||
* Copyright 2010, Oleg Mazko
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*/
|
|
||||||
!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.vi=function(){this.pipeline.reset(),this.pipeline.add(e.vi.stopWordFilter,e.vi.trimmer)},e.vi.wordCharacters="[A-Za-ẓ̀͐́͑̉̃̓ÂâÊêÔôĂ-ăĐ-đƠ-ơƯ-ư]",e.vi.trimmer=e.trimmerSupport.generateTrimmer(e.vi.wordCharacters),e.Pipeline.registerFunction(e.vi.trimmer,"trimmer-vi"),e.vi.stopWordFilter=e.generateStopWordFilter("là cái nhưng mà".split(" "))}});
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
202
docs/index.html
202
docs/index.html
@ -1,202 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en" class="no-js">
|
|
||||||
<head>
|
|
||||||
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
||||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<meta name="lang:clipboard.copy" content="Copy to clipboard">
|
|
||||||
|
|
||||||
<meta name="lang:clipboard.copied" content="Copied to clipboard">
|
|
||||||
|
|
||||||
<meta name="lang:search.language" content="en">
|
|
||||||
|
|
||||||
<meta name="lang:search.pipeline.stopwords" content="True">
|
|
||||||
|
|
||||||
<meta name="lang:search.pipeline.trimmer" content="True">
|
|
||||||
|
|
||||||
<meta name="lang:search.result.none" content="No matching documents">
|
|
||||||
|
|
||||||
<meta name="lang:search.result.one" content="1 matching document">
|
|
||||||
|
|
||||||
<meta name="lang:search.result.other" content="# matching documents">
|
|
||||||
|
|
||||||
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
|
||||||
|
|
||||||
<link rel="shortcut icon" href="assets/images/favicon.png">
|
|
||||||
<meta name="generator" content="mkdocs-1.0.4, mkdocs-material-4.6.0">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<title>Yq</title>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="assets/stylesheets/application.1b62728e.css">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="assets/javascripts/modernizr.268332fc.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
|
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&display=fallback">
|
|
||||||
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="assets/fonts/material-icons.css">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body dir="ltr">
|
|
||||||
|
|
||||||
<svg class="md-svg">
|
|
||||||
<defs>
|
|
||||||
|
|
||||||
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="__github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
|
|
||||||
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
|
|
||||||
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
|
|
||||||
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
|
|
||||||
|
|
||||||
<a href="#new-documentation-website" tabindex="1" class="md-skip">
|
|
||||||
Skip to content
|
|
||||||
</a>
|
|
||||||
|
|
||||||
|
|
||||||
<header class="md-header" data-md-component="header">
|
|
||||||
<nav class="md-header-nav md-grid">
|
|
||||||
<div class="md-flex">
|
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<a href="." title="Yq" class="md-header-nav__button md-logo">
|
|
||||||
|
|
||||||
<i class="md-icon"></i>
|
|
||||||
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
|
|
||||||
</div>
|
|
||||||
<div class="md-flex__cell md-flex__cell--stretch">
|
|
||||||
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
|
|
||||||
|
|
||||||
<span class="md-header-nav__topic">
|
|
||||||
Yq
|
|
||||||
</span>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
|
|
||||||
<label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="md-flex__cell md-flex__cell--shrink">
|
|
||||||
<div class="md-header-nav__source">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/mikefarah/yq/" title="Go to repository" class="md-source" data-md-source="github">
|
|
||||||
|
|
||||||
<div class="md-source__icon">
|
|
||||||
<svg viewBox="0 0 24 24" width="24" height="24">
|
|
||||||
<use xlink:href="#__github" width="24" height="24"></use>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="md-source__repository">
|
|
||||||
mikefarah/yq
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="md-container">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<main class="md-main" role="main">
|
|
||||||
<div class="md-main__inner md-grid" data-md-component="container">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="md-content">
|
|
||||||
<article class="md-content__inner md-typeset">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h1>New documentation website</h1>
|
|
||||||
|
|
||||||
<p>User docs are better than ever, and have been <a href="https://mikefarah.gitbook.io/yq">moved here</a></p>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
|
|
||||||
<footer class="md-footer">
|
|
||||||
|
|
||||||
<div class="md-footer-meta md-typeset">
|
|
||||||
<div class="md-footer-meta__inner md-grid">
|
|
||||||
<div class="md-footer-copyright">
|
|
||||||
|
|
||||||
powered by
|
|
||||||
<a href="https://www.mkdocs.org">MkDocs</a>
|
|
||||||
and
|
|
||||||
<a href="https://squidfunk.github.io/mkdocs-material/">
|
|
||||||
Material for MkDocs</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="assets/javascripts/application.808e90bb.js"></script>
|
|
||||||
|
|
||||||
<script>app.initialize({version:"1.0.4",url:{base:"."}})</script>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1 +0,0 @@
|
|||||||
{"config":{"lang":["en"],"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"New documentation website User docs are better than ever, and have been moved here","title":"Home"},{"location":"#new-documentation-website","text":"User docs are better than ever, and have been moved here","title":"New documentation website"}]}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
||||||
<url>
|
|
||||||
<loc>None</loc>
|
|
||||||
<lastmod>2020-01-30</lastmod>
|
|
||||||
<changefreq>daily</changefreq>
|
|
||||||
</url>
|
|
||||||
</urlset>
|
|
Binary file not shown.
@ -1,4 +1,6 @@
|
|||||||
a: simple # just the best
|
a:
|
||||||
b: [1, 2]
|
key1: "value1"
|
||||||
c:
|
key2: 2.6
|
||||||
test: 1
|
ab:
|
||||||
|
key1: 6
|
||||||
|
key2: "h"
|
@ -1,19 +1,19 @@
|
|||||||
foo: &foo
|
foo: &foo
|
||||||
a: original
|
a: foo_a
|
||||||
thing: coolasdf
|
thing: foo_thing
|
||||||
thirsty: yep
|
c: foo_c
|
||||||
|
|
||||||
bar: &bar
|
bar: &bar
|
||||||
b: 2
|
b: bar_b
|
||||||
thing: coconut
|
thing: bar_thing
|
||||||
c: oldbar
|
c: bar_c
|
||||||
|
|
||||||
foobarList:
|
foobarList:
|
||||||
|
b: foobarList_b
|
||||||
<<: [*foo,*bar]
|
<<: [*foo,*bar]
|
||||||
c: newbar
|
c: foobarList_c
|
||||||
|
|
||||||
foobar:
|
foobar:
|
||||||
|
c: foobar_c
|
||||||
<<: *foo
|
<<: *foo
|
||||||
thirty: well beyond
|
thing: foobar_thing
|
||||||
thing: ice
|
|
||||||
c: 3
|
|
@ -1 +1 @@
|
|||||||
{"a":"Easy! as one two three","b":{"c":2,"d":[3,4],"e":[{"name":"fred","value":3},{"name":"sam","value":4}]}}
|
{"a":"Easy! as one two three","b":{"c":2,"d":[3,4],"e":[{"name":"fred","value":3},{"name":"sam","value":4}]},"ab":"must appear last"}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# Some doc
|
||||||
|
|
||||||
a: true
|
a: true
|
||||||
b:
|
b:
|
||||||
c: 2
|
c: 2
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM mikefarah/yq:3
|
FROM mikefarah/yq:4.9.3
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
23
go.mod
23
go.mod
@ -1,17 +1,16 @@
|
|||||||
module github.com/mikefarah/yq/v3
|
module github.com/mikefarah/yq/v4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/fatih/color v1.9.0
|
github.com/elliotchance/orderedmap v1.4.0
|
||||||
github.com/goccy/go-yaml v1.7.5
|
github.com/fatih/color v1.10.0
|
||||||
github.com/kylelemons/godebug v1.1.0
|
github.com/goccy/go-yaml v1.8.9
|
||||||
github.com/mattn/go-colorable v0.1.6 // indirect
|
github.com/jinzhu/copier v0.2.8
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/spf13/cobra v1.1.3
|
||||||
github.com/spf13/cobra v1.0.0
|
github.com/timtadh/data-structures v0.5.3 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/timtadh/lexmachine v0.2.2
|
||||||
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 // indirect
|
golang.org/x/sys v0.0.0-20210317225723-c4fcb01b228e // indirect
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
|
|
||||||
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
|
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||||
)
|
)
|
||||||
|
|
||||||
go 1.14
|
go 1.15
|
||||||
|
240
go.sum
240
go.sum
@ -1,53 +1,112 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||||
|
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||||
|
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||||
|
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||||
|
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||||
|
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||||
|
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||||
|
cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
|
||||||
|
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||||
|
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||||
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||||
|
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||||
|
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||||
|
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||||
|
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
|
||||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||||
|
github.com/elliotchance/orderedmap v1.4.0 h1:wZtfeEONCbx6in1CZyE6bELEt/vFayMvsxqI5SgsR+A=
|
||||||
|
github.com/elliotchance/orderedmap v1.4.0/go.mod h1:wsDwEaX5jEoyhbs7x93zk2H/qv0zwuhg4inXhDkYqys=
|
||||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
|
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
|
||||||
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
|
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
|
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
github.com/go-playground/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/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||||
|
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
github.com/goccy/go-yaml v1.7.5 h1:dWvj+p3BG11S/GlUzwzt1WZz0lhBTzTIDtmXT/ZOaPY=
|
github.com/goccy/go-yaml v1.8.9 h1:4AEXg2qx+/w29jXnXpMY6mTckmYu1TMoHteKuMf0HFg=
|
||||||
github.com/goccy/go-yaml v1.7.5/go.mod h1:wS4gNoLalDSJxo/SpngzPQ2BN4uuZVLCmbM4S3vd4+Y=
|
github.com/goccy/go-yaml v1.8.9/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
|
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||||
|
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||||
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
|
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||||
|
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||||
|
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
|
||||||
|
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||||
|
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||||
|
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||||
|
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||||
|
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||||
|
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||||
|
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||||
|
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||||
|
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
||||||
|
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
|
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
|
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||||
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
|
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
|
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||||
|
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||||
|
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||||
|
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
|
github.com/jinzhu/copier v0.2.8 h1:N8MbL5niMwE3P4dOwurJixz5rMkKfujmMRFmAanSzWE=
|
||||||
|
github.com/jinzhu/copier v0.2.8/go.mod h1:24xnZezI2Yqac9J61UC6/dG/k76ttpq0DdJI3QmUvro=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
|
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||||
|
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
@ -58,30 +117,35 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
|||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
|
||||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
|
||||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
||||||
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
|
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
|
||||||
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
|
||||||
github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
|
|
||||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
|
||||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
|
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||||
|
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||||
|
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
|
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||||
|
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||||
|
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||||
|
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||||
|
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||||
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||||
@ -92,89 +156,173 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
|
|||||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||||
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||||
|
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||||
|
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
|
github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M=
|
||||||
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
|
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
|
||||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||||
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
|
||||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
|
github.com/timtadh/data-structures v0.5.3 h1:F2tEjoG9qWIyUjbvXVgJqEOGJPMIiYn7U5W5mE+i/vQ=
|
||||||
|
github.com/timtadh/data-structures v0.5.3/go.mod h1:9R4XODhJ8JdWFEI8P/HJKqxuJctfBQw6fDibMQny2oU=
|
||||||
|
github.com/timtadh/lexmachine v0.2.2 h1:g55RnjdYazm5wnKv59pwFcBJHOyvTPfDEoz21s4PHmY=
|
||||||
|
github.com/timtadh/lexmachine v0.2.2/go.mod h1:GBJvD5OAfRn/gnp92zb9KTgHLB7akKyxmVivoYCcjQI=
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
|
||||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||||
|
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||||
|
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
|
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||||
|
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||||
|
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||||
|
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
|
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||||
|
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||||
|
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||||
|
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||||
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
|
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-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-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y=
|
golang.org/x/sys v0.0.0-20210317225723-c4fcb01b228e h1:XNp2Flc/1eWQGk5BLzqTAN7fQIwIbfyVTuVxXxZh73M=
|
||||||
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210317225723-c4fcb01b228e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
|
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||||
|
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||||
|
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||||
|
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||||
|
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||||
|
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||||
|
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
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/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
gopkg.in/go-playground/validator.v9 v9.30.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
|
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 h1:6D+BvnJ/j6e222UW8s2qTSe3wGBtvo0MbVQG/c5k8RE=
|
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 h1:6D+BvnJ/j6e222UW8s2qTSe3wGBtvo0MbVQG/c5k8RE=
|
||||||
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473/go.mod h1:N1eN2tsCx0Ydtgjl4cqmbRCsY4/+z4cYDeqwZTk6zog=
|
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473/go.mod h1:N1eN2tsCx0Ydtgjl4cqmbRCsY4/+z4cYDeqwZTk6zog=
|
||||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo=
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
|
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||||
|
70
pkg/yqlib/all_at_once_evaluator.go
Normal file
70
pkg/yqlib/all_at_once_evaluator.go
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"container/list"
|
||||||
|
|
||||||
|
yaml "gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// A yaml expression evaluator that runs the expression once against all files/nodes in memory.
|
||||||
|
type Evaluator interface {
|
||||||
|
EvaluateFiles(expression string, filenames []string, printer Printer) error
|
||||||
|
|
||||||
|
// EvaluateNodes takes an expression and one or more yaml nodes, returning a list of matching candidate nodes
|
||||||
|
EvaluateNodes(expression string, nodes ...*yaml.Node) (*list.List, error)
|
||||||
|
|
||||||
|
// EvaluateCandidateNodes takes an expression and list of candidate nodes, returning a list of matching candidate nodes
|
||||||
|
EvaluateCandidateNodes(expression string, inputCandidateNodes *list.List) (*list.List, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type allAtOnceEvaluator struct {
|
||||||
|
treeNavigator DataTreeNavigator
|
||||||
|
treeCreator ExpressionParser
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAllAtOnceEvaluator() Evaluator {
|
||||||
|
return &allAtOnceEvaluator{treeNavigator: NewDataTreeNavigator(), treeCreator: NewExpressionParser()}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *allAtOnceEvaluator) EvaluateNodes(expression string, nodes ...*yaml.Node) (*list.List, error) {
|
||||||
|
inputCandidates := list.New()
|
||||||
|
for _, node := range nodes {
|
||||||
|
inputCandidates.PushBack(&CandidateNode{Node: node})
|
||||||
|
}
|
||||||
|
return e.EvaluateCandidateNodes(expression, inputCandidates)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *allAtOnceEvaluator) EvaluateCandidateNodes(expression string, inputCandidates *list.List) (*list.List, error) {
|
||||||
|
node, err := e.treeCreator.ParseExpression(expression)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
context, err := e.treeNavigator.GetMatchingNodes(Context{MatchingNodes: inputCandidates}, node)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return context.MatchingNodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *allAtOnceEvaluator) EvaluateFiles(expression string, filenames []string, printer Printer) error {
|
||||||
|
fileIndex := 0
|
||||||
|
|
||||||
|
var allDocuments *list.List = list.New()
|
||||||
|
for _, filename := range filenames {
|
||||||
|
reader, err := readStream(filename)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fileDocuments, err := readDocuments(reader, filename, fileIndex)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
allDocuments.PushBackList(fileDocuments)
|
||||||
|
fileIndex = fileIndex + 1
|
||||||
|
}
|
||||||
|
matches, err := e.EvaluateCandidateNodes(expression, allDocuments)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return printer.PrintResults(matches)
|
||||||
|
}
|
40
pkg/yqlib/all_at_once_evaluator_test.go
Normal file
40
pkg/yqlib/all_at_once_evaluator_test.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/mikefarah/yq/v4/test"
|
||||||
|
)
|
||||||
|
|
||||||
|
var evaluateNodesScenario = []expressionScenario{
|
||||||
|
{
|
||||||
|
document: `a: hello`,
|
||||||
|
expression: `.a`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[a], (!!str)::hello\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
document: `a: hello`,
|
||||||
|
expression: `.`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[], (doc)::a: hello\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
document: `- a: "yes"`,
|
||||||
|
expression: `.[] | has("a")`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[0], (!!bool)::true\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAllAtOnceEvaluateNodes(t *testing.T) {
|
||||||
|
var evaluator = NewAllAtOnceEvaluator()
|
||||||
|
for _, tt := range evaluateNodesScenario {
|
||||||
|
node := test.ParseData(tt.document)
|
||||||
|
list, _ := evaluator.EvaluateNodes(tt.expression, &node)
|
||||||
|
test.AssertResultComplex(t, tt.expected, resultsToString(list))
|
||||||
|
}
|
||||||
|
}
|
101
pkg/yqlib/candidate_node.go
Normal file
101
pkg/yqlib/candidate_node.go
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
|
yaml "gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CandidateNode struct {
|
||||||
|
Node *yaml.Node // the actual node
|
||||||
|
Parent *CandidateNode // parent node
|
||||||
|
Path []interface{} /// the path we took to get to this node
|
||||||
|
Document uint // the document index of this node
|
||||||
|
Filename string
|
||||||
|
FileIndex int
|
||||||
|
// when performing op against all nodes given, this will treat all the nodes as one
|
||||||
|
// (e.g. top level cross document merge). This property does not propegate to child nodes.
|
||||||
|
EvaluateTogether bool
|
||||||
|
IsMapKey bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *CandidateNode) GetKey() string {
|
||||||
|
keyPrefix := ""
|
||||||
|
if n.IsMapKey {
|
||||||
|
keyPrefix = "key-"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%v%v - %v", keyPrefix, n.Document, n.Path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *CandidateNode) CreateChild(path interface{}, node *yaml.Node) *CandidateNode {
|
||||||
|
return &CandidateNode{
|
||||||
|
Node: node,
|
||||||
|
Path: n.createChildPath(path),
|
||||||
|
Parent: n,
|
||||||
|
Document: n.Document,
|
||||||
|
Filename: n.Filename,
|
||||||
|
FileIndex: n.FileIndex,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *CandidateNode) createChildPath(path interface{}) []interface{} {
|
||||||
|
if path == nil {
|
||||||
|
newPath := make([]interface{}, len(n.Path))
|
||||||
|
copy(newPath, n.Path)
|
||||||
|
return newPath
|
||||||
|
}
|
||||||
|
|
||||||
|
//don't use append as they may actually modify the path of the orignal node!
|
||||||
|
newPath := make([]interface{}, len(n.Path)+1)
|
||||||
|
copy(newPath, n.Path)
|
||||||
|
newPath[len(n.Path)] = path
|
||||||
|
return newPath
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *CandidateNode) Copy() (*CandidateNode, error) {
|
||||||
|
clone := &CandidateNode{}
|
||||||
|
err := copier.Copy(clone, n)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return clone, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// updates this candidate from the given candidate node
|
||||||
|
func (n *CandidateNode) UpdateFrom(other *CandidateNode) {
|
||||||
|
|
||||||
|
n.UpdateAttributesFrom(other)
|
||||||
|
n.Node.Content = other.Node.Content
|
||||||
|
n.Node.Value = other.Node.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode) {
|
||||||
|
log.Debug("UpdateAttributesFrom: n: %v other: %v", n.GetKey(), other.GetKey())
|
||||||
|
if n.Node.Kind != other.Node.Kind {
|
||||||
|
// clear out the contents when switching to a different type
|
||||||
|
// e.g. map to array
|
||||||
|
n.Node.Content = make([]*yaml.Node, 0)
|
||||||
|
n.Node.Value = ""
|
||||||
|
}
|
||||||
|
n.Node.Kind = other.Node.Kind
|
||||||
|
n.Node.Tag = other.Node.Tag
|
||||||
|
n.Node.Alias = other.Node.Alias
|
||||||
|
n.Node.Anchor = other.Node.Anchor
|
||||||
|
|
||||||
|
// merge will pickup the style of the new thing
|
||||||
|
// when autocreating nodes
|
||||||
|
if n.Node.Style == 0 {
|
||||||
|
n.Node.Style = other.Node.Style
|
||||||
|
}
|
||||||
|
|
||||||
|
if other.Node.FootComment != "" {
|
||||||
|
n.Node.FootComment = other.Node.FootComment
|
||||||
|
}
|
||||||
|
if other.Node.HeadComment != "" {
|
||||||
|
n.Node.HeadComment = other.Node.HeadComment
|
||||||
|
}
|
||||||
|
if other.Node.LineComment != "" {
|
||||||
|
n.Node.LineComment = other.Node.LineComment
|
||||||
|
}
|
||||||
|
}
|
@ -17,8 +17,8 @@ func format(attr color.Attribute) string {
|
|||||||
return fmt.Sprintf("%s[%dm", escape, attr)
|
return fmt.Sprintf("%s[%dm", escape, attr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ColorizeAndPrint(bytes []byte, writer io.Writer) error {
|
func colorizeAndPrint(yamlBytes []byte, writer io.Writer) error {
|
||||||
tokens := lexer.Tokenize(string(bytes))
|
tokens := lexer.Tokenize(string(yamlBytes))
|
||||||
var p printer.Printer
|
var p printer.Printer
|
||||||
p.Bool = func() *printer.Property {
|
p.Bool = func() *printer.Property {
|
||||||
return &printer.Property{
|
return &printer.Property{
|
||||||
|
68
pkg/yqlib/context.go
Normal file
68
pkg/yqlib/context.go
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"container/list"
|
||||||
|
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Context struct {
|
||||||
|
MatchingNodes *list.List
|
||||||
|
Variables map[string]*list.List
|
||||||
|
DontAutoCreate bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) SingleReadonlyChildContext(candidate *CandidateNode) Context {
|
||||||
|
list := list.New()
|
||||||
|
list.PushBack(candidate)
|
||||||
|
newContext := n.ChildContext(list)
|
||||||
|
newContext.DontAutoCreate = true
|
||||||
|
return newContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) SingleChildContext(candidate *CandidateNode) Context {
|
||||||
|
list := list.New()
|
||||||
|
list.PushBack(candidate)
|
||||||
|
return n.ChildContext(list)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) GetVariable(name string) *list.List {
|
||||||
|
if n.Variables == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return n.Variables[name]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) SetVariable(name string, value *list.List) {
|
||||||
|
if n.Variables == nil {
|
||||||
|
n.Variables = make(map[string]*list.List)
|
||||||
|
}
|
||||||
|
n.Variables[name] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) ChildContext(results *list.List) Context {
|
||||||
|
clone := Context{}
|
||||||
|
err := copier.Copy(&clone, n)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Error cloning context :(")
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
clone.MatchingNodes = results
|
||||||
|
return clone
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) Clone() Context {
|
||||||
|
clone := Context{}
|
||||||
|
err := copier.Copy(&clone, n)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Error cloning context :(")
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return clone
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Context) ReadOnlyClone() Context {
|
||||||
|
clone := n.Clone()
|
||||||
|
clone.DontAutoCreate = true
|
||||||
|
return clone
|
||||||
|
}
|
@ -1,292 +0,0 @@
|
|||||||
package yqlib
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
yaml "gopkg.in/yaml.v3"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DataNavigator interface {
|
|
||||||
Traverse(value *yaml.Node, path []interface{}) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type navigator struct {
|
|
||||||
navigationStrategy NavigationStrategy
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDataNavigator(NavigationStrategy NavigationStrategy) DataNavigator {
|
|
||||||
return &navigator{
|
|
||||||
navigationStrategy: NavigationStrategy,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *navigator) Traverse(value *yaml.Node, path []interface{}) error {
|
|
||||||
realValue := value
|
|
||||||
emptyArray := make([]interface{}, 0)
|
|
||||||
log.Debugf("Traversing path %v", pathStackToString(path))
|
|
||||||
if realValue.Kind == yaml.DocumentNode {
|
|
||||||
log.Debugf("its a document! returning the first child")
|
|
||||||
return n.doTraverse(value.Content[0], "", path, emptyArray)
|
|
||||||
}
|
|
||||||
return n.doTraverse(value, "", path, emptyArray)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *navigator) doTraverse(value *yaml.Node, head interface{}, tail []interface{}, pathStack []interface{}) error {
|
|
||||||
|
|
||||||
log.Debug("head %v", head)
|
|
||||||
DebugNode(value)
|
|
||||||
var nodeContext = NewNodeContext(value, head, tail, pathStack)
|
|
||||||
|
|
||||||
var errorDeepSplatting error
|
|
||||||
if head == "**" && value.Kind != yaml.ScalarNode && n.navigationStrategy.ShouldDeeplyTraverse(nodeContext) {
|
|
||||||
if len(pathStack) == 0 || pathStack[len(pathStack)-1] != "<<" {
|
|
||||||
errorDeepSplatting = n.recurse(value, head, tail, pathStack)
|
|
||||||
}
|
|
||||||
// ignore errors here, we are deep splatting so we may accidently give a string key
|
|
||||||
// to an array sequence
|
|
||||||
if len(tail) > 0 {
|
|
||||||
_ = n.recurse(value, tail[0], tail[1:], pathStack)
|
|
||||||
}
|
|
||||||
return errorDeepSplatting
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(tail) > 0 && value.Kind != yaml.ScalarNode {
|
|
||||||
log.Debugf("diving into %v", tail[0])
|
|
||||||
DebugNode(value)
|
|
||||||
return n.recurse(value, tail[0], tail[1:], pathStack)
|
|
||||||
}
|
|
||||||
return n.navigationStrategy.Visit(nodeContext)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *navigator) getOrReplace(original *yaml.Node, expectedKind yaml.Kind) *yaml.Node {
|
|
||||||
if original.Kind != expectedKind {
|
|
||||||
log.Debug("wanted %v but it was %v, overriding", KindString(expectedKind), KindString(original.Kind))
|
|
||||||
return &yaml.Node{Kind: expectedKind}
|
|
||||||
}
|
|
||||||
return original
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *navigator) recurse(value *yaml.Node, head interface{}, tail []interface{}, pathStack []interface{}) error {
|
|
||||||
log.Debug("recursing, processing %v, pathStack %v", head, pathStackToString(pathStack))
|
|
||||||
|
|
||||||
nodeContext := NewNodeContext(value, head, tail, pathStack)
|
|
||||||
|
|
||||||
if head == "**" && !n.navigationStrategy.ShouldOnlyDeeplyVisitLeaves(nodeContext) {
|
|
||||||
errorVisitingDeeply := n.navigationStrategy.Visit(nodeContext)
|
|
||||||
if errorVisitingDeeply != nil {
|
|
||||||
return errorVisitingDeeply
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch value.Kind {
|
|
||||||
case yaml.MappingNode:
|
|
||||||
log.Debug("its a map with %v entries", len(value.Content)/2)
|
|
||||||
headString := fmt.Sprintf("%v", head)
|
|
||||||
return n.recurseMap(value, headString, tail, pathStack)
|
|
||||||
|
|
||||||
case yaml.SequenceNode:
|
|
||||||
log.Debug("its a sequence of %v things!", len(value.Content))
|
|
||||||
|
|
||||||
switch head := head.(type) {
|
|
||||||
case int64:
|
|
||||||
return n.recurseArray(value, head, head, tail, pathStack)
|
|
||||||
default:
|
|
||||||
|
|
||||||
if head == "+" {
|
|
||||||
return n.appendArray(value, head, tail, pathStack)
|
|
||||||
} else if len(value.Content) == 0 && head == "**" {
|
|
||||||
return n.navigationStrategy.Visit(nodeContext)
|
|
||||||
}
|
|
||||||
return n.splatArray(value, head, tail, pathStack)
|
|
||||||
}
|
|
||||||
case yaml.AliasNode:
|
|
||||||
log.Debug("its an alias!")
|
|
||||||
DebugNode(value.Alias)
|
|
||||||
if n.navigationStrategy.FollowAlias(nodeContext) {
|
|
||||||
log.Debug("following the alias")
|
|
||||||
return n.recurse(value.Alias, head, tail, pathStack)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
return n.navigationStrategy.Visit(nodeContext)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *navigator) recurseMap(value *yaml.Node, head string, tail []interface{}, pathStack []interface{}) error {
|
|
||||||
traversedEntry := false
|
|
||||||
errorVisiting := n.visitMatchingEntries(value, head, tail, pathStack, func(contents []*yaml.Node, indexInMap int) error {
|
|
||||||
log.Debug("recurseMap: visitMatchingEntries for %v", contents[indexInMap].Value)
|
|
||||||
n.navigationStrategy.DebugVisitedNodes()
|
|
||||||
newPathStack := append(pathStack, contents[indexInMap].Value)
|
|
||||||
log.Debug("should I traverse? head: %v, path: %v", head, pathStackToString(newPathStack))
|
|
||||||
DebugNode(value)
|
|
||||||
if n.navigationStrategy.ShouldTraverse(NewNodeContext(contents[indexInMap+1], head, tail, newPathStack), contents[indexInMap].Value) {
|
|
||||||
log.Debug("recurseMap: Going to traverse")
|
|
||||||
traversedEntry = true
|
|
||||||
contents[indexInMap+1] = n.getOrReplace(contents[indexInMap+1], guessKind(head, tail, contents[indexInMap+1].Kind))
|
|
||||||
errorTraversing := n.doTraverse(contents[indexInMap+1], head, tail, newPathStack)
|
|
||||||
log.Debug("recurseMap: Finished traversing")
|
|
||||||
n.navigationStrategy.DebugVisitedNodes()
|
|
||||||
return errorTraversing
|
|
||||||
} else {
|
|
||||||
log.Debug("nope not traversing")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
if errorVisiting != nil {
|
|
||||||
return errorVisiting
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(value.Content) == 0 && head == "**" {
|
|
||||||
return n.navigationStrategy.Visit(NewNodeContext(value, head, tail, pathStack))
|
|
||||||
} else if traversedEntry || n.navigationStrategy.GetPathParser().IsPathExpression(head) || !n.navigationStrategy.AutoCreateMap(NewNodeContext(value, head, tail, pathStack)) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
_, errorParsingInt := strconv.ParseInt(head, 10, 64)
|
|
||||||
|
|
||||||
mapEntryKey := yaml.Node{Value: head, Kind: yaml.ScalarNode}
|
|
||||||
|
|
||||||
if errorParsingInt == nil {
|
|
||||||
// fixes a json encoding problem where keys that look like numbers
|
|
||||||
// get treated as numbers and cannot be used in a json map
|
|
||||||
mapEntryKey.Style = yaml.LiteralStyle
|
|
||||||
}
|
|
||||||
|
|
||||||
value.Content = append(value.Content, &mapEntryKey)
|
|
||||||
mapEntryValue := yaml.Node{Kind: guessKind(head, tail, 0)}
|
|
||||||
value.Content = append(value.Content, &mapEntryValue)
|
|
||||||
log.Debug("adding a new node %v - def a string", head)
|
|
||||||
return n.doTraverse(&mapEntryValue, head, tail, append(pathStack, head))
|
|
||||||
}
|
|
||||||
|
|
||||||
// need to pass the node in, as it may be aliased
|
|
||||||
type mapVisitorFn func(contents []*yaml.Node, index int) error
|
|
||||||
|
|
||||||
func (n *navigator) visitDirectMatchingEntries(node *yaml.Node, head string, tail []interface{}, pathStack []interface{}, visit mapVisitorFn) error {
|
|
||||||
var contents = node.Content
|
|
||||||
for index := 0; index < len(contents); index = index + 2 {
|
|
||||||
content := contents[index]
|
|
||||||
|
|
||||||
log.Debug("index %v, checking %v, %v", index, content.Value, content.Tag)
|
|
||||||
n.navigationStrategy.DebugVisitedNodes()
|
|
||||||
errorVisiting := visit(contents, index)
|
|
||||||
if errorVisiting != nil {
|
|
||||||
return errorVisiting
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *navigator) visitMatchingEntries(node *yaml.Node, head string, tail []interface{}, pathStack []interface{}, visit mapVisitorFn) error {
|
|
||||||
var contents = node.Content
|
|
||||||
log.Debug("visitMatchingEntries %v", head)
|
|
||||||
DebugNode(node)
|
|
||||||
// value.Content is a concatenated array of key, value,
|
|
||||||
// so keys are in the even indexes, values in odd.
|
|
||||||
// merge aliases are defined first, but we only want to traverse them
|
|
||||||
// if we don't find a match directly on this node first.
|
|
||||||
errorVisitedDirectEntries := n.visitDirectMatchingEntries(node, head, tail, pathStack, visit)
|
|
||||||
|
|
||||||
if errorVisitedDirectEntries != nil || !n.navigationStrategy.FollowAlias(NewNodeContext(node, head, tail, pathStack)) {
|
|
||||||
return errorVisitedDirectEntries
|
|
||||||
}
|
|
||||||
return n.visitAliases(contents, head, tail, pathStack, visit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *navigator) visitAliases(contents []*yaml.Node, head string, tail []interface{}, pathStack []interface{}, visit mapVisitorFn) error {
|
|
||||||
// merge aliases are defined first, but we only want to traverse them
|
|
||||||
// if we don't find a match on this node first.
|
|
||||||
// traverse them backwards so that the last alias overrides the preceding.
|
|
||||||
// a node can either be
|
|
||||||
// an alias to one other node (e.g. <<: *blah)
|
|
||||||
// or a sequence of aliases (e.g. <<: [*blah, *foo])
|
|
||||||
log.Debug("checking for aliases, head: %v, pathstack: %v", head, pathStackToString(pathStack))
|
|
||||||
for index := len(contents) - 2; index >= 0; index = index - 2 {
|
|
||||||
|
|
||||||
if contents[index+1].Kind == yaml.AliasNode && contents[index].Value == "<<" {
|
|
||||||
valueNode := contents[index+1]
|
|
||||||
log.Debug("found an alias")
|
|
||||||
DebugNode(contents[index])
|
|
||||||
DebugNode(valueNode)
|
|
||||||
|
|
||||||
errorInAlias := n.visitMatchingEntries(valueNode.Alias, head, tail, pathStack, visit)
|
|
||||||
if errorInAlias != nil {
|
|
||||||
return errorInAlias
|
|
||||||
}
|
|
||||||
} else if contents[index+1].Kind == yaml.SequenceNode {
|
|
||||||
// could be an array of aliases...
|
|
||||||
errorVisitingAliasSeq := n.visitAliasSequence(contents[index+1].Content, head, tail, pathStack, visit)
|
|
||||||
if errorVisitingAliasSeq != nil {
|
|
||||||
return errorVisitingAliasSeq
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *navigator) visitAliasSequence(possibleAliasArray []*yaml.Node, head string, tail []interface{}, pathStack []interface{}, visit mapVisitorFn) error {
|
|
||||||
// need to search this backwards too, so that aliases defined last override the preceding.
|
|
||||||
for aliasIndex := len(possibleAliasArray) - 1; aliasIndex >= 0; aliasIndex = aliasIndex - 1 {
|
|
||||||
child := possibleAliasArray[aliasIndex]
|
|
||||||
if child.Kind == yaml.AliasNode {
|
|
||||||
log.Debug("found an alias")
|
|
||||||
DebugNode(child)
|
|
||||||
errorInAlias := n.visitMatchingEntries(child.Alias, head, tail, pathStack, visit)
|
|
||||||
if errorInAlias != nil {
|
|
||||||
return errorInAlias
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *navigator) splatArray(value *yaml.Node, head interface{}, tail []interface{}, pathStack []interface{}) error {
|
|
||||||
for index, childValue := range value.Content {
|
|
||||||
log.Debug("processing")
|
|
||||||
DebugNode(childValue)
|
|
||||||
childValue = n.getOrReplace(childValue, guessKind(head, tail, childValue.Kind))
|
|
||||||
|
|
||||||
newPathStack := append(pathStack, index)
|
|
||||||
if n.navigationStrategy.ShouldTraverse(NewNodeContext(childValue, head, tail, newPathStack), childValue.Value) {
|
|
||||||
// here we should not deeply traverse the array if we are appending..not sure how to do that.
|
|
||||||
// need to visit instead...
|
|
||||||
// easiest way is to pop off the head and pass the rest of the tail in.
|
|
||||||
var err = n.doTraverse(childValue, head, tail, newPathStack)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *navigator) appendArray(value *yaml.Node, head interface{}, tail []interface{}, pathStack []interface{}) error {
|
|
||||||
var newNode = yaml.Node{Kind: guessKind(head, tail, 0)}
|
|
||||||
value.Content = append(value.Content, &newNode)
|
|
||||||
log.Debug("appending a new node, %v", value.Content)
|
|
||||||
return n.doTraverse(&newNode, head, tail, append(pathStack, len(value.Content)-1))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *navigator) recurseArray(value *yaml.Node, index int64, head interface{}, tail []interface{}, pathStack []interface{}) error {
|
|
||||||
var contentLength = int64(len(value.Content))
|
|
||||||
for contentLength <= index {
|
|
||||||
value.Content = append(value.Content, &yaml.Node{Kind: guessKind(head, tail, 0)})
|
|
||||||
contentLength = int64(len(value.Content))
|
|
||||||
}
|
|
||||||
var indexToUse = index
|
|
||||||
|
|
||||||
if indexToUse < 0 {
|
|
||||||
indexToUse = contentLength + indexToUse
|
|
||||||
}
|
|
||||||
|
|
||||||
if indexToUse < 0 {
|
|
||||||
return fmt.Errorf("Index [%v] out of range, array size is %v", index, contentLength)
|
|
||||||
}
|
|
||||||
|
|
||||||
value.Content[indexToUse] = n.getOrReplace(value.Content[indexToUse], guessKind(head, tail, value.Content[indexToUse].Kind))
|
|
||||||
|
|
||||||
return n.doTraverse(value.Content[indexToUse], head, tail, append(pathStack, index))
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
package yqlib
|
|
41
pkg/yqlib/data_tree_navigator.go
Normal file
41
pkg/yqlib/data_tree_navigator.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
logging "gopkg.in/op/go-logging.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DataTreeNavigator interface {
|
||||||
|
// given the context and a expressionNode,
|
||||||
|
// this will process the against the given expressionNode and return
|
||||||
|
// a new context of matching candidates
|
||||||
|
GetMatchingNodes(context Context, expressionNode *ExpressionNode) (Context, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type dataTreeNavigator struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDataTreeNavigator() DataTreeNavigator {
|
||||||
|
return &dataTreeNavigator{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *dataTreeNavigator) GetMatchingNodes(context Context, expressionNode *ExpressionNode) (Context, error) {
|
||||||
|
if expressionNode == nil {
|
||||||
|
log.Debugf("getMatchingNodes - nothing to do")
|
||||||
|
return context, nil
|
||||||
|
}
|
||||||
|
log.Debugf("Processing Op: %v", expressionNode.Operation.toString())
|
||||||
|
if log.IsEnabledFor(logging.DEBUG) {
|
||||||
|
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
|
||||||
|
log.Debug(NodeToString(el.Value.(*CandidateNode)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Debug(">>")
|
||||||
|
handler := expressionNode.Operation.OperationType.Handler
|
||||||
|
if handler != nil {
|
||||||
|
return handler(d, context, expressionNode)
|
||||||
|
}
|
||||||
|
return Context{}, fmt.Errorf("Unknown operator %v", expressionNode.Operation.OperationType)
|
||||||
|
|
||||||
|
}
|
@ -1,79 +0,0 @@
|
|||||||
package yqlib
|
|
||||||
|
|
||||||
import (
|
|
||||||
yaml "gopkg.in/yaml.v3"
|
|
||||||
)
|
|
||||||
|
|
||||||
func DeleteNavigationStrategy(pathElementToDelete interface{}) NavigationStrategy {
|
|
||||||
parser := NewPathParser()
|
|
||||||
return &NavigationStrategyImpl{
|
|
||||||
visitedNodes: []*NodeContext{},
|
|
||||||
pathParser: parser,
|
|
||||||
followAlias: func(nodeContext NodeContext) bool {
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
autoCreateMap: func(nodeContext NodeContext) bool {
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
shouldDeeplyTraverse: func(nodeContext NodeContext) bool {
|
|
||||||
return true
|
|
||||||
},
|
|
||||||
shouldOnlyDeeplyVisitLeaves: func(nodeContext NodeContext) bool {
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
visit: func(nodeContext NodeContext) error {
|
|
||||||
node := nodeContext.Node
|
|
||||||
log.Debug("need to find and delete %v in here (%v)", pathElementToDelete, pathStackToString(nodeContext.PathStack))
|
|
||||||
DebugNode(node)
|
|
||||||
if node.Kind == yaml.SequenceNode {
|
|
||||||
newContent := deleteFromArray(parser, node.Content, nodeContext.PathStack, pathElementToDelete)
|
|
||||||
node.Content = newContent
|
|
||||||
} else if node.Kind == yaml.MappingNode {
|
|
||||||
node.Content = deleteFromMap(parser, node.Content, nodeContext.PathStack, pathElementToDelete)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func deleteFromMap(pathParser PathParser, contents []*yaml.Node, pathStack []interface{}, pathElementToDelete interface{}) []*yaml.Node {
|
|
||||||
newContents := make([]*yaml.Node, 0)
|
|
||||||
for index := 0; index < len(contents); index = index + 2 {
|
|
||||||
keyNode := contents[index]
|
|
||||||
valueNode := contents[index+1]
|
|
||||||
if !pathParser.MatchesNextPathElement(NewNodeContext(keyNode, pathElementToDelete, make([]interface{}, 0), pathStack), keyNode.Value) {
|
|
||||||
log.Debug("adding node %v", keyNode.Value)
|
|
||||||
newContents = append(newContents, keyNode, valueNode)
|
|
||||||
} else {
|
|
||||||
log.Debug("skipping node %v", keyNode.Value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newContents
|
|
||||||
}
|
|
||||||
|
|
||||||
func deleteFromArray(pathParser PathParser, content []*yaml.Node, pathStack []interface{}, pathElementToDelete interface{}) []*yaml.Node {
|
|
||||||
|
|
||||||
switch pathElementToDelete := pathElementToDelete.(type) {
|
|
||||||
case int64:
|
|
||||||
return deleteIndexInArray(content, pathElementToDelete)
|
|
||||||
default:
|
|
||||||
log.Debug("%v is not a numeric index, finding matching patterns", pathElementToDelete)
|
|
||||||
var newArray = make([]*yaml.Node, 0)
|
|
||||||
|
|
||||||
for _, childValue := range content {
|
|
||||||
if !pathParser.MatchesNextPathElement(NewNodeContext(childValue, pathElementToDelete, make([]interface{}, 0), pathStack), childValue.Value) {
|
|
||||||
newArray = append(newArray, childValue)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newArray
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func deleteIndexInArray(content []*yaml.Node, index int64) []*yaml.Node {
|
|
||||||
log.Debug("deleting index %v in array", index)
|
|
||||||
if index >= int64(len(content)) {
|
|
||||||
log.Debug("index %v is greater than content length %v", index, len(content))
|
|
||||||
return content
|
|
||||||
}
|
|
||||||
return append(content[:index], content[index+1:]...)
|
|
||||||
}
|
|
1
pkg/yqlib/doc/.gitignore
vendored
Normal file
1
pkg/yqlib/doc/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.zip
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user