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

Plumb context through crane and gcrane #995

Merged
merged 2 commits into from
May 18, 2021

Conversation

jonjohnsonjr
Copy link
Collaborator

Fixes #912

Also, use signal.NotifyContext for cancelling the ctx.

Also, don't log errors twice now that we're using RunE.

@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2021

Codecov Report

Merging #995 (369dd64) into main (8395cdf) will decrease coverage by 0.08%.
The diff coverage is 14.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #995      +/-   ##
==========================================
- Coverage   75.24%   75.15%   -0.09%     
==========================================
  Files         107      107              
  Lines        5058     5064       +6     
==========================================
  Hits         3806     3806              
- Misses        706      712       +6     
  Partials      546      546              
Impacted Files Coverage Δ
pkg/crane/options.go 90.47% <0.00%> (-9.53%) ⬇️
pkg/gcrane/options.go 63.63% <0.00%> (-14.15%) ⬇️
pkg/crane/catalog.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8395cdf...369dd64. Read the comment docs.

@@ -29,5 +29,5 @@ func Catalog(src string, opt ...Option) (res []string, err error) {
return nil, err
}

return remote.Catalog(context.TODO(), reg, o.remote...)
return remote.Catalog(context.Background(), reg, o.remote...)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not plumbing context through here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The remote.WithContext in o.remote... will override it.

@@ -61,8 +62,9 @@ func main() {
root.AddCommand(cmd)
}

if err := root.Execute(); err != nil {
fmt.Println(err)
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
Copy link
Collaborator

Choose a reason for hiding this comment

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

defer cancel () instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Doesn't os.Exit(1) pre-empt it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ended up doing both instead

@jonjohnsonjr jonjohnsonjr force-pushed the contexts branch 2 times, most recently from 053a029 to 3750ef0 Compare May 14, 2021 16:15
Also, use signal.NotifyContext for cancelling the ctx.
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.

Plumb a signal.NotifyContext through crane/gcrane
3 participants