summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorEirik Nygaard <eirik.nygaard@yahooinc.com>2022-03-01 13:13:39 +0100
committerEirik Nygaard <eirik.nygaard@yahooinc.com>2022-03-01 19:00:43 +0100
commite6613f36c429d0c1a733fca73b2c104bf7bc7103 (patch)
tree0802102d80f6fac1764794835a00241a967e2115 /client
parentabdcb942d907c44e263d808178c6dbad4cf6e567 (diff)
avoid duplicating paths
Diffstat (limited to 'client')
-rw-r--r--client/go/vespa/application.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/client/go/vespa/application.go b/client/go/vespa/application.go
index 6ebf4b4478f..28643515906 100644
--- a/client/go/vespa/application.go
+++ b/client/go/vespa/application.go
@@ -132,6 +132,7 @@ func (ap *ApplicationPackage) zipReader(test bool) (io.ReadCloser, error) {
defer func() {
tempZip.Close()
os.Remove(tempZip.Name())
+ // TODO: Caller must remove temporary file
}()
if err := zipDir(zipFile, tempZip.Name()); err != nil {
return nil, err
@@ -153,25 +154,23 @@ func FindApplicationPackage(zipOrDir string, requirePackaging bool) (Application
if util.PathExists(filepath.Join(zipOrDir, "pom.xml")) {
zip := filepath.Join(zipOrDir, "target", "application.zip")
if util.PathExists(zip) {
- testZip := filepath.Join(zipOrDir, "target", "application-test.zip")
- if !util.PathExists(testZip) {
- testZip = ""
+ if testZip := filepath.Join(zipOrDir, "target", "application-test.zip"); util.PathExists(testZip) {
+ return ApplicationPackage{Path: zip, TestPath: testZip}, nil
}
- return ApplicationPackage{Path: zip, TestPath: testZip}, nil
+ return ApplicationPackage{Path: zip}, nil
}
if requirePackaging {
return ApplicationPackage{}, errors.New("pom.xml exists but no target/application.zip. Run mvn package first")
}
}
- if util.PathExists(filepath.Join(zipOrDir, "src", "main", "application")) {
- if util.PathExists(filepath.Join(zipOrDir, "src", "test", "application")) {
- return ApplicationPackage{Path: filepath.Join(zipOrDir, "src", "main", "application"),
- TestPath: filepath.Join(zipOrDir, "src", "test", "application")}, nil
+ if path := filepath.Join(zipOrDir, "src", "main", "application"); util.PathExists(path) {
+ if testPath := filepath.Join(zipOrDir, "src", "test", "application"); util.PathExists(testPath) {
+ return ApplicationPackage{Path: path, TestPath: testPath}, nil
}
- return ApplicationPackage{Path: filepath.Join(zipOrDir, "src", "main", "application")}, nil
+ return ApplicationPackage{Path: path}, nil
}
if util.PathExists(filepath.Join(zipOrDir, "services.xml")) {
return ApplicationPackage{Path: zipOrDir}, nil
}
- return ApplicationPackage{}, errors.New("Could not find an application package source in '" + zipOrDir + "'")
+ return ApplicationPackage{}, fmt.Errorf("could not find an application package source in '%s'", zipOrDir)
}