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

clarify Endpoint behavior on empty strings #3423

Merged
merged 1 commit into from
Jul 16, 2020
Merged

Conversation

tabboud
Copy link
Contributor

@tabboud tabboud commented Jul 14, 2020

The following PR changed the Endpoint behavior to include falling back to the default generated endpoint if an empty string is set.
#3349

It's not very clear that this is the intended behavior when reading the docs. Adding this clarification promotes using the following code rather than have to conditionally check if it's set or not.
For example:

type S3 struct {
	Endpoint string
	Region 	 string
}


// ideal behavior
sess, err := session.NewSession(&aws.Config{
	Endpoint: aws.String(s3Cfg.Endpoint),
	Region:   aws.String(s3Cfg.Region),
})


// required check given docs assumption
var endpoint *string
if s3Cfg.Endpoint != "" {
	endpoint = aws.String(s3Cfg.Endpoint)
}
sess, err := session.NewSession(&aws.Config{
	Endpoint: endpoint,
	Region:   aws.String(s3Cfg.Region),
})

The following PR changed the Endpoint behavior to include falling back to the default generated endpoint if an empty string is set. 
aws#3349

It's not very clear that this is the intended behavior when reading the docs. Adding this clarification promotes using the following code rather than have to conditionally check if it's set or not.
For example:
```go
// ideal behavior
sess, err := session.NewSession(&aws.Config{
	Endpoint: aws.String(s3Cfg.Endpoint),
	Region:   aws.String(s3Cfg.Region),
})

// required check given docs assumption
var endpoint *string
if s3Cfg.Endpoint != "" {
	endpoint = aws.String(s3Cfg.Endpoint)
}
sess, err := session.NewSession(&aws.Config{
	Endpoint: endpoint,
	Region:   aws.String(s3Cfg.Region),
})
```
Copy link
Contributor

@jasdel jasdel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to correct this documentation @tabboud the change looks good and we'll include it in our next release.

@jasdel jasdel merged commit b868519 into aws:master Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants