mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-18 16:06:02 +02:00
* Fix #3032: Remove query parameters in ADD command when the destination is a directory * fixing linter URL sorry forget to lint * add error in extractFilename and realize that ResolveEnvironmentReplacement better execute before getting the filename
This commit is contained in:
@@ -216,11 +216,17 @@ func URLDestinationFilepath(rawurl, dest, cwd string, envs []string) (string, er
|
||||
}
|
||||
return dest, nil
|
||||
}
|
||||
urlBase := filepath.Base(rawurl)
|
||||
urlBase, err := ResolveEnvironmentReplacement(urlBase, envs, true)
|
||||
|
||||
urlBase, err := ResolveEnvironmentReplacement(rawurl, envs, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
urlBase, err = extractFilename(urlBase)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
destPath := filepath.Join(dest, urlBase)
|
||||
|
||||
if !filepath.IsAbs(dest) {
|
||||
@@ -470,3 +476,13 @@ func getUID(userStr string) (uint32, error) {
|
||||
}
|
||||
return uint32(uid), nil
|
||||
}
|
||||
|
||||
// ExtractFilename extracts the filename from a URL without its query url
|
||||
func extractFilename(rawURL string) (string, error) {
|
||||
parsedURL, err := url.Parse(rawURL)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
filename := filepath.Base(parsedURL.Path)
|
||||
return filename, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user