nginxinc / crossplane

Quick and reliable way to convert NGINX configurations into JSON and back.
Apache License 2.0
719 stars 87 forks source link

build ignores the -d argument #72

Closed rolfen closed 5 years ago

rolfen commented 5 years ago

Describe the bug The documentation for the build command describes: -d PATH, --dir PATH the base directory to build in However, in practice, this does not produce the expected effect.

To Reproduce crossplane parse /etc/nginx/nginx.conf |crossplane build -d /tmp /dev/stdin

Expected behavior crossplane produces new configuration files inside the /tmp directory as instructed by the -d option

Actual behavior crossplane tries to overwrite the configuration files in /etc/nginx

Your environment

aluttik commented 5 years ago

Hi @rolfen, thanks for the bug report!

The issue here is because the -d option will only apply to the files in the crossplane JSON that use relative paths. If you pipe the parsed config file into the build command, you'll always write to /etc/nginx/nginx.conf because the absolute path is stored in the JSON.

I can see why that'd be confusing. We'll consider editing the help message and README.

rolfen commented 5 years ago

Hi!

Oh, OK! Thank you for the prompt clarification, it makes sense.

I am closing the issue, because the issue strictly as described is resolved.

However a note in the documentation would be very welcome.

Feel free to reopen it if you prefer.

rolfen commented 5 years ago

I was trying to build config files into a temporary directory so that I can examine them. To achieve my intentions, I had to rewrite absolute paths because crossplane would not override them.

mkdir /tmp/nginx.conf/
crossplane parse /etc/nginx/nginx.conf |sed s:\"/etc/nginx/:\"/tmp/nginx.conf/:g |crossplane build /dev/stdin