我希望将两个不同的 JSON 文件合并到一个文件中 -
文件1
[
{
"namespace": "lerjr-rb26-sandbox-keycloak",
"name": "keycloak",
"url": "REMOVED"
},
{
"namespace": "prometheus-brr1-sandbox",
"name": "abacus",
"url": "REMOVED"
},
{
"namespace": "prometheus-brr1-sandbox",
"name": "keycloak",
"url": "REMOVED"
},
{
"namespace": "prometheus-nginxredirect-sandbox",
"name": "riskpoynt-redirect444",
"url": "REMOVED"
},
{
"namespace": "prometheus-nginxredirect-sandbox",
"name": "riskpoynt-redirect447",
"url": "REMOVED"
},
{
"namespace": "prometheus-x105-sandbox",
"name": "epas",
"url": "REMOVED"
},
{
"namespace": "prometheus-x105-sandbox",
"name": "epas-oidc",
"url": "REMOVED"
},
{
"namespace": "prometheus-x105-sandbox",
"name": "keycloak",
"url": "REMOVED"
}
]
文件2
[
{
"namespace": "ler-rb26-sandbox",
"labels": {
"pg.customerName": "prometheus",
"pg.customerCode": "rb26",
"pg.product": "keycloak",
"pg.environment": null
}
},
{
"namespace": "lerjr-rb26-sandbox-keycloak",
"labels": {
"pg.customerName": "lerjr",
"pg.customerCode": "rb26",
"pg.product": "keycloak",
"pg.environment": null
}
},
{
"namespace": "prometheus-brr1-sandbox",
"labels": {
"pg.customerName": "prometheus",
"pg.customerCode": null,
"pg.product": null,
"pg.environment": null
}
}
]
预期产出
[
{
"namespace": "lerjr-rb26-sandbox-keycloak",
"labels": {
"pg.customerName": "lerjr",
"pg.customerCode": "rb26",
"pg.product": "keycloak",
"pg.environment": null
},
"ingresses": [
{
"name": "keycloak",
"url": "REMOVED"
}
]
},
{
"namespace": "prometheus-brr1-sandbox",
"labels": {
"pg.customerName": "prometheus",
"pg.customerCode": null,
"pg.product": null,
"pg.environment": null
},
"ingresses": [
{
"name": "abacus",
"url": "REMOVED"
},
{
"name": "keycloak",
"url": "REMOVED"
}
]
},
{
"namespace": "prometheus-nginxredirect-sandbox",
"labels": {
"pg.customerName": "null",
"pg.customerCode": null,
"pg.product": null,
"pg.environment": null
},
"ingresses": [
{
"name": "riskpoynt-redirect444",
"url": "REMOVED"
},
{
"name": "riskpoynt-redirect447",
"url": "REMOVED"
}
]
},
{
"namespace": "prometheus-x105-sandbox",
"labels": {
"pg.customerName": "null",
"pg.customerCode": null,
"pg.product": null,
"pg.environment": null
},
"ingresses": [
{
"name": "epas",
"url": "REMOVED"
},
{
"name": "epas-oidc",
"url": "REMOVED"
},
{
"name": "keycloak",
"url": "REMOVED"
}
]
}
]
请注意,最终产品具有标签(如果不存在则为 null),并且如果没有入口,则删除名称空间条目。命名空间键/值对是两个文件之间的链接 - 我想文件 1 是主文件,如果文件 1 中没有命名空间条目,我不希望文件 2 中的命名空间条目。
任何和所有的帮助将不胜感激,我一直在努力解决这个问题。