Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
iterate in sorted order
  • Loading branch information
k-anshul committed Apr 29, 2026
commit 16f5863882f8a1cface387aef5483b3aae00cedd
1 change: 1 addition & 0 deletions admin/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ func (s *Service) StartDeploymentInner(ctx context.Context, depl *database.Deplo
if err != nil {
return err
}
// base variables are returned first followed by environment specific variables, so we can just iterate once and overlay them in order
v := map[string]string{}
for _, variable := range vars {
v[variable.Name] = variable.Value
Expand Down
6 changes: 6 additions & 0 deletions admin/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"context"
"fmt"
"reflect"
"slices"
"strconv"
"strings"
"time"

"github.com/rilldata/rill/admin/database"
Expand Down Expand Up @@ -534,11 +536,15 @@ func (s *Service) TriggerParserAndAwaitResource(ctx context.Context, depl *datab

// 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 environment) first.
func (s *Service) ResolveVariables(ctx context.Context, depl *database.Deployment) ([]*database.ProjectVariable, error) {
vars, err := s.DB.FindProjectVariables(ctx, depl.ProjectID, &depl.Environment)
if err != nil {
return nil, err
}
slices.SortFunc(vars, func(a, b *database.ProjectVariable) int {
return strings.Compare(a.Environment, b.Environment)
})
// Enable the file watcher for editable deployments.
vars = append(vars, &database.ProjectVariable{
Name: "rill.watch_repo",
Expand Down
14 changes: 7 additions & 7 deletions runtime/server/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ func (s *Server) PushEnv(ctx context.Context, req *runtimev1.PushEnvRequest) (*r
if err != nil && !errors.Is(err, drivers.ErrNotAuthenticated) {
return nil, fmt.Errorf("failed to get project variables: %w", err)
}
var cloudPerEnv map[string]map[string]string
if cfg != nil {
cloudPerEnv = cfg.Variables
}
if cloudPerEnv == nil {
cloudPerEnv = make(map[string]map[string]string)
}
var cloudPerEnv map[string]map[string]string
if cfg != nil {
cloudPerEnv = cfg.Variables
}
if cloudPerEnv == nil {
cloudPerEnv = make(map[string]map[string]string)
}
Comment thread
k-anshul marked this conversation as resolved.

var addedCount, changedCount int32

Expand Down
Loading