DodoApp: Return env vars on install/update
Pass service namespace as env var as well.
Fix llm-api-key flag.
Change-Id: Iff8c845c4a1b62eb4940463a62eb32487abd5992
diff --git a/core/installer/app.go b/core/installer/app.go
index f9d3bc0..9719134 100644
--- a/core/installer/app.go
+++ b/core/installer/app.go
@@ -135,6 +135,11 @@
Password string `json:"password"`
}
+type EnvVar struct {
+ Name string `json:"name"`
+ Value string `json:"value"`
+}
+
type rendered struct {
Name string
Readme string
@@ -150,6 +155,7 @@
Help []HelpDocument
Icon string
Access []Access
+ EnvVars []EnvVar
Raw []byte
}
@@ -475,6 +481,19 @@
return rendered{}, err
}
{
+ envVars := []string{}
+ if err := res.LookupPath(cue.ParsePath("envVars")).Decode(&envVars); err != nil {
+ return rendered{}, err
+ }
+ for _, ev := range envVars {
+ items := strings.SplitN(ev, "=", 2)
+ if len(items) != 2 {
+ panic(ev)
+ }
+ ret.EnvVars = append(ret.EnvVars, EnvVar{items[0], items[1]})
+ }
+ }
+ {
charts := res.LookupPath(cue.ParsePath("output.charts"))
i, err := charts.Fields()
if err != nil {
diff --git a/core/installer/app_configs/app_base.cue b/core/installer/app_configs/app_base.cue
index ad701e8..f2a17bd 100644
--- a/core/installer/app_configs/app_base.cue
+++ b/core/installer/app_configs/app_base.cue
@@ -1298,3 +1298,5 @@
kubeconfig: out.cluster.kubeconfig
}]
}
+
+envVars: [...string] | *[]
diff --git a/core/installer/app_configs/dodo_app.cue b/core/installer/app_configs/dodo_app.cue
index c763d4b..0ce8baa 100644
--- a/core/installer/app_configs/dodo_app.cue
+++ b/core/installer/app_configs/dodo_app.cue
@@ -93,6 +93,7 @@
_service: service
envVars: [
+ "DODO_SERVICE_DOMAIN=svc.\(release.namespace).cluster.local",
for v in out.volume {
"DODO_VOLUME_\(strings.ToUpper(v.name))=/dodo/volume/\(v.name)"
},
@@ -555,7 +556,7 @@
_sessionId: input["sketch_\(name)_session_id"]
runConfiguration: [{
- bin: "sketch -verbose -unsafe -skaband-addr=\"\" -addr=\"0.0.0.0:2001\" -model=\(model.name) -llm-api-key=\"(_llmApiKey)\" -session-id=\"\(_sessionId)\""
+ bin: "sketch -verbose -unsafe -skaband-addr=\"\" -addr=\"0.0.0.0:2001\" -model=\(model.name) -llm-api-key=\"\(_llmApiKey)\" -session-id=\"\(_sessionId)\""
env: lastCmdEnv
}]
}
diff --git a/core/installer/app_manager.go b/core/installer/app_manager.go
index eee4841..e090a47 100644
--- a/core/installer/app_manager.go
+++ b/core/installer/app_manager.go
@@ -334,6 +334,7 @@
Release Release
Helm []Resource
Access []Access
+ EnvVars []EnvVar
RenderedRaw []byte
}
@@ -578,6 +579,7 @@
RenderedRaw: rendered.Raw,
Access: rendered.Access,
Helm: extractHelm(rendered.Resources),
+ EnvVars: rendered.EnvVars,
}, nil
}
@@ -805,6 +807,7 @@
RenderedRaw: rendered.Raw,
Access: rendered.Access,
Helm: extractHelm(rendered.Resources),
+ EnvVars: rendered.EnvVars,
}, nil
}
diff --git a/core/installer/server/appmanager/server.go b/core/installer/server/appmanager/server.go
index ffa710c..3b5d5b5 100644
--- a/core/installer/server/appmanager/server.go
+++ b/core/installer/server/appmanager/server.go
@@ -173,6 +173,7 @@
Id string `json:"id"`
DeployKey string `json:"deployKey"`
Access []installer.Access `json:"access"`
+ EnvVars []installer.EnvVar `json:"envVars"`
}
type dodoAppRendered struct {
@@ -226,6 +227,7 @@
Id: instanceId,
DeployKey: cfg.Input.Key.Public,
Access: rr.Access,
+ EnvVars: rr.EnvVars,
}); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
@@ -295,6 +297,7 @@
Id: instanceId,
DeployKey: rend.Input.Key.Public,
Access: rr.Access,
+ EnvVars: rr.EnvVars,
}); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}