-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
Support arkade get with tgz/zip archives #130
Conversation
Signed-off-by: Tuan Anh Tran <me@tuananh.org>
Thank you for your contribution. I've just checked and your commit doesn't appear to be signed-off. That's something we need before your Pull Request can be merged. Please see our contributing guide. |
…ade-get-tgz-zip Signed-off-by: Tuan Anh Tran <me@tuananh.org>
8adf5fa
to
d3bbe8d
Compare
pkg/get/get.go
Outdated
@@ -195,7 +196,8 @@ https://storage.googleapis.com/kubernetes-release/release/{{.Version}}/bin/{{$os | |||
Version: "v0.9.0", | |||
URLTemplate: `https://github.com/ahmetb/kubectx/releases/download/{{.Version}}/kubectx`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically this is now wrong as a URL if you are downloading the archive?
How about leaving this one as it is, and adding helm3 to the list of "get" tools instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd/get.go
Outdated
"github.com/spf13/cobra" | ||
) | ||
|
||
func IsArchive(url string) bool { | ||
return strings.HasSuffix(url, "tar.gz") || strings.HasSuffix(url, "zip") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't support .zip at this time. I would remove that code.
Also IsArchive
could be part of the Tool
type, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
if err != nil { | ||
t.Fatal(err) | ||
} | ||
want := "https://get.helm.sh/helm-v3.2.4-windows-amd64.zip" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the un-tar code really going to work with a zip?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My gut feeling is: no. However, there is a Go library that can uncompress zips -> https://golang.org/src/archive/zip/example_test.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be wrong here,
tar -xvf helm-v3.2.4-windows-amd64.zip
x windows-amd64/
x windows-amd64/helm.exe
x windows-amd64/README.md
x windows-amd64/LICENSE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bsdtar
can uncompress zip archives, but I would think the Golang tar code cannot. In any case using archive/zip for zips would be better suited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexellis you're right. it doesn't work with zip file. I add Unzip
function to deal with that.
Since i don't have a windows machine, I just hardcode a zip url and test . it's able to extract the zip files in the pic below
Signed-off-by: Tuan Anh Tran <me@tuananh.org>
482cc38
to
27dbd04
Compare
return err | ||
} | ||
reader := bytes.NewReader(buff.Bytes()) | ||
zipReader, err := zip.NewReader(reader, size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can improve the API here - for instance, let's pass in the bytes directly to the method and have it create the zip reader via the zip.NewReader call.
}() | ||
|
||
// Closure to address file descriptors issue with all the deferred .Close() methods | ||
extractAndWriteFile := func(f *zip.File) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you copy any of this code from stack overflow or another source like a blog post? If so please quote the URL here for crediting the author.
See #133 |
Signed-off-by: Tuan Anh Tran me@tuananh.org
Allow
arkade get
to download tgz/zip archivesThere are a few points I still need clarification.
tool.Name
. However, will there be case the cli name is different than the repo name? In that case, should I add a new fieldBinaryName
to the Tool struct and use that to pull the cli from the tgz/zip archive instead?kubectx
author is still recommending to use bash version.Description
Motivation and Context
Attempt to partially fix #123
How Has This Been Tested?
Right now, there's no tgz/zip tool so I manually change the url of
kubectx
to usetgz
format (hardcode download url tohttps://github.com/ahmetb/kubectx/releases/download/v0.9.0/kubectx_v0.9.0_darwin_x86_64.tar.gz
andNeedDecompress
totrue
during testing.Types of changes
Checklist:
git commit -s