updates
This commit is contained in:
@@ -16,10 +16,10 @@ import (
|
||||
// AppConfig holds the per-app deployment configuration.
|
||||
// Saved as app.yaml in each stack directory after first deployment.
|
||||
type AppConfig struct {
|
||||
Deployed bool `yaml:"deployed" json:"deployed"`
|
||||
DeployedAt string `yaml:"deployed_at" json:"deployed_at"`
|
||||
Env map[string]string `yaml:"env" json:"env"`
|
||||
LockedFields []string `yaml:"locked_fields" json:"locked_fields"`
|
||||
Deployed bool `yaml:"deployed" json:"deployed"`
|
||||
DeployedAt string `yaml:"deployed_at" json:"deployed_at"`
|
||||
Env map[string]string `yaml:"env" json:"env"`
|
||||
LockedFields []string `yaml:"locked_fields" json:"locked_fields"`
|
||||
}
|
||||
|
||||
// DeployRequest contains the user-provided values from the deploy form.
|
||||
@@ -30,9 +30,9 @@ type DeployRequest struct {
|
||||
|
||||
// DeployStack handles first-time deployment of an app:
|
||||
// 1. Load metadata (.felhom.yml) to know what fields exist
|
||||
// 2. Auto-generate secrets for secret/password fields without user values
|
||||
// 2. Auto-generate secrets for secret fields (hidden from user)
|
||||
// 3. Auto-fill domain from controller config
|
||||
// 4. Merge with user-provided values
|
||||
// 4. Validate all user-provided values (password, path, required fields)
|
||||
// 5. Save app.yaml
|
||||
// 6. Run docker compose up -d with env vars
|
||||
func (m *Manager) DeployStack(req DeployRequest) error {
|
||||
@@ -50,6 +50,16 @@ func (m *Manager) DeployStack(req DeployRequest) error {
|
||||
return fmt.Errorf("stack %q is already deployed; use update instead", req.StackName)
|
||||
}
|
||||
|
||||
// Debug: log received values (redact passwords)
|
||||
m.logger.Printf("[DEBUG] Deploy %s: received %d user values", req.StackName, len(req.Values))
|
||||
for k, v := range req.Values {
|
||||
if strings.Contains(strings.ToLower(k), "password") || strings.Contains(strings.ToLower(k), "secret") {
|
||||
m.logger.Printf("[DEBUG] %s = [REDACTED, len=%d]", k, len(v))
|
||||
} else {
|
||||
m.logger.Printf("[DEBUG] %s = %q", k, v)
|
||||
}
|
||||
}
|
||||
|
||||
// Build the full env map
|
||||
env := make(map[string]string)
|
||||
var lockedFields []string
|
||||
@@ -71,15 +81,12 @@ func (m *Manager) DeployStack(req DeployRequest) error {
|
||||
value = generated
|
||||
|
||||
case "password":
|
||||
// Use user value if provided, otherwise generate
|
||||
// Password fields MUST be filled by the user (via typing or Generálás button).
|
||||
// We never silently auto-generate — the user needs to know their password.
|
||||
if userVal, ok := req.Values[field.EnvVar]; ok && userVal != "" {
|
||||
value = userVal
|
||||
} else if field.Generate != "" {
|
||||
generated, err := generateValue(field.Generate)
|
||||
if err != nil {
|
||||
return fmt.Errorf("generating %s: %w", field.EnvVar, err)
|
||||
}
|
||||
value = generated
|
||||
} else {
|
||||
return fmt.Errorf("a(z) %q mező kitöltése kötelező — használja a Generálás gombot vagy írjon be egy jelszót", field.Label)
|
||||
}
|
||||
|
||||
default:
|
||||
@@ -93,7 +100,7 @@ func (m *Manager) DeployStack(req DeployRequest) error {
|
||||
|
||||
// Validate required fields
|
||||
if field.Required && value == "" {
|
||||
return fmt.Errorf("required field %q (%s) is empty", field.Label, field.EnvVar)
|
||||
return fmt.Errorf("a(z) %q (%s) mező kitöltése kötelező", field.Label, field.EnvVar)
|
||||
}
|
||||
|
||||
// Validate path fields exist
|
||||
@@ -124,7 +131,12 @@ func (m *Manager) DeployStack(req DeployRequest) error {
|
||||
return fmt.Errorf("saving app config: %w", err)
|
||||
}
|
||||
|
||||
m.logger.Printf("[INFO] Deploying stack %s with %d env vars", req.StackName, len(env))
|
||||
// Debug: log final env var keys (not values)
|
||||
envKeys := make([]string, 0, len(env))
|
||||
for k := range env {
|
||||
envKeys = append(envKeys, k)
|
||||
}
|
||||
m.logger.Printf("[INFO] Deploying stack %s with %d env vars: [%s]", req.StackName, len(env), strings.Join(envKeys, ", "))
|
||||
|
||||
// Run docker compose up -d
|
||||
_, err := m.composeExecWithEnv(stackDir, env, "up", "-d")
|
||||
@@ -298,4 +310,4 @@ func randomAlphanumeric(length int) (string, error) {
|
||||
result[i] = alphanumChars[n.Int64()]
|
||||
}
|
||||
return string(result), nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user