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

Install templates from remote tarball #2957

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

itowlson
Copy link
Contributor

Fixes #2955.

$ rm -rf ~/.local/share/spin/templates/
$ spin templates install --tar https://github.com/fermyon/spin/archive/refs/tags/v3.0.0.tar.gz
Copying remote template source
Installing template http-go...
Installing template redis-go...
Installing template http-grain...
Installing template http-empty...
Installing template redis-rust...
Installing template static-fileserver...
Installing template http-rust...
Installing template http-zig...
Installing template redirect...
Installing template http-c...
Installing template http-php...
Installed 11 template(s)

+------------------------------------------------------------------------+
| Name                Description                                        |
+========================================================================+
| http-c              HTTP request handler using C and the Zig toolchain |
| http-empty          HTTP application with no components                |
| http-go             HTTP request handler using (Tiny)Go                |
| http-grain          HTTP request handler using Grain                   |
| http-php            HTTP request handler using PHP                     |
| http-rust           HTTP request handler using Rust                    |
| http-zig            HTTP request handler using Zig                     |
| redirect            Redirects a HTTP route                             |
| redis-go            Redis message handler using (Tiny)Go               |
| redis-rust          Redis message handler using Rust                   |
| static-fileserver   Serves static files from an asset directory        |
+------------------------------------------------------------------------+

Copy link
Collaborator

@rylev rylev left a comment

Choose a reason for hiding this comment

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

I have some nits that I'd love to see addressed, but nothing is blocking.

crates/templates/src/source.rs Outdated Show resolved Hide resolved
src/commands/templates.rs Outdated Show resolved Hide resolved
@@ -192,6 +203,84 @@ async fn check_local(path: &Path) -> anyhow::Result<LocalTemplateSource> {
}
}

async fn download_untar_local(url: &Url) -> anyhow::Result<LocalTemplateSource> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this make sense as a function on LocalTemplateSource? Like LocalTemplateSource::from_remote_tarball? Then you can leave a doc comment outlining that it downloads the tarball to a temp dir.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other "pull down a remote source" functions are free, so I've followed the same pattern for now. We can change them all to methods in a separate refactoring pass if we prefer that. In the meantime I've added the doc comment.

@itowlson itowlson force-pushed the templates-install-from-remote-tar branch from a9da922 to d3247ba Compare December 16, 2024 18:43
@itowlson itowlson force-pushed the templates-install-from-remote-tar branch from d3247ba to a6c2f94 Compare December 16, 2024 22:04
@itowlson itowlson enabled auto-merge December 16, 2024 22:06
@itowlson itowlson merged commit 6e9883e into fermyon:main Dec 16, 2024
17 checks passed
jandubois added a commit to jandubois/rancher-desktop that referenced this pull request Dec 19, 2024
jandubois added a commit to jandubois/rancher-desktop that referenced this pull request Dec 20, 2024
Ref fermyon/spin#2957

Signed-off-by: Jan Dubois <[email protected]>
(cherry picked from commit 6a7a7f5)
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.

Install templates from a remote tarball
2 participants