Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jq: add quote option #18009

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions provider/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ type Pipeline struct {
re *regexp.Regexp
jq *gojq.Query
allowEmpty bool
quote bool
dflt string
unpack string
decode string
}

type Settings struct {
AllowEmpty bool
Quote bool
Regex string
Default string
Jq string
Expand All @@ -39,6 +41,7 @@ func New(log *util.Logger, cc Settings) (*Pipeline, error) {
p := &Pipeline{
log: log,
allowEmpty: cc.AllowEmpty,
quote: cc.Quote,
}

var err error
Expand Down Expand Up @@ -191,6 +194,9 @@ func (p *Pipeline) Process(in []byte) ([]byte, error) {
}

if p.jq != nil {
if p.quote {
b = []byte(fmt.Sprintf("%q", string(b)))
}
v, err := jq.Query(p.jq, b)
if err != nil {
return b, backoff.Permanent(err)
Expand Down
Loading