Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 3, 2023

Conversation

watsonian
Copy link
Contributor

@watsonian watsonian commented Mar 15, 2023

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 watsonian requested a review from Piccirello as a code owner March 15, 2023 18:50
@watsonian watsonian changed the title Add support for monorepo structuring in doppler.yaml setup file Add support for monorepo-friendly structuring in doppler.yaml setup file Mar 15, 2023
@watsonian watsonian force-pushed the watsonian/monorepo-setup-file branch 2 times, most recently from 622fd4e to e670e51 Compare March 15, 2023 21:40
Copy link
Contributor

@Piccirello Piccirello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did some quick testing locally and this works great!

pkg/models/repo_config.go Outdated Show resolved Hide resolved
pkg/cmd/setup.go Show resolved Hide resolved
@watsonian watsonian force-pushed the watsonian/monorepo-setup-file branch 8 times, most recently from e6b8a3e to 959ebb8 Compare March 20, 2023 18:18
@watsonian watsonian requested a review from Piccirello March 20, 2023 18:24
Piccirello
Piccirello previously approved these changes Mar 22, 2023
Copy link
Contributor

@Piccirello Piccirello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Requesting review from @nmanoogian as a sanity check.

pkg/cmd/setup.go Show resolved Hide resolved
@Piccirello Piccirello requested a review from nmanoogian March 22, 2023 18:21
nmanoogian
nmanoogian previously approved these changes Mar 24, 2023
Copy link
Member

@nmanoogian nmanoogian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this! I did some light local testing; just two small callouts

pkg/cmd/setup.go Show resolved Hide resolved
pkg/cmd/setup.go Show resolved Hide resolved
@watsonian watsonian dismissed stale reviews from nmanoogian and Piccirello via a31b884 March 28, 2023 18:57
@watsonian watsonian force-pushed the watsonian/monorepo-setup-file branch 2 times, most recently from a31b884 to caeac52 Compare March 28, 2023 19:11
nmanoogian
nmanoogian previously approved these changes Mar 28, 2023
@watsonian watsonian force-pushed the watsonian/monorepo-setup-file branch from 064c0c7 to 3bc72d1 Compare March 28, 2023 20:03
@watsonian
Copy link
Contributor Author

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

@nmanoogian
Copy link
Member

Nice refactor!

@jieey1140
Copy link

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

@Piccirello
Copy link
Contributor

Piccirello commented Apr 3, 2023

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

@ZeldOcarina
Copy link

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

@watsonian
Copy link
Contributor Author

@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
Copy link

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

@Piccirello Piccirello deleted the watsonian/monorepo-setup-file branch July 5, 2023 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants