Skip to content

Commit

Permalink
fix: nil pointer on incomplete config for accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Nov 10, 2024
1 parent 7196f93 commit 0ce5294
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ func (c *Config) Filters(accountID string) (filter.Filters, error) {
// new resource type.
func (c *Config) ResolveDeprecations() error {
for _, a := range c.Accounts {
if a == nil {
return nil
}

// Note: if there are no filters defined, then there's no substitution to perform.
if a.Filters == nil {
return nil
Expand Down
9 changes: 9 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,12 @@ func TestNoBlocklist(t *testing.T) {
err = c.ValidateAccount("555133742")
assert.Error(t, err)
}

func TestIncomplete(t *testing.T) {
opts := Options{
Path: "testdata/incomplete.yaml",
}
c, err := New(opts)
assert.NoError(t, err)
_ = c
}
5 changes: 5 additions & 0 deletions pkg/config/testdata/incomplete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
regions:
- global

accounts:
"0964xxxxxxxx":

0 comments on commit 0ce5294

Please sign in to comment.