DopplerHQ / cli

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

Add support for monorepo-friendly structuring in doppler.yaml setup file #374

Closed watsonian closed 1 year ago

watsonian commented 1 year ago

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.

watsonian commented 1 year ago

@nmanoogian @Piccirello Tweaked the error checking a bit. Would love a second look at that when you have a chance.

nmanoogian commented 1 year ago

Nice refactor!

jieey1140 commented 1 year ago

so nice! I'm looking forward to this update :)

Piccirello commented 1 year ago

Bypassing branch protection to merge this, despite the Salus failure. The failure is unrelated to our code: https://github.com/coinbase/salus/issues/828

ZeldOcarina commented 1 year ago

Hi! Can you please explain a bit how to run doppler commands using this?

watsonian commented 1 year ago

@ZeldOcarina All Doppler CLI commands will remain unchanged! All this does is make it so you can create a single doppler.yaml file in the root of your monorepo directory and then run doppler setup once to configure all of the services in the repo in one command (previously, you would have needed a separate doppler.yaml file in each of your service's top-level subdirectory and would have had to run doppler setup in each directory one-by-one).

Once the setup is done, you won't need to specify the project or config in your CLI command because that's already setup.

ZeldOcarina commented 1 year ago

Thank you!! I made it work somehow! It also helped me to handle this question: https://stackoverflow.com/questions/76274391/how-do-i-allow-separate-env-variables-on-a-monorepo-for-each-project-in-vercel