First, thank you very much for this wonderful library! We had feared needing to write one, or having to live with using exec to run jq from the command line.
The problem we ran into is that a query that works fine on an M1 Mac fails in Jenkins running on a t3.medium image in AWS: https://aws.amazon.com/ec2/instance-types/
Is this perhaps due to not having a binding for that particular hardware?
This unit test shows the problem (when executed in Jenkins):
package org.problem;
import com.arakelian.jq.ImmutableJqLibrary;
import com.arakelian.jq.ImmutableJqRequest;
import com.arakelian.jq.JqResponse;
import org.junit.jupiter.api.Test;
class Problem {
static final String INPUT =
"{\n"
+ " \"apiVersion\": 1,\n"
+ " \"kind\": \"Foo\",\n"
+ " \"spec\": {\n"
+ " \"workloads\": {\n"
+ " \"settings\": {\n"
+ " \"clusters\": {}\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
static final String UNHAPPY_JQ =
"del(.spec.workloads.[].clusters[].envs.[].tracks.[].containers[].useArtifactoryCacheServers) | .spec.workloads.[].clusters[].envs.[].tracks.[] |= with_entries(if .key == \"featureFlags\" then .key = \"rolloutFlags\" else . end)";
static String responseOutput(JqResponse response) {
if (response == null) {
throw new RuntimeException("JQ response is null");
}
if (response.hasErrors()) {
throw new RuntimeException(response.getErrors().toString());
}
return response.getOutput();
}
static String doQuery(String input, String query) {
JqResponse response =
ImmutableJqRequest.builder()
.lib(ImmutableJqLibrary.of())
.input(input)
.filter(query)
.build()
.execute();
return responseOutput(response);
}
@Test
void simpleQueryWorks() {
doQuery("{\"a\":[1,2,3,4,5],\"b\":\"hello\"}", ".");
}
@Test
void makeProblemHappen() {
doQuery(INPUT, UNHAPPY_JQ);
}
}
The error is:
[jq: error: syntax error, unexpected '[', expecting FORMAT or QQSTRING_START (Unix shell quoting issues?) at <top-level>, line 1:
del(.spec.workloads.[].clusters[].envs.[].tracks.[].containers[].useArtifactoryCacheServers) | .spec.workloads.[].clusters[].envs.[].tracks.[] |= with_entries(if .key == "featureFlags" then .key = "rolloutFlags" else . end), jq: 1 compile error]
First, thank you very much for this wonderful library! We had feared needing to write one, or having to live with using exec to run jq from the command line.
The problem we ran into is that a query that works fine on an M1 Mac fails in Jenkins running on a t3.medium image in AWS: https://aws.amazon.com/ec2/instance-types/
Is this perhaps due to not having a binding for that particular hardware?
This unit test shows the problem (when executed in Jenkins):
The error is: