fix: env vars хранятся в аннотации fission-console/env-vars (не в spec.runtime)
spec.runtime.container.env срезается CRD-схемой Fission. Хранение перенесено в аннотацию fission-console/env-vars (JSON-массив). Версия v1.3.73
This commit is contained in:
@@ -55,7 +55,7 @@ spec:
|
||||
serviceAccountName: fission-console
|
||||
containers:
|
||||
- name: console
|
||||
image: naeel/fission-console:v1.3.72
|
||||
image: naeel/fission-console:v1.3.73
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 8090
|
||||
|
||||
@@ -308,7 +308,7 @@ func (s *Server) handleGetFunctionEnvVars(w http.ResponseWriter, r *http.Request
|
||||
writeAnyJSON(w, http.StatusOK, map[string]any{"env_vars": envVars})
|
||||
}
|
||||
|
||||
// handlePutFunctionEnvVars обновляет переменные окружения функции в .spec.runtime.container.env
|
||||
// handlePutFunctionEnvVars обновляет переменные окружения функции в аннотации fission-console/env-vars (JSON)
|
||||
func (s *Server) handlePutFunctionEnvVars(w http.ResponseWriter, r *http.Request, name string) {
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)
|
||||
defer cancel()
|
||||
@@ -341,18 +341,10 @@ func (s *Server) handlePutFunctionEnvVars(w http.ResponseWriter, r *http.Request
|
||||
return
|
||||
}
|
||||
|
||||
// Формируем список [{name: ..., value: ...}] для .spec.runtime.container.env
|
||||
envList := make([]any, 0, len(req.EnvVars))
|
||||
for _, ev := range req.EnvVars {
|
||||
envList = append(envList, map[string]any{
|
||||
"name": ev["name"],
|
||||
"value": ev["value"],
|
||||
})
|
||||
}
|
||||
|
||||
// Устанавливаем .spec.runtime.container.env
|
||||
if err := unstructured.SetNestedSlice(fn.Object, envList, "spec", "runtime", "container", "env"); err != nil {
|
||||
writeJSONError(w, http.StatusInternalServerError, fmt.Sprintf("set env vars: %v", err))
|
||||
// Сериализуем в JSON для аннотации
|
||||
envJSON, err := json.Marshal(req.EnvVars)
|
||||
if err != nil {
|
||||
writeJSONError(w, http.StatusInternalServerError, fmt.Sprintf("marshal env vars: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -363,6 +355,7 @@ func (s *Server) handlePutFunctionEnvVars(w http.ResponseWriter, r *http.Request
|
||||
ann = map[string]string{}
|
||||
}
|
||||
ann[functionUpdatedAtAnnotation] = now
|
||||
ann["fission-console/env-vars"] = string(envJSON)
|
||||
fn.SetAnnotations(ann)
|
||||
|
||||
if _, err := s.dyn.Resource(fission.FunctionGVR).Namespace(ns).Update(ctx, fn, metav1.UpdateOptions{}); err != nil {
|
||||
@@ -373,23 +366,20 @@ func (s *Server) handlePutFunctionEnvVars(w http.ResponseWriter, r *http.Request
|
||||
writeAnyJSON(w, http.StatusOK, map[string]any{"updated": true, "count": len(req.EnvVars)})
|
||||
}
|
||||
|
||||
// extractEnvVars читает .spec.runtime.container.env из Function CRD и возвращает [{name, value}, ...]
|
||||
// extractEnvVars читает аннотацию fission-console/env-vars (JSON) из Function CRD
|
||||
// Возвращает [{name, value}, ...]
|
||||
func extractEnvVars(fn *unstructured.Unstructured) []map[string]string {
|
||||
raw, found, _ := unstructured.NestedSlice(fn.Object, "spec", "runtime", "container", "env")
|
||||
if !found || len(raw) == 0 {
|
||||
ann := fn.GetAnnotations()
|
||||
if ann == nil {
|
||||
return []map[string]string{}
|
||||
}
|
||||
result := make([]map[string]string, 0, len(raw))
|
||||
for _, item := range raw {
|
||||
m, ok := item.(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
k, _ := m["name"].(string)
|
||||
v, _ := m["value"].(string)
|
||||
if k != "" {
|
||||
result = append(result, map[string]string{"name": k, "value": v})
|
||||
raw := ann["fission-console/env-vars"]
|
||||
if raw == "" {
|
||||
return []map[string]string{}
|
||||
}
|
||||
var result []map[string]string
|
||||
if err := json.Unmarshal([]byte(raw), &result); err != nil {
|
||||
return []map[string]string{}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<div class="nubes">NUBES</div>
|
||||
<div class="product">FISSION CONSOLE</div>
|
||||
</div>
|
||||
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.72</div>
|
||||
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.73</div>
|
||||
</div>
|
||||
<div class="row" style="margin:0;">
|
||||
<button class="btn ghost" onclick="reloadAll()">Refresh</button>
|
||||
@@ -509,7 +509,7 @@
|
||||
</div>
|
||||
|
||||
<div class="actions" style="justify-content:space-between; align-items:center;">
|
||||
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.72</span>
|
||||
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.73</span>
|
||||
<button class="btn ghost" onclick="closeHelp()">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user