ResolveVariables resolves the project's variables for the given environment. It fetches the variable specific to the environment plus the default variables not set exclusively for the environment. The returned list is sorted by environment name for consistent ordering, with default variables (empty
(ctx context.Context, depl *database.Deployment)
| 543 | // It fetches the variable specific to the environment plus the default variables not set exclusively for the environment. |
| 544 | // The returned list is sorted by environment name for consistent ordering, with default variables (empty environment) first. |
| 545 | func (s *Service) ResolveVariables(ctx context.Context, depl *database.Deployment) ([]*database.ProjectVariable, map[string]string, error) { |
| 546 | vars, err := s.DB.FindProjectVariables(ctx, depl.ProjectID, &depl.Environment) |
| 547 | if err != nil { |
| 548 | return nil, nil, err |
| 549 | } |
| 550 | slices.SortFunc(vars, func(a, b *database.ProjectVariable) int { |
| 551 | return strings.Compare(a.Environment, b.Environment) |
| 552 | }) |
| 553 | // Enable the file watcher for editable deployments. |
| 554 | systemVars := map[string]string{ |
| 555 | "rill.watch_repo": strconv.FormatBool(depl.Editable), |
| 556 | } |
| 557 | return vars, systemVars, nil |
| 558 | } |
no test coverage detected