DopplerHQ / cli

The official CLI for interacting with your Doppler secrets and configuration.
https://docs.doppler.com
Apache License 2.0
221 stars 44 forks source link

Add support for monorepo-friendly doppler.yaml files (take 2) #394

Closed watsonian closed 1 year ago

watsonian commented 1 year ago

Take 2 of #374 which we had to revert due to a bug that broke interactive invocations of doppler setup. This reintroduces the same change in #374 with the addition of the fix in #386 that we decided to hold off on in favor of rolling back so we could do more testing. It also adds an additional test for interactive doppler setup invocations using expect. I've run the test without the fix from #386 to ensure it would have caught it (which it would have).


This adds support for a more monorepo-friendly setup file. Historically, a setup file (doppler.yaml) had this format:

setup:
  project: cli
  config: dev

It could only contain values for a single project+config combination. If you had a monorepo that contained many services as subdirectories, you had to essentially add one of these to each of the subdirectories and then have a script go through running doppler setup in each directory (or clever usage of find on linux systems).

This change now supports setup files in this format:

setup:
  - project: cli
    config: dev
    path: .
  - project: example
    config: stg
    path: example/

It lets you specify multiple project+repo combinations and adds a new path field. If no path field is specified, then it refers to the root directory. If one is specified, it's relative to the root directory.

The change maintains backwards compatibility with old setup files while allowing the new usage. If the new format is detected, it will loop through, prompting you if you want to perform the setup for each directory (and prints the directory it's performing the setup for). --no-interactive will work as expected in this case. If the old format is detected, then everything works as it has historically.

Fixes ENG-3644.