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

Implement the equivalent of process.env #369

Open
lastmjs opened this issue May 4, 2023 · 3 comments
Open

Implement the equivalent of process.env #369

lastmjs opened this issue May 4, 2023 · 3 comments
Labels
new feature Adds additional functionality

Comments

@lastmjs
Copy link
Member

lastmjs commented May 4, 2023

Azle now has a process.env object with the environment variables specified by the developer in the env property of their dfx.json file. Kybra should have the equivalent of this, and the reference section of the Kybra book should be updated accordingly.

@bdemann bdemann self-assigned this May 9, 2023
@lastmjs
Copy link
Member Author

lastmjs commented May 9, 2023

Actually let's hold off on this while I do the wasi stuff. If we can compile Kybra to wasi, we might have a lot of this done/a better way of doing this

@dansteren dansteren added the new feature Adds additional functionality label Jun 5, 2023
@bdemann bdemann removed their assignment Jun 5, 2023
@lastmjs
Copy link
Member Author

lastmjs commented Jun 30, 2023

os.environ.get looks like the API we should use. I believe if ic-wasi-polyfill had implemented the environment variable imports, then this would work, but I wonder if it will take some more effort on DFINITY's side. We could possibly fork ic-wasi-polyfill and get this working now, but I'm holding off to wait for a better solution.

@lastmjs
Copy link
Member Author

lastmjs commented Jun 30, 2023

import os


@update
def test() -> str:
    return os.environ.get("TEST_KEY") or "could not find TEST_KEY"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Adds additional functionality
Projects
None yet
Development

No branches or pull requests

3 participants