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

Check for nil environment before accessing it #453

Merged
merged 2 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions bundle/config/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ func (r *Root) SetConfigFilePath(path string) {
r.Resources.SetConfigFilePath(path)
if r.Environments != nil {
for _, env := range r.Environments {
if env == nil {
continue
}
if env.Resources != nil {
env.Resources.SetConfigFilePath(path)
}
Expand Down
5 changes: 5 additions & 0 deletions bundle/tests/environment_empty/bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bundle:
name: environment_empty

environments:
development:
12 changes: 12 additions & 0 deletions bundle/tests/environment_empty_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package config_tests

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestEnvironmentEmpty(t *testing.T) {
b := loadEnvironment(t, "./environment_empty", "development")
assert.Equal(t, "development", b.Config.Bundle.Environment)
}