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

Added a WasmerEnv abstraction to the CLI #4013

Merged
merged 4 commits into from
Jun 21, 2023
Merged

Added a WasmerEnv abstraction to the CLI #4013

merged 4 commits into from
Jun 21, 2023

Conversation

Michael-F-Bryan
Copy link
Contributor

@Michael-F-Bryan Michael-F-Bryan commented Jun 20, 2023

This adds a WasmerEnv struct which abstracts over $WASMER_DIR and config used to communicate with the registry (i.e. graphql endpoint and tokens).

Now, whenever you run a command that interacts with the registry in some way, you should always be able to use the $WASMER_DIR, $WASMER_REGISTRY, and $WASMER_TOKEN environment variables or their associated command-line arguments.

This makes the handling of things like $WASMER_DIR, --token, and --registry consistent across all our subcommands.

Fixes #3993, fixes #3959.

@Michael-F-Bryan Michael-F-Bryan marked this pull request as ready for review June 20, 2023 11:38
@syrusakbary
Copy link
Member

This PR made me super confused.

I think this PR is more complicated than it should. It also ties the WASMER_TOKEN into a Wasmer dir? I don't think this make much sense, what am I missing?

@Michael-F-Bryan
Copy link
Contributor Author

Michael-F-Bryan commented Jun 20, 2023

WasmerDir is a bad name so I've renamed it to WasmerEnv. The $WASMER_TOKEN is actually pretty coupled to $WASMER_DIR and $WASMER_REGISTRY because we want to go through the global config when the $WASMER_TOKEN environment variable isn't set.

It may feel overcomplicated, but we want to have a proper abstraction for working with the $WASMER_DIR and tokens and all that. We currently have about 10 different versions of --token or --registry, all with slightly different behaviours, fallbacks, sometimes one command will respect environment variables while another command won't, etc. This PR is fixing those inconsistencies by extracting the logic into its own component.

@Michael-F-Bryan Michael-F-Bryan changed the title Added a WasmerDir abstraction to the CLI Added a WasmerEnv abstraction to the CLI Jun 20, 2023
Copy link
Contributor

@theduke theduke left a comment

Choose a reason for hiding this comment

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

Love it.

The Edge CLI followed a very similar approach.

Left a few comments/discussion points.

lib/cli/src/commands/login.rs Show resolved Hide resolved
lib/cli/src/wasmer_env.rs Outdated Show resolved Hide resolved
lib/cli/src/wasmer_env.rs Outdated Show resolved Hide resolved
lib/cli/src/wasmer_env.rs Outdated Show resolved Hide resolved
lib/cli/src/wasmer_env.rs Outdated Show resolved Hide resolved
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.

Unable to Publish Package with WASMER_TOKEN env var wasmer login does not respect the registry.url config
4 participants