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

moved the keyring functions back into warg_client #275

Merged
merged 3 commits into from
May 9, 2024

Conversation

calvinrp
Copy link
Collaborator

@calvinrp calvinrp commented May 9, 2024

This allows us to have a simpler FileSystemClient::new_with_default_config() that gets the expected auth_token.

Would simplify bytecodealliance/cargo-component#288, bytecodealliance/wac#103, bytecodealliance/wasm-pkg-tools#6, esoterra/wow#3

This:

        let config = warg_client::Config::from_default_file()?.unwrap_or_default();
        let url = url.or(config.home_url.as_deref());
        let auth_token = if config.keyring_auth && url.is_some() {
            get_auth_token(&RegistryUrl::new(url.unwrap())?)?
        } else {
            None
        };
        Ok(Self {
            client: FileSystemClient::new_with_config(url, &config, auth_token)?,
        })

would change to:

        Ok(Self {
            client: FileSystemClient::new_with_default_config(url)?,
        })

@calvinrp calvinrp requested review from lann and macovedj May 9, 2024 12:55
Copy link
Collaborator

@lann lann left a comment

Choose a reason for hiding this comment

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

Partial review; I suspect this won't compile with cargo build --no-default-features

postgres = ["warg-server/postgres"]
cli-interactive = ["warg-client/cli-interactive"]
keyring = ["warg-client/keyring"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know that we actually need to make this optional for the binary do we? Actually, I didn't really think about this until now: it probably doesn't make sense to have any of these features; what does the postgres feature even mean here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The postgres feature is for the warg-server switches between using an in-memory vs Postgres backing when setting the feature flag. That probably still makes sense for now.

The other keyring and cli-interactive features might make sense to have the option of compiling without those implementations in the warg-client.

Copy link
Collaborator

Choose a reason for hiding this comment

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

These features are just for the crate defined in this file: warg-cli

Copy link
Collaborator Author

@calvinrp calvinrp May 9, 2024

Choose a reason for hiding this comment

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

Ah, you mean we can drop postgres feature in the top-level Cargo.toml but keep it in the crates/server/Cargo.toml?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, most of the root Cargo.toml is (somewhat confusingly) completely independent of other workspace members.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removing postgres from the top-level Cargo.toml appears to affect how I run tests. It might affect the test runner, but would need to double check. But doesn't seem urgent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the time being, we might want to keep the top-level postgres feature. The test runner is setup expecting it. https://github.com/bytecodealliance/registry/blob/main/ci/run-postgres-tests.sh#L26

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok; are the keyring and cli-interactive features needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, in theory, if you don't want those features, it will be useful to have them behind a feature flag. But not entirely sure.

crates/client/src/lib.rs Outdated Show resolved Hide resolved
postgres = ["warg-server/postgres"]
cli-interactive = ["warg-client/cli-interactive"]
keyring = ["warg-client/keyring"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok; are the keyring and cli-interactive features needed?

@calvinrp calvinrp merged commit 0c96ff7 into bytecodealliance:main May 9, 2024
6 checks passed
@calvinrp calvinrp deleted the simplify-creds branch May 9, 2024 19:28
path = path.display()
);
let client =
match FileSystemClient::try_new_with_config(self.registry.as_deref(), config, None)? {
Copy link
Contributor

Choose a reason for hiding this comment

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

Was it intentional that you're now passing None for the auth token (and that you deleted the now-unused auth_token method below)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I was trying to simplify the burden on external crates getting the correct auth_token. So None gets the correct one, https://github.com/bytecodealliance/registry/blob/main/crates/client/src/lib.rs#L1403-L1405

Also, introduced new_with_default_config() to simplify, https://github.com/bytecodealliance/registry/blob/main/crates/client/src/lib.rs#L1428-L1430

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.

3 participants