vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.21k stars 1.81k forks source link

Provide env var for --api url. #1324

Closed sppatel closed 2 years ago

sppatel commented 2 years ago

Describe the feature you'd like to request

The following env variables are supported today for use by a CI configuration (e.g GHA).

TURBO_TOKEN TURBO_TEAM TURBO_REMOTE_ONLY

However for users using a custom cache server - would be good to also provide TURBO_API to avoid having to pass though --api on all commands.

The current solution is to drop in a config.json inside .turbo directory with the team and api url. However, for security purposes use different api urls for a shared cache between developers vs CI.

Describe the solution you'd like

Support a TURBO_API environment variable to set the --api for caching requests.

Describe alternatives you've considered

The current solution is to swap out the config.json during CI with the different URL (vs what is used for development).

weyert commented 2 years ago

Yeah, good idea. You would think that CLI library they use to parse arguments would have built-in functionality to easily support driving arguments by environment variables. Similar to https://pkg.go.dev/gopkg.in/alecthomas/kingpin.v2#ArgClause.Envar

cpitt commented 2 years ago

TURBO_TOKEN TURBO_API TURBO_TEAMID

Works for me to configure the custom remote process.env.STORAGE_PATH = 'fluent-turborepo-cache';

cpitt commented 2 years ago

Looks like it's undocumented but the config setup uses https://github.com/kelseyhightower/envconfig process anything prefixed with TURBO_ Not sure how it all maps up my Go is a little rusty

https://github.com/vercel/turborepo/blob/main/cli/internal/config/config.go#L115

https://github.com/vercel/turborepo/blob/1cfaff0f5152cea02e98f872e82d5e72a167d1f4/cli/internal/config/config_file.go#L20

mehulkar commented 2 years ago

Sounds like https://github.com/vercel/turborepo/issues/1324#issuecomment-1213557555 has answered the question. Closing this out unless anything else is needed!