Allow using URL as archive source when creating functions (#1360)

In the case of large files, it takes a long time for the user to download
the source from the URL and upload it to StorgeSvc through CLI.

This PR allows a user to use URL as the function source when creating a function
and provides a new flag "--keeparchiveurl" to let the user to decided
whether the CLI should download the file first or store the file URL in the
archive directly. If "--keeparchiveurl" is true, then no checksum will be
generated, it's the user's responsibility to ensure the file won't be changed.
This commit is contained in:
Ta-Ching Chen
2019-10-28 22:37:13 +08:00
committed by GitHub
parent 52b5cb0902
commit d20dc9aa64
13 changed files with 299 additions and 84 deletions
+2 -2
View File
@@ -281,7 +281,7 @@ func applyArchives(fclient *client.Client, specDir string, fr *FissionResources)
fmt.Printf("uploading archive %v\n", name)
// ar.URL is actually a local filename at this stage
ctx := context.Background()
uploadedAr, err := pkgutil.UploadArchive(ctx, fclient, ar.URL)
uploadedAr, err := pkgutil.UploadArchiveFile(ctx, fclient, ar.URL)
if err != nil {
return err
}
@@ -461,7 +461,7 @@ func localArchiveFromSpec(specDir string, aus *spectypes.ArchiveUploadSpec) (*fv
}, nil
} else {
// checksum
csum, err := utils.FileChecksum(archiveFileName)
csum, err := utils.GetFileChecksum(archiveFileName)
if err != nil {
return nil, fmt.Errorf("failed to calculate archive checksum for %v (%v): %v", aus.Name, archiveFileName, err)
}