How to keep production and development git branches with different variables from conflicting with eachother?

Viewed 20

We have one git repository serving two environments/branches: production and development. The code between those two environments should be identical except for a few variables.

To exemplify:

in our development environment which exists in a separate network, we run a dhcp server with configurations that match its IP space e.g. 192.168.1.0/24. Say during boot a device needs to get fileA from 192.168.1.10, the dhcp has these options and sends it to the device.

If everything works fine we want to implement the exact same thing in production. However production lives in e.g. 172.16.1.0/24. So now the dhcp should send the same option to get fileA but from 172.16.1.10.

So now we have in the dhcp config file:

Production: get fileA from 172.16.1.10

Development get fileA from 192.168.1.10

Say we are currently in development and want to get fileB instead, after changing that line to get fileB from 192.168.1.10 and deduced it works, we want to implement it in production.

However when we would merge dev into production we would overwrite not only fileA to fileB but also the IP address which we don't want. Other times it would give merge conflicts.

Also the interface, gateway, subnet and dhcp pool address would be changed.

A solution could be to do a search and replace but having to do that after every merge is quite cumbersome.

Another thing I thought of is to replace the actual ip address with variables: get fileA from $IP and fill in this variable from a config file with a search and replace. This would be in development we would run the script to apply the variables, check if it's working and revert everything except the changes we made to be able to merge cleanly into production.

What would be the best way to tackle something like this?

0 Answers
Related