mirror of
https://github.com/floci-io/floci.git
synced 2026-11-28 16:11:48 -05:00
fix(ecs): emit empty arrays for empty command, entryPoint and environment (#7941)
This commit is contained in:
1 parent
1dadaee351
commit
bbc6e1b0a1
2 files changed
+32
-3
No files matched your search
@@ -280,13 +280,13 @@ public class EcsResponseWriter {
|
||||
n.set("portMappings", pms);
|
||||
}
|
||||
|
||||
if (def.getEntryPoint() != null && !def.getEntryPoint().isEmpty()) {
|
||||
if (def.getEntryPoint() != null) {
|
||||
n.set("entryPoint", stringArray(def.getEntryPoint()));
|
||||
}
|
||||
if (def.getCommand() != null && !def.getCommand().isEmpty()) {
|
||||
if (def.getCommand() != null) {
|
||||
n.set("command", stringArray(def.getCommand()));
|
||||
}
|
||||
if (def.getEnvironment() != null && !def.getEnvironment().isEmpty()) {
|
||||
if (def.getEnvironment() != null) {
|
||||
n.set("environment", keyValuePairsNode(def.getEnvironment()));
|
||||
}
|
||||
if (def.getEnvironmentFiles() != null && !def.getEnvironmentFiles().isEmpty()) {
|
||||
|
||||
@@ -112,4 +112,33 @@ class EcsJsonHandlerCommandEntryPointTest {
|
||||
assertTrue(container.path("entryPoint").isMissingNode(), "entryPoint must stay absent");
|
||||
assertTrue(container.path("command").isMissingNode(), "command must stay absent");
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyCommandEntryPointAndEnvironmentReadBackAsEmptyArrays() throws Exception {
|
||||
String requestJson = """
|
||||
{
|
||||
"family": "empty-list-family",
|
||||
"containerDefinitions": [
|
||||
{
|
||||
"name": "app",
|
||||
"image": "alpine:latest",
|
||||
"entryPoint": [],
|
||||
"command": [],
|
||||
"environment": []
|
||||
}
|
||||
]
|
||||
}
|
||||
""";
|
||||
JsonNode request = objectMapper.readTree(requestJson);
|
||||
|
||||
Response response = handler.handle("RegisterTaskDefinition", request, "us-east-1");
|
||||
JsonNode container = objectMapper.valueToTree(response.getEntity())
|
||||
.path("taskDefinition").path("containerDefinitions").get(0);
|
||||
|
||||
for (String field : List.of("entryPoint", "command", "environment")) {
|
||||
JsonNode value = container.path(field);
|
||||
assertTrue(value.isArray() && value.isEmpty(),
|
||||
field + " must read back as an empty array");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user