Skip to content

refactor!: Properly support contexts#501

Merged
bhavanki merged 1 commit intomasterfrom
contexts
Jun 5, 2024
Merged

refactor!: Properly support contexts#501
bhavanki merged 1 commit intomasterfrom
contexts

Conversation

@bhavanki
Copy link
Contributor

@bhavanki bhavanki commented May 28, 2024

The new AWS SDK uses contexts for all API functions and for loading the
SDK configuration. When chamber was migrated to the SDK, all of them
were set to context.TODO(). This commit removes those temporary values
and threads contexts properly throughout the codebase, starting from the
chamber commands.

BREAKING CHANGE: This commit changes the signature of many exported
functions to add a context argument.

@bhavanki bhavanki requested a review from a team as a code owner May 28, 2024 20:11
@codecov
Copy link

codecov bot commented May 28, 2024

Codecov Report

Attention: Patch coverage is 32.57143% with 118 lines in your changes missing coverage. Please review.

Project coverage is 35.81%. Comparing base (e70bb44) to head (3367239).

Files Patch % Lines
store/s3store.go 0.00% 38 Missing ⚠️
store/s3storeKMS.go 0.00% 29 Missing ⚠️
environ/environ.go 0.00% 8 Missing ⚠️
store/nullstore.go 0.00% 7 Missing ⚠️
cmd/root.go 0.00% 5 Missing ⚠️
store/ssmstore.go 87.09% 4 Missing ⚠️
cmd/exec.go 0.00% 3 Missing ⚠️
cmd/find.go 0.00% 3 Missing ⚠️
cmd/write.go 0.00% 3 Missing ⚠️
cmd/delete.go 0.00% 2 Missing ⚠️
... and 9 more
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #501   +/-   ##
=======================================
  Coverage   35.81%   35.81%           
=======================================
  Files          25       25           
  Lines        2284     2284           
=======================================
  Hits          818      818           
  Misses       1394     1394           
  Partials       72       72           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@alecjacobs5401 alecjacobs5401 left a comment

Choose a reason for hiding this comment

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

Changes all seem reasonable here! Mainly have a a recurring open question about the nature of this PR introducing breaking changes to almost every public interface. I know this is slated for a v3 release, but should this PR be split up/the title include the nature of the breaking changes? I believe the CHANGELOG is auto generated based on commits now, so want to make sure we're building up a good changelog for migrations.

I know its more work too, but a well worn pattern I've seen is to add a <Action>WithContext as a way to side-step the breaking nature of passing contexts through. Is that something we might need to consider?

// collisions will be populated with any keys that get overwritten
func (e *Environ) Load(s store.Store, service string, collisions *[]string) error {
return e.load(s, service, collisions, false)
func (e *Environ) Load(ctx context.Context, s store.Store, service string, collisions *[]string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

as it stands, anywhere we add in ctx here as a starting argument is considered a breaking change since it alters the public interface.

I know we're preparing the default branch as a candidate for v3, so maybe its moot, but does it make sense to call this out heavily somewhere (either in a changelog, or updating the merge commit) to designate the nature of these breaking changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm fine updating the commit to be a breaking change in conventional commit-ese. It is certainly a significant break for anyone using chamber as a library, which I wasn't thinking about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commit updated to call out that this is a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As for <Action>WithContext: I'm OK with using the breaking change opportunity to avoid adding those extra functions to preserve compatibility. It'd certainly be a lot of extra functions.

@bhavanki bhavanki changed the title refactor: Properly support contexts refactor!: Properly support contexts May 30, 2024
@bhavanki bhavanki requested a review from alecjacobs5401 May 30, 2024 16:37
alecjacobs5401
alecjacobs5401 previously approved these changes Jun 4, 2024
The new AWS SDK uses contexts for all API functions and for loading the
SDK configuration. When chamber was migrated to the SDK, all of them
were set to `context.TODO()`. This commit removes those temporary values
and threads contexts properly throughout the codebase, starting from the
chamber commands.

BREAKING CHANGE: This commit changes the signature of many exported
functions to add a context argument.
@bhavanki bhavanki merged commit 9fa06b1 into master Jun 5, 2024
@bhavanki bhavanki deleted the contexts branch June 5, 2024 19:30
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.

3 participants