有没有办法使用 yq 命令更改 URL 中的 ip 地址
Is there a way to change to a ip addess in URL using yq command
我正在寻找如何使用 yq 命令从 localhost 更改为 ip 地址。下面是例子
来自 :
api:
in: http://localhost:1141/test-new-api/rest/apiIntegration
out: http://localhost:1141/test-new-api/rest/outputIntegration
收件人:
api:
in: http://192.168.0.1:1141/test-new-api/rest/apiIntegration
out: http://192.168.0.1:1141/test-new-api/rest/outputIntegration
格式正确
url:
api:
in: http://localhost:1141/test-new-api/rest/apiIntegration
out: http://localhost:1141/test-new-api/rest/outputIntegration
db:
in: http://localhost:1121/test-new-api/rest/aggregateTaskQuery
out: http://localhost:1121/test-new-api/rest/insertQuery
rule: http://localhost:1131/test-new-api/rest/executeRule
metrics: http://localhost:1191/test-new-api/rest/addTaskMetrics
您可以使用 Substitute / Replace string functionality of mikefarah/yq
yq e '.api[] |= sub("localhost:", "192.168.0.1:")'
要在多个节点上替换更新的问题,请执行
yq e '.url |= (.api[],.db[],.rule,.metrics) |= sub("localhost:", "192.168.0.1:")'
我正在寻找如何使用 yq 命令从 localhost 更改为 ip 地址。下面是例子
来自 :
api:
in: http://localhost:1141/test-new-api/rest/apiIntegration
out: http://localhost:1141/test-new-api/rest/outputIntegration
收件人:
api:
in: http://192.168.0.1:1141/test-new-api/rest/apiIntegration
out: http://192.168.0.1:1141/test-new-api/rest/outputIntegration
格式正确
url:
api:
in: http://localhost:1141/test-new-api/rest/apiIntegration
out: http://localhost:1141/test-new-api/rest/outputIntegration
db:
in: http://localhost:1121/test-new-api/rest/aggregateTaskQuery
out: http://localhost:1121/test-new-api/rest/insertQuery
rule: http://localhost:1131/test-new-api/rest/executeRule
metrics: http://localhost:1191/test-new-api/rest/addTaskMetrics
您可以使用 Substitute / Replace string functionality of mikefarah/yq
yq e '.api[] |= sub("localhost:", "192.168.0.1:")'
要在多个节点上替换更新的问题,请执行
yq e '.url |= (.api[],.db[],.rule,.metrics) |= sub("localhost:", "192.168.0.1:")'