The replacer is a configuration-based file replace tool.
The first need Go installed (version 1.21+ is required), then you can use the below
command to install replacer
.
go install github.com/no-src/replacer/...@latest
You can use the build-docker.sh script to build the docker image and you should clone this
repository and cd
to the root path of the repository first.
$ ./scripts/build-docker.sh
Or pull the docker image directly from DockerHub with the command below.
$ docker pull nosrc/replacer
Create a config file named replacer.yaml
, content is as follows
name: the configuration of replacer
version: v0.0.1
items:
- name: replace domain
paths:
- "*/test.yaml"
rules:
- old:
- 127.0.0.1:8888
- 127.0.0.1:9999
new:
test: test-github.com
uat: uat-github.com
product: product-github.com
Now running the command below start to replace the files.
$ replacer -root="./testdata/testfile" -tag=test