Skip to content

Commit

Permalink
fix for environment overrides in rill.yaml (#6118)
Browse files Browse the repository at this point in the history
* fix for environment overrides in rill.yaml

* fix for environment overrides in rill.yaml

* fix for environment overrides in rill.yaml
  • Loading branch information
k-anshul authored Nov 21, 2024
1 parent ba98f82 commit 419ab21
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions runtime/compilers/rillv1/parse_rillyaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,11 @@ func (p *Parser) parseRillYAML(ctx context.Context, path string) error {
return newYAMLError(err)
}

// Display name backwards compatibility
if tmp.Title != "" && tmp.DisplayName == "" {
tmp.DisplayName = tmp.Title
}

// Parse environment variables from the "env:" (current) and "vars:" (deprecated) keys.
vars := make(map[string]string)
for k, v := range tmp.Vars { // Backwards compatibility
vars[k] = v
}
// Look for environment-specific overrides
for k, v := range tmp.Env { // nolint: gocritic // Using a pointer changes parser behavior
if v.Kind == yaml.ScalarNode {
vars[k] = v.Value
continue
}

// Backwards compatibility hack: we renamed "env" to "environment_overrides".
// The only environments supported at the rename time were "dev" and "prod".
if k == "dev" || k == "prod" {
Expand Down Expand Up @@ -145,6 +134,23 @@ func (p *Parser) parseRillYAML(ctx context.Context, path string) error {
}
}

// Display name backwards compatibility
if tmp.Title != "" && tmp.DisplayName == "" {
tmp.DisplayName = tmp.Title
}

// Parse environment variables from the "env:" (current) and "vars:" (deprecated) keys.
vars := make(map[string]string)
for k, v := range tmp.Vars { // Backwards compatibility
vars[k] = v
}

for k, v := range tmp.Env { // nolint: gocritic // Using a pointer changes parser behavior
if v.Kind == yaml.ScalarNode {
vars[k] = v.Value
}
}

// Validate resource defaults
if !tmp.Sources.IsZero() {
if err := tmp.Sources.Decode(&SourceYAML{}); err != nil {
Expand Down

0 comments on commit 419ab21

Please sign in to comment.