cos-gpu-installer: Add support for signed URL of installer
Change-Id: Ie36148ad2fb01d8aa4af7f70ed6ce7c23a1c4bba
Reviewed-on: https://cos-review.googlesource.com/c/cos/tools/+/23790
Cloud-Build: GCB Service account <228075978874@cloudbuild.gserviceaccount.com>
Reviewed-by: Arnav Kansal <rnv@google.com>
Tested-by: Arnav Kansal <rnv@google.com>
diff --git a/src/cmd/cos_gpu_installer/internal/installer/installer.go b/src/cmd/cos_gpu_installer/internal/installer/installer.go
index fb05ddd..3e742ba 100644
--- a/src/cmd/cos_gpu_installer/internal/installer/installer.go
+++ b/src/cmd/cos_gpu_installer/internal/installer/installer.go
@@ -29,6 +29,7 @@
latestGPUDriverFile = "gpu_latest_version"
precompiledInstallerURLFormat = "https://storage.googleapis.com/nvidia-drivers-%s-public/nvidia-cos-project/%s/tesla/%s_00/%s/NVIDIA-Linux-x86_64-%s_%s-%s.cos"
defaultFilePermission = 0755
+ signedURLKey = "Expires"
)
var (
@@ -78,7 +79,7 @@
// DownloadToInstallDir downloads data from the provided URL to the GPU
// installation directory. It returns the basename of the locally written file.
func DownloadToInstallDir(url, infoStr string) (string, error) {
- outputPath := filepath.Join(gpuInstallDirContainer, path.Base(url))
+ outputPath := filepath.Join(gpuInstallDirContainer, strings.Split(path.Base(url), "?"+signedURLKey+"=")[0])
if err := utils.DownloadContentFromURL(url, outputPath, infoStr); err != nil {
return "", fmt.Errorf("failed to download file with description %q from %q and install into %q: %v", infoStr, url, gpuInstallDirContainer, err)
}