DodoApp: Implement branch and app delete functionalities.

Change-Id: I8bf6ed30a6274203e73e80f05a4b82896509ecb0
diff --git a/core/installer/app_manager.go b/core/installer/app_manager.go
index 9b28004..4ed21f4 100644
--- a/core/installer/app_manager.go
+++ b/core/installer/app_manager.go
@@ -692,13 +692,28 @@
 		}
 		cfg = renderedCfg
 		r.RemoveAll(instanceDir)
-		kustPath := filepath.Join(m.appDirRoot, "kustomization.yaml")
-		kust, err := soft.ReadKustomization(r, kustPath)
-		if err != nil {
-			return "", err
+		prev := ""
+		curr := instanceDir
+		for prev != curr {
+			p := filepath.Dir(curr)
+			n := filepath.Base(curr)
+			kustPath := filepath.Join(p, "kustomization.yaml")
+			kust, err := soft.ReadKustomization(r, kustPath)
+			if err != nil {
+				return "", err
+			}
+			kust.RemoveResources(n)
+			if len(kust.Resources) > 0 {
+				soft.WriteYaml(r, kustPath, kust)
+				break
+			} else {
+				if err := r.RemoveAll(kustPath); err != nil {
+					return "", err
+				}
+			}
+			prev = curr
+			curr = p
 		}
-		kust.RemoveResources(instanceId)
-		soft.WriteYaml(r, kustPath, kust)
 		return fmt.Sprintf("uninstall: %s", instanceId), nil
 	}); err != nil {
 		return err