Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for environment overrides in rill.yaml #6118

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Changes from all commits
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
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
Loading