{
"taskDefinition": {
"status": "ACTIVE",
"networkMode": "bridge",
"family": "decac-DSF-FarmB-BGcore-V7KAEEL71QS8",
"placementConstraints": [],
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.17"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.28"
},
{
"name": "ecs.capability.container-health-check"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
}
],
"cpu": "8192",
"compatibilities": [
"EXTERNAL",
"EC2"
],
"volumes": [],
"memory": "12480",
"requiresCompatibilities": [],
"taskDefinitionArn": "arn:aws:ecs:ap-south-1:020627:task-definition/decac-DSF-FarmB-BGcore-V7KAEEL71QS8:640",
"containerDefinitions": [
{
"dnsSearchDomains": [],
"environment": [
{
"name": "BG_CONFIGURATION_SERVER_URL",
"value": "http://internal-BGDSF-FarmB-pp-int-ALB-1301919556.ap-south-1.elb.amazonaws.com"
},
{
"name": "ES_IS_ENABLED_SSL",
"value": "false"
},
{
"name": "THINKANALYTICS_ENDPOINT",
"value": ""
},
{
"name": "USE_HTTPS",
"value": "false"
},
{
"name": "BG_CONFIG_REFRESH_INTERVAL",
"value": "10000"
},
{
"name": "DECOUPLE_DCQ_ENABLED",
"value": "true"
},
{
"name": "ES_SSL_CERTIFICATE_PATH",
"value": ""
},
{
"name": "LOG_LEVEL",
"value": "info"
}
],
"systemControls": [],
"name": "BG-core-FarmB",
"links": [],
"mountPoints": [],
"healthCheck": {
"retries": 10,
"interval": 60,
"command": [
"CMD-SHELL",
"/opt/app-root/src/readinessodejs.sh"
],
"startPeriod": 15,
"timeout": 45
},
"image": "020627.dkr.ecr.ap-south-1.amazonaws.com/BG-core:DEE.56.03112022-122711",
"hostname": "BG-core",
"essential": true,
"portMappings": [
{
"protocol": "tcp",
"containerPort": 3000,
"hostPort": 0
}
],
"dnsServers": [],
"dockerSecurityOptions": [],
"entryPoint": [
"sh",
"-c"
],
"ulimits": [
{
"softLimit": 51200,
"name": "nofile",
"hardLimit": 51200
}
],
"memory": 12480,
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-region": "ap-south-1",
"awslogs-stream-prefix": "BG-core-FarmB",
"awslogs-group": "decacDSF-PP-ECSInfra-KHM9B7BK1HDE-ECSLogGroup-Q2KC9BCLGILN",
"mode": "non-blocking"
}
},
"command": [
"/bin/sh -c \"/tmp/scripts/run\""
],
"cpu": 8192,
"volumesFrom": []
}
],
"revision": 640
},
"tags": []
},
这已经通过使用下面的命令工作过了:
jq 'map(del(.任务定义参数,.修订版,.状态,.要求属性,.兼容性))'
但现在相同的命令开始出现以下错误。
jq:错误(在:139):无法使用字符串“taskDefinitionArn”对数组进行索引
我用的是JQ 1.5版,最近有什么变化吗?
为什么会失败,有人能帮忙吗?
请找到完整的JSON代码和输出,我已经复制在以下link
1条答案
按热度按时间pod7payv1#
现在问题已经用一个最小的、可重复的例子更新了,答案很简单。程序应该是:
它会将
taskDefinition
对象重新指派给本身,并移除所有指定的属性。map
不起作用的原因是map将其内部过滤器应用于数组的所有元素。如果传入一个对象,则过滤器将应用于该对象的所有 * 值 *。只要你的对象值是对象本身,这就可以工作,但是当你有非对象值时就中断。
del
只能应用于类型对象的输入。以下是将破坏基于
map
的过滤器的最小样本输入:在
object
的值上调用del
的工作原理如下:{} | del(.something)
,但是在array
的值上呼叫它将会中断:[] | del(.something)
.