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

Base ISO cache file name on the full ISO URL #18723

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/minikube/download/iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package download

import (
"crypto/sha1"
"fmt"
"net/url"
"os"
Expand Down Expand Up @@ -77,7 +78,10 @@ func localISOPath(u *url.URL) string {
return u.String()
}

return filepath.Join(detect.ISOCacheDir(), path.Base(u.Path))
urlHash := sha1.Sum([]byte(u.String()))
fileName := fmt.Sprintf("%s-%040x", path.Base(u.Path), urlHash)
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes the iso file name a little bit ugly to support questionable API of a single application. The common way to publish downloads is to provide a URL ending with the filename, so the current behavior makes sense.

Since the image name always end with .iso or .ISO, and the file name is likely to be in the URL even in gitlab, can be search back the URL components and take the first component ending with .(iso|ISO) as the file name?

Or, maybe apply this behavior only if the URL does not end with .(iso|ISO)? This way this change helps gitlab users, without affecting other users.

Also did you open a bug for gitlab to provide a better URL? This /download URL will cause trouble for other tools, for example what do you get with curl -O?

Copy link
Contributor

Choose a reason for hiding this comment

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

Another way to solve this, add --iso-filename option. When set, using --iso-url will store the iso using the filename specified in --iso-filename. With this if you download the iso from a system that does not provide the common url with meaningful file name at the end, you can control the stored file name.


return filepath.Join(detect.ISOCacheDir(), fileName)
}

// ISO downloads and returns the path to the downloaded ISO
Expand Down