DodoApp: Ingress can configure label and home path

Change-Id: I55b83f54f4aa10e6fcc74b08ea081c0f040829ac
diff --git a/core/installer/app_configs/app_global_env.cue b/core/installer/app_configs/app_global_env.cue
index 32cc63d..3841f02 100644
--- a/core/installer/app_configs/app_global_env.cue
+++ b/core/installer/app_configs/app_global_env.cue
@@ -43,6 +43,8 @@
 	auth: #Auth
 	network: #Network
 	subdomain: string
+	home: string | *""
+	label: string | *name
 	appRoot: string | *""
 	service: close({
 		name: string
@@ -131,6 +133,7 @@
 					// TODO(gio): Change type to cluster-gateway or sth similar.
 					"dodo.cloud/resource-type": "ingress"
 					"dodo.cloud/resource.ingress.host": "https://\(_clusterDomain)"
+					"dodo.cloud/internal": "true"
 				}
 				values: {
 					domain: _clusterDomain
@@ -162,6 +165,8 @@
 				annotations: {
 					"dodo.cloud/resource-type": "ingress"
 					"dodo.cloud/resource.ingress.host": "https://\(_domain)"
+					"dodo.cloud/resource.ingress.home": home
+					"dodo.cloud/resource.ingress.name": label
 				}
 				values: {
 					domain: _domain
@@ -192,6 +197,8 @@
 				annotations: {
 					"dodo.cloud/resource-type": "ingress"
 					"dodo.cloud/resource.ingress.host": "https://\(_domain)"
+					"dodo.cloud/resource.ingress.home": home
+					"dodo.cloud/resource.ingress.name": label
 				}
 				values: {
 					domain: _domain
diff --git a/core/installer/app_configs/dodo_app.cue b/core/installer/app_configs/dodo_app.cue
index ceb72c9..7e2b7bc 100644
--- a/core/installer/app_configs/dodo_app.cue
+++ b/core/installer/app_configs/dodo_app.cue
@@ -270,6 +270,7 @@
 		out: {
 			ingress: {
 				app: {
+					label: "App"
 					network: networks[strings.ToLower(_app.ingress.network)]
 					subdomain: _app.ingress.subdomain
 					auth: _app.ingress.auth
@@ -371,6 +372,7 @@
 		out: {
 			ingress: {
 				app: {
+					label: "App"
 					network: networks[strings.ToLower(_app.ingress.network)]
 					subdomain: _app.ingress.subdomain
 					auth: _app.ingress.auth
@@ -380,6 +382,8 @@
 					}
 				}
 				code: {
+					label: "VS Code"
+					home: "/?folder=/home/\(_app.dev.username)/code"
 					network: networks[strings.ToLower(_app.ingress.network)]
 					subdomain: "code-\(_app.ingress.subdomain)"
 					auth: enabled: false
diff --git a/core/installer/server/dodo-app/server.go b/core/installer/server/dodo-app/server.go
index f921a09..858afa8 100644
--- a/core/installer/server/dodo-app/server.go
+++ b/core/installer/server/dodo-app/server.go
@@ -12,6 +12,7 @@
 	"io/fs"
 	"net/http"
 	"slices"
+	"sort"
 	"strconv"
 	"strings"
 	"sync"
@@ -594,7 +595,9 @@
 }
 
 type ingress struct {
+	Name string
 	Host string
+	Home string
 }
 
 type vm struct {
@@ -1747,6 +1750,10 @@
 		if !ok {
 			continue
 		}
+		internal, ok := r.Annotations["dodo.cloud/internal"]
+		if ok && strings.ToLower(internal) == "true" {
+			continue
+		}
 		switch t {
 		case "volume":
 			name, ok := r.Annotations["dodo.cloud/resource.volume.name"]
@@ -1773,11 +1780,19 @@
 			}
 			ret.PostgreSQL = append(ret.PostgreSQL, postgresql{name, version, volume})
 		case "ingress":
+			name, ok := r.Annotations["dodo.cloud/resource.ingress.name"]
+			if !ok {
+				return resourceData{}, fmt.Errorf("no name")
+			}
+			home, ok := r.Annotations["dodo.cloud/resource.ingress.home"]
+			if !ok {
+				home = ""
+			}
 			host, ok := r.Annotations["dodo.cloud/resource.ingress.host"]
 			if !ok {
 				return resourceData{}, fmt.Errorf("no host")
 			}
-			ret.Ingress = append(ret.Ingress, ingress{host})
+			ret.Ingress = append(ret.Ingress, ingress{name, host, home})
 		case "virtual-machine":
 			name, ok := r.Annotations["dodo.cloud/resource.virtual-machine.name"]
 			if !ok {
@@ -1804,6 +1819,9 @@
 			fmt.Printf("Unknown resource: %+v\n", r.Annotations)
 		}
 	}
+	sort.Slice(ret.Ingress, func(i, j int) bool {
+		return strings.Compare(ret.Ingress[i].Name, ret.Ingress[j].Name) < 0
+	})
 	return ret, nil
 }
 
diff --git a/core/installer/server/dodo-app/templates/base.html b/core/installer/server/dodo-app/templates/base.html
index 9129c4d..eb3a9c3 100644
--- a/core/installer/server/dodo-app/templates/base.html
+++ b/core/installer/server/dodo-app/templates/base.html
@@ -24,8 +24,7 @@
 {{- if gt (len .Ingress) 0 -}}
 <h3>Ingress</h3>
 {{- range $i := .Ingress -}}
-Host: <a href="{{ $i.Host }}">{{ $i.Host }}</a><br/>
-<br/>
+{{ $i.Name }}: <a href="{{ $i.Host }}{{ $i.Home }}" target="_blank">{{ $i.Host }}</a><br/>
 {{- end -}}
 {{- end -}}
 {{- if gt (len .VirtualMachine) 0 -}}
diff --git a/core/installer/values-tmpl/dodo-app.cue b/core/installer/values-tmpl/dodo-app.cue
index 1c5939b..fe7e504 100644
--- a/core/installer/values-tmpl/dodo-app.cue
+++ b/core/installer/values-tmpl/dodo-app.cue
@@ -106,8 +106,8 @@
 				if !input.external {
 					enabled: true
 					noAuthPathPatterns: [
-						"^/static/.*$",
-						"^/schemas/.*$",
+						"^/static\/.*$",
+						"^/schemas\/.*$",
 						"^/api/public-data$",
 				    ]
 				}