Skip to content

Commit

Permalink
Changed the error to more understandable when the region code isn't set
Browse files Browse the repository at this point in the history
  • Loading branch information
a2ush committed Feb 10, 2024
1 parent 87e12f2 commit a6ad55d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/eks/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ func newAWSProvider(spec *api.ProviderConfig, configurationLoader AWSConfigurati
return nil, err
}

if cfg.Region == "" {
return nil. fmt.Errorf("AWS Region must be set, please set the AWS Region in AWS config file or as environment variable")

Check failure on line 190 in pkg/eks/api.go

View workflow job for this annotation

GitHub Actions / Unit tests

nil.fmt undefined (type untyped nil has no field or method fmt)

Check failure on line 190 in pkg/eks/api.go

View workflow job for this annotation

GitHub Actions / Lint

nil.fmt undefined (type untyped nil has no field or method fmt))

Check failure on line 190 in pkg/eks/api.go

View workflow job for this annotation

GitHub Actions / Lint

nil.fmt undefined (type untyped nil has no field or method fmt))

Check failure on line 190 in pkg/eks/api.go

View workflow job for this annotation

GitHub Actions / Lint

nil.fmt undefined (type untyped nil has no field or method fmt))

Check failure on line 190 in pkg/eks/api.go

View workflow job for this annotation

GitHub Actions / Lint

nil.fmt undefined (type untyped nil has no field or method fmt))

Check failure on line 190 in pkg/eks/api.go

View workflow job for this annotation

GitHub Actions / Lint

nil.fmt undefined (type untyped nil has no field or method fmt))

Check failure on line 190 in pkg/eks/api.go

View workflow job for this annotation

GitHub Actions / Lint

nil.fmt undefined (type untyped nil has no field or method fmt))

Check failure on line 190 in pkg/eks/api.go

View workflow job for this annotation

GitHub Actions / Lint

nil.fmt undefined (type untyped nil has no field or method fmt))

Check failure on line 190 in pkg/eks/api.go

View workflow job for this annotation

GitHub Actions / Lint

nil.fmt undefined (type untyped nil has no field or method fmt))

Check failure on line 190 in pkg/eks/api.go

View workflow job for this annotation

GitHub Actions / Lint

nil.fmt undefined (type untyped nil has no field or method fmt))

Check failure on line 190 in pkg/eks/api.go

View workflow job for this annotation

GitHub Actions / Lint

nil.fmt undefined (type untyped nil has no field or method fmt))
}

if spec.Region == "" {
spec.Region = cfg.Region
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/eks/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ var _ = Describe("eksctl API", func() {
},
err: fmt.Sprintf("cache file %s is not private", cacheFilePath),
}),
Entry("region code is not set", newAWSProviderEntry{
updateFakes: func(fal *fakes.FakeAWSConfigurationLoader) {
fal.LoadDefaultConfigReturns(aws.Config{
Region: "",
}, nil)
},
err: "AWS Region must be set, please set the AWS Region in AWS config file or as environment variable",
}),
Entry("creates the AWS provider successfully", newAWSProviderEntry{}),
)

Expand Down

0 comments on commit a6ad55d

Please sign in to comment.