github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/actor/v7pushaction/handle_app_path_override.go (about) 1 package v7pushaction 2 3 import ( 4 "os" 5 "path/filepath" 6 7 "code.cloudfoundry.org/cli/command/translatableerror" 8 "code.cloudfoundry.org/cli/util/manifestparser" 9 ) 10 11 // Overrides the path if path is given. Changes empty paths to pwd. Validates paths 12 func HandleAppPathOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { 13 if overrides.ProvidedAppPath != "" { 14 if manifest.ContainsMultipleApps() { 15 return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} 16 } 17 18 app := manifest.GetFirstApp() 19 20 if app.Docker != nil { 21 return manifest, translatableerror.ArgumentManifestMismatchError{ 22 Arg: "--path, -p", 23 ManifestProperty: "docker", 24 } 25 } 26 27 app.Path = overrides.ProvidedAppPath 28 } 29 30 for i := range manifest.Applications { 31 if manifest.Applications[i].Path == "" { 32 continue 33 } 34 35 var finalPath = manifest.Applications[i].Path 36 if !filepath.IsAbs(finalPath) && overrides.ProvidedAppPath == "" { 37 finalPath = filepath.Join(filepath.Dir(manifest.PathToManifest), finalPath) 38 } 39 40 finalPathNoLinks, err := filepath.EvalSymlinks(finalPath) 41 42 if err != nil { 43 if os.IsNotExist(err) { 44 return manifest, manifestparser.InvalidManifestApplicationPathError{ 45 Path: finalPath, 46 } 47 } 48 49 return manifest, err 50 } 51 52 manifest.Applications[i].Path = finalPathNoLinks 53 } 54 55 return manifest, nil 56 }