mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-10 08:35:42 +00:00
Merge branch 'mikefarah:master' into master
This commit is contained in:
commit
d713496938
@ -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 = "4.9.5"
|
Version = "4.9.6"
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
FROM mikefarah/yq:4.9.5
|
FROM mikefarah/yq:4.9.6
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
|||||||
@ -7,11 +7,24 @@ import (
|
|||||||
"github.com/mikefarah/yq/v4/test"
|
"github.com/mikefarah/yq/v4/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var variableWithNewLine = `"cat
|
||||||
|
"`
|
||||||
|
|
||||||
var pathTests = []struct {
|
var pathTests = []struct {
|
||||||
path string
|
path string
|
||||||
expectedTokens []interface{}
|
expectedTokens []interface{}
|
||||||
expectedPostFix []interface{}
|
expectedPostFix []interface{}
|
||||||
}{
|
}{
|
||||||
|
{
|
||||||
|
".a\n",
|
||||||
|
append(make([]interface{}, 0), "a"),
|
||||||
|
append(make([]interface{}, 0), "a"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
variableWithNewLine,
|
||||||
|
append(make([]interface{}, 0), "cat\n (string)"),
|
||||||
|
append(make([]interface{}, 0), "cat\n (string)"),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
`.[0]`,
|
`.[0]`,
|
||||||
append(make([]interface{}, 0), "SELF", "TRAVERSE_ARRAY", "[", "0 (int64)", "]"),
|
append(make([]interface{}, 0), "SELF", "TRAVERSE_ARRAY", "[", "0 (int64)", "]"),
|
||||||
|
|||||||
@ -320,7 +320,7 @@ func initLexer() (*lex.Lexer, error) {
|
|||||||
lexer.Add([]byte("( |\t|\n|\r)+"), skip)
|
lexer.Add([]byte("( |\t|\n|\r)+"), skip)
|
||||||
|
|
||||||
lexer.Add([]byte(`\."[^ "]+"\??`), pathToken(true))
|
lexer.Add([]byte(`\."[^ "]+"\??`), pathToken(true))
|
||||||
lexer.Add([]byte(`\.[^ \}\{\:\[\],\|\.\[\(\)=]+\??`), pathToken(false))
|
lexer.Add([]byte(`\.[^ \}\{\:\[\],\|\.\[\(\)=\n]+\??`), pathToken(false))
|
||||||
lexer.Add([]byte(`\.`), selfToken())
|
lexer.Add([]byte(`\.`), selfToken())
|
||||||
|
|
||||||
lexer.Add([]byte(`\|`), opToken(pipeOpType))
|
lexer.Add([]byte(`\|`), opToken(pipeOpType))
|
||||||
|
|||||||
@ -14,7 +14,7 @@ var equalsOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
document: `a: cat`,
|
document: `a: cat`,
|
||||||
expression: ".a == .b",
|
expression: ".a == .b",
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[a], (!!bool)::false\n",
|
"D0, P[a], (!!bool)::false\n",
|
||||||
@ -22,7 +22,7 @@ var equalsOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
document: `a: cat`,
|
document: `a: cat`,
|
||||||
expression: ".b == .a",
|
expression: ".b == .a",
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[a], (!!bool)::false\n",
|
"D0, P[a], (!!bool)::false\n",
|
||||||
|
|||||||
@ -127,9 +127,16 @@ func traverseArrayIndices(context Context, matchingNode *CandidateNode, indicesT
|
|||||||
node := matchingNode.Node
|
node := matchingNode.Node
|
||||||
if node.Tag == "!!null" {
|
if node.Tag == "!!null" {
|
||||||
log.Debugf("OperatorArrayTraverse got a null - turning it into an empty array")
|
log.Debugf("OperatorArrayTraverse got a null - turning it into an empty array")
|
||||||
// auto vivification, make it into an empty array
|
// auto vivification
|
||||||
node.Tag = ""
|
node.Tag = ""
|
||||||
node.Kind = yaml.SequenceNode
|
node.Kind = yaml.SequenceNode
|
||||||
|
//check that the indices are numeric, if not, then we should create an object
|
||||||
|
if len(indicesToTraverse) != 0 {
|
||||||
|
_, err := strconv.ParseInt(indicesToTraverse[0].Value, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
node.Kind = yaml.MappingNode
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.Kind == yaml.AliasNode {
|
if node.Kind == yaml.AliasNode {
|
||||||
|
|||||||
@ -35,6 +35,14 @@ var traversePathOperatorScenarios = []expressionScenario{
|
|||||||
"D0, P[0 0], (!!int)::1\n",
|
"D0, P[0 0], (!!int)::1\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
skipDoc: true,
|
||||||
|
document: `b: cat`,
|
||||||
|
expression: ".b\n",
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[b], (!!str)::cat\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
document: `[[[1]]]`,
|
document: `[[[1]]]`,
|
||||||
@ -43,6 +51,13 @@ var traversePathOperatorScenarios = []expressionScenario{
|
|||||||
"D0, P[0 0 0], (!!int)::1\n",
|
"D0, P[0 0 0], (!!int)::1\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
skipDoc: true,
|
||||||
|
expression: `.["cat"] = "thing"`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[], ()::cat: thing\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: "Simple map navigation",
|
description: "Simple map navigation",
|
||||||
document: `{a: {b: apple}}`,
|
document: `{a: {b: apple}}`,
|
||||||
|
|||||||
@ -4,7 +4,7 @@ set -e
|
|||||||
# at https://github.com/inconshreveable/gonative
|
# at https://github.com/inconshreveable/gonative
|
||||||
|
|
||||||
|
|
||||||
CGO_ENABLED=0 gox -ldflags "${LDFLAGS}" -output="build/yq_{{.OS}}_{{.Arch}}" --osarch="darwin/amd64 freebsd/386 freebsd/amd64 freebsd/arm linux/386 linux/amd64 linux/arm linux/arm64 linux/mips linux/mips64 linux/mips64le linux/mipsle linux/ppc64 linux/ppc64le linux/s390x netbsd/386 netbsd/amd64 netbsd/arm openbsd/386 openbsd/amd64 windows/386 windows/amd64"
|
CGO_ENABLED=0 gox -ldflags "${LDFLAGS}" -output="build/yq_{{.OS}}_{{.Arch}}" --osarch="darwin/amd64 darwin/arm64 freebsd/386 freebsd/amd64 freebsd/arm linux/386 linux/amd64 linux/arm linux/arm64 linux/mips linux/mips64 linux/mips64le linux/mipsle linux/ppc64 linux/ppc64le linux/s390x netbsd/386 netbsd/amd64 netbsd/arm openbsd/386 openbsd/amd64 windows/386 windows/amd64"
|
||||||
|
|
||||||
cd build
|
cd build
|
||||||
rhash -r -a . -o checksums
|
rhash -r -a . -o checksums
|
||||||
@ -21,4 +21,4 @@ rm yq_windows_386.exe.tar.gz
|
|||||||
rm yq_windows_amd64.exe.tar.gz
|
rm yq_windows_amd64.exe.tar.gz
|
||||||
|
|
||||||
zip yq_windows_386.zip yq_windows_386.exe
|
zip yq_windows_386.zip yq_windows_386.exe
|
||||||
zip yq_windows_amd64.zip yq_windows_amd64.exe
|
zip yq_windows_amd64.zip yq_windows_amd64.exe
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yq
|
name: yq
|
||||||
version: '4.9.5'
|
version: '4.9.6'
|
||||||
summary: A lightweight and portable command-line YAML processor
|
summary: A lightweight and portable command-line YAML processor
|
||||||
description: |
|
description: |
|
||||||
The aim of the project is to be the jq or sed of yaml files.
|
The aim of the project is to be the jq or sed of yaml files.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user