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

feat(extensions): install from external registries #2968

Conversation

smallstepman
Copy link
Contributor

@smallstepman smallstepman commented Feb 13, 2023

Description

Modifies the extension install command to take a flag --registry that allows the registry to install from to be specified at runtime

dfx extension install foo --registry <other-compatibility.json>

Implements https://dfinity.atlassian.net/browse/SDK-963

How Has This Been Tested?

added e2e test

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@smallstepman smallstepman marked this pull request as ready for review March 2, 2023 17:43
@smallstepman smallstepman requested a review from a team as a code owner March 2, 2023 17:43
@smallstepman smallstepman marked this pull request as draft June 19, 2023 10:09
@smallstepman smallstepman marked this pull request as ready for review July 20, 2023 14:28
@smallstepman smallstepman force-pushed the SDK-963-enable-multiple-extension-registries-to-be-defined-for-dfx-extensions branch from 3d49880 to da6b933 Compare July 20, 2023 16:17
@smallstepman smallstepman force-pushed the SDK-963-enable-multiple-extension-registries-to-be-defined-for-dfx-extensions branch from 5b1007f to 9d6b445 Compare July 20, 2023 18:38
@smallstepman smallstepman force-pushed the SDK-963-enable-multiple-extension-registries-to-be-defined-for-dfx-extensions branch from 007d9df to e6f5e1b Compare July 20, 2023 19:09
.context("Unable to read input")?;
let input_string = input_string.trim_end();
if input_string != "yes" {
bail!("Refusing to install canister without approval");
Copy link
Member

Choose a reason for hiding this comment

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

This message doesn't match the context (installing an extension)

# strip semver suffix
DFX_VERSION=$(dfx --version | sed 's/-.*//' | cut -d ' ' -f 2)
# find unoocupied port
port=49152

Choose a reason for hiding this comment

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

See start_webserver, stop_webserver

Example usage: https://github.com/dfinity/sdk/blob/master/e2e/tests-dfx/deps.bash#L24

Comment on lines +15 to +78
The registry file is a JSON file that contains a list of extensions. Here is an example:

```json
{
"compatibility": {
"0.15.0": {
"your_extension": {
"versions": ["0.1.0"]
}
}
},
"extensions": {
"your_extension": {
"0.1.0": {
"homepage": "https://github.com/your-org/your-repo",
"authors": "Your Org",
"summary": "Your extension",
"categories": ["development"],
"keywords": ["cli-helper"],
"description": "A longer description.",
"subcommands": {
"do_something": {
"about": "does something",
"args": {
"the_param": {
"about": "some paramater",
"long": "the-param"
}
}
}
},
"binaries": {
"unknown-linux-gnu-x86_64": {
"url": "https://raw.githubusercontent.com/your-org/your-repo/master/your_extension-v0.1.0-x86_64-unknown-linux-gnu.tar.gz",
"sha256": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
},
"apple-darwin-x86_64": {
"url": "https://raw.githubusercontent.com/your-org/your-repo/master/your_extension-v0.1.0-x86_64-apple-darwin.tar.gz ",
"sha256": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
},
"apple-darwin-aarch64": {
"url": "https://raw.githubusercontent.com/your-org/your-repo/master/your_extension-v0.1.0-aarch64-apple-darwin.tar.gz ",
"sha256": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
}
}
}
}
}
}
```

The extension must be published as a tarball (`.tag.gz`), which contains a directory named `<EXTENSION_NAME>-v<EXTENSION_VERSION>-<CPU_ARCHITECTURE>-<PLATFORM>`, which contains a binary named `<EXTENSION_NAME>`, here is minimal example:

```bash
mkdir test_extension-v0.1.0-x86_64-unknown-linux-gnu
cat > test_extension-v0.1.0-x86_64-unknown-linux-gnu/test_extension << "EOF"
#!/usr/bin/env bash

echo Hello, World!
EOF
tar -czf test_extension-v0.1.0-x86_64-unknown-linux-gnu.tar.gz test_extension-v0.1.0-x86_64-unknown-linux-gnu
# you'll also need to generate a sha256 hash of the tarball and put it into the registry file
shasum -a 256 test_extension-v0.1.0-x86_64-unknown-linux-gnu.tar.gz
```

Choose a reason for hiding this comment

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

This is a little too much to put in the dfx changelog. A better place for it would be a document in https://github.com/dfinity/dfx-extensions/docs which describes how to set up your own extension registry and publish extensions from it. Then, we can link to that document from here.

@@ -4,6 +4,80 @@

## DFX

### feat: dfx extension can now be installed from external registries

Modifies the `dfx extension install` command to take a flag `--registry` that allows installing extensions from external registries. Here is an example:

Choose a reason for hiding this comment

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

Suggestion:

The dfx extension install command now supports --registry <url to registry json> for installing an extension from an external registry. Example usage:

dfx extension install your_extension --registry https://raw.githubusercontent.com/your-org/your-repo/master/dfx-extensions-registry.json

For more information about hosting external registries, please see https://github.com/dfinity/dfx-extensions/docs/hosting-external-registries.md

}
Ok(())
}
}

fn process_external_registry_manifest(

Choose a reason for hiding this comment

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

Would you please explain the rationale for having a different scheme for storing/obtaining the manifest for external registries vs the the dfx-extensions repo?

Choose a reason for hiding this comment

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

I see in the PR description

dfx extension install foo --registry https://github.com/org/repo/other-compatibility.json

which seems like it was closer to what's going on in dfx-extensions. What didn't work out with that?

Copy link
Contributor Author

@smallstepman smallstepman Jul 20, 2023

Choose a reason for hiding this comment

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

Sure, tho I'm not sure if I completely understand the question, but... the manifest from dfinity/dfx-extensions is of a different format than the one specified by the external manifest. As specified in design doc:

In order for extensions stored in external repositories to be consumable by dfx, the repository maintainers must provide a URL to a JSON file with the following structure. This file is an amalgamation of the compatibility.json file and the combined manifest.json extension.json files for each individual extension, as they exist in the DFINITY extension repository.

Here are some of the differences

dfinity/dfx-extensions external registry
checksum well-known location: https://github.com/dfinity/dfx-extensions/releases/<GIT_TAG>/downloads/<ARCHIVE_FILENAME>.sha256 supplied in registry file
tarball download url well-known location: https://github.com/dfinity/dfx-extensions/releases/<GIT_TAG>/downloads/<ARCHIVE_FILENAME> supplied in registry file
supported arch/platform all platforms supported by dfx are supported by official extensions determined by fetching value of .extensions.<EXT>.<VER>.binaries.<ARCH-PLATFORM> from registry file, if key is missing then platform is not supported
extension.json unpacked from tarball extracted from registry file

To process both DFINITY extensions and external extensions using the same logic, would mean that we require extension developers to use only GitHub and mimic dfinity/dfx-extensions release process

@ericswanson-dfinity ericswanson-dfinity deleted the SDK-963-enable-multiple-extension-registries-to-be-defined-for-dfx-extensions branch May 6, 2024 21:37
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