Introducing feature flags to "build-configs"

Yesterday, I wanted to make a breaking change to my build-configs project - changing the default database credentials that are used by Docker Compose.

As I have several projects based on generated files by the tool, changing the values could cause issues in those projects in the future and this is something that I wanted to avoid.

What did I do?

To avoid this issue and needing to update all of my projects at once, I added a feature flag to the build.yaml file so I can opt-in to this feature on a per-project basis.

If a project, like my Drupal and LocalGov Drupal Docker examples, are opted in, its files will get the new credentials. If not, it will continue to use the original ones.

In this commit, you'll see where I enabled the feature flag and committed the resulting change.

What does this achieve?

I can continue to work on existing projects without them breaking, and migrate projects one at a time by using the feature flag instead of needing to do them all once.

Once all active projects have been migrated or completed, the feature flag can be removed and I can refactor and simplify the code - removing the feature flag and the legacy values.

- Oliver

P.S. Do you want to learn about automated testing in Drupal? Take my free 10-day email course and get daily lessons straight to your inbox.

Was this useful?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.