Skip to content

Commit

Permalink
fix packager.HandleIfURL() tempPath early deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-mccoy committed Feb 8, 2022
1 parent 486735c commit bb1008a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion cli/cmd/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ var packageDeployCmd = &cobra.Command{
Short: "Deploys an update package from a local file or URL (runs offline)",
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
var done func()
packageName := choosePackage(args)
config.DeployOptions.PackagePath = packager.HandleIfURL(packageName, shasum, insecureDeploy)
config.DeployOptions.PackagePath, done = packager.HandleIfURL(packageName, shasum, insecureDeploy)
defer done()
packager.Deploy()
},
}
Expand Down
6 changes: 3 additions & 3 deletions cli/internal/packager/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ func getValidComponents(allComponents []types.ZarfComponent, requestedComponentN
}

// HandleIfURL If provided package is a URL download it to a temp directory
func HandleIfURL(packagePath string, shasum string, insecureDeploy bool) string {
func HandleIfURL(packagePath string, shasum string, insecureDeploy bool) (string, func()) {
// Check if the user gave us a remote package
providedURL, err := url.Parse(packagePath)
if err != nil || providedURL.Scheme == "" || providedURL.Host == "" {
return packagePath
return packagePath, func() {}
}

if !insecureDeploy && shasum == "" {
Expand Down Expand Up @@ -198,7 +198,7 @@ func HandleIfURL(packagePath string, shasum string, insecureDeploy bool) string
}
}

return localPackagePath
return localPackagePath, tempPath.clean
}

func isValidFileExtension(filename string) bool {
Expand Down

0 comments on commit bb1008a

Please sign in to comment.