-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
4

1 回答 1

0

您可以使用mikefarah/yq的替换/替换字符串功能

yq e '.api[] |= sub("localhost:", "192.168.0.1:")'

对于要在多个节点上替换的更新问题,请执行

yq e '.url |= (.api[],.db[],.rule,.metrics) |= sub("localhost:", "192.168.0.1:")'
于 2021-06-03T11:33:59.273 回答