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

Allow custom env file paths #482

Merged
merged 7 commits into from
Dec 18, 2024
Merged

Allow custom env file paths #482

merged 7 commits into from
Dec 18, 2024

Conversation

bcherry
Copy link
Contributor

@bcherry bcherry commented Dec 18, 2024

I'm working on a swift example app for the voice assistant and it needs to get the sandbox ID loaded in, but none of the API keys. The Android example app does this with a global variable that gets overridden via sed, but the approach is brittle and a little messy.

In Swift, the best approach is to use xcconfig files, which can be imported in as build settings. It turns out that xcconfig files basically have the same format as env files, so we can just treat them as the env files for this type and take advantage of our existing env-population code. The only issues are
a) the files need to be in a subdirectory
b) it's best to give them the .xcconfig extension (although not strictly necessary, it can work without this)
c) we should not install the project secrets into them

This PR resolves these issues by allowing you to specify custom paths to these files. I added support for these to the taskfile's vars field and also to the app env command for completeness.

Here's a sample taskfile using these new properties, which I have tested and works exactly as desired. I haven't evaluated it yet but I'm hopeful that we can adopt the same method in android, react native, and flutter.

@bcherry bcherry requested a review from rektdeckard December 18, 2024 06:27
Copy link
Contributor

@rektdeckard rektdeckard left a comment

Choose a reason for hiding this comment

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

I wholeheartedly support the ability to specify the --output and --example input, but I should point out that instantiating the env does not copy LiveKit project secrets. It reads in the example and replaces only the ones present that it recognizes. So the solution to not including secrets is...not to specify them in your example.

cmd/lk/app.go Outdated Show resolved Hide resolved
@bcherry
Copy link
Contributor Author

bcherry commented Dec 18, 2024

@rektdeckard ah that makes perfect sense. it wasn't clear to me from the code, but I tested it and you are absolutely right! the only case it would fill them anyways is if no .env.example exists, but in this case I'll have an example file so it should work.

I simplified that option away and made some other tidies.

Copy link
Contributor

@rektdeckard rektdeckard left a comment

Choose a reason for hiding this comment

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

Other than comments, looks good!

cmd/lk/app.go Outdated Show resolved Hide resolved
cmd/lk/app.go Outdated Show resolved Hide resolved
@bcherry bcherry changed the title Allow custom env file path, omitting api keys Allow custom env file paths Dec 18, 2024
@bcherry bcherry merged commit 4a41071 into main Dec 18, 2024
3 checks passed
@bcherry bcherry deleted the bcherry/env-flexibility branch December 18, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants