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

feat: implements exit code functionality #2673

Merged
merged 1 commit into from
Feb 10, 2023

Conversation

ChrisJBurns
Copy link
Contributor

@ChrisJBurns ChrisJBurns commented Jan 28, 2023

Summary

  • adds exit code functionality that allows for cosign to return sensible exit codes for specific errors. the exit code document generation is automatically baked into the docgen step.
  • adds first exit code for "no matching signatures" and added two more ready for addition in future PR.
  • is backwards compatible and will throw exit code 1 for all non defined error types/exit code permutations.
  • updates version of linter to use when running make lint as it was 4 versions behind the one used in Actions workflow.

Addresses some of #948 (further PR's to address completely)

Signed-off-by: ChrisJBurns 29541485+ChrisJBurns@users.noreply.github.com

@codecov-commenter
Copy link

codecov-commenter commented Jan 28, 2023

Codecov Report

Merging #2673 (285f24a) into main (4996f9b) will increase coverage by 0.00%.
The diff coverage is 33.60%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           Coverage Diff            @@
##             main    #2673    +/-   ##
========================================
  Coverage   30.00%   30.01%            
========================================
  Files         146      150     +4     
  Lines        9299     9406   +107     
========================================
+ Hits         2790     2823    +33     
- Misses       6077     6151    +74     
  Partials      432      432            
Impacted Files Coverage Δ
cmd/cosign/cli/verify/verify.go 22.49% <0.00%> (ø)
cmd/cosign/errors/generate_docs.go 0.00% <0.00%> (ø)
pkg/cosign/errors.go 60.00% <0.00%> (-40.00%) ⬇️
cmd/cosign/errors/errors.go 22.22% <22.22%> (ø)
pkg/cosign/verify.go 39.26% <48.38%> (+0.03%) ⬆️
cmd/cosign/errors/error_wrap.go 100.00% <100.00%> (ø)
cmd/cosign/errors/exit_code_lookup.go 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

// convieniently solved this problem prior: https://github.com/rancher/elemental-cli/blob/main/docs/generate_docs.go
// there was no need to change (apart from some file paths) due to it
// giving us exactly what we want without error.
func GenerateExitCodeDocs() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Damn, beautiful code. Only a genius could write something as beautiful as this ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Standing on the shoulders of giants as they say 😝

@Itxaka
Copy link
Contributor

Itxaka commented Jan 28, 2023

Looking really nice!

znewman01
znewman01 previously approved these changes Feb 6, 2023
doc/cosign_exit_codes.md Show resolved Hide resolved
znewman01
znewman01 previously approved these changes Feb 6, 2023
Copy link
Contributor

@znewman01 znewman01 left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

- adds exit code functionality that allows for cosign to return sensible
  exit codes for specific errors. the exit code document generation is
  automatically baked into the `docgen` step.
- adds first exit code for no matching signatures and added two more
  ready for addition in future PR.
- is backwards compatible and will throw exit code 1 for all non defined
  error types/exit code permutations.

Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
@ChrisJBurns
Copy link
Contributor Author

ChrisJBurns commented Feb 6, 2023

@znewman01 All good to go, permitting the Workflow Gods are happy 😄

@znewman01
Copy link
Contributor

Ugh, I kicked off the workflows 3 days ago and the Windows one is hung. Re-running...

@znewman01 znewman01 enabled auto-merge (squash) February 10, 2023 14:57
@znewman01 znewman01 merged commit b5abf22 into sigstore:main Feb 10, 2023
@github-actions github-actions bot added this to the v1.14.0 milestone Feb 10, 2023
@ChrisJBurns ChrisJBurns deleted the adds-exit-code-func branch February 10, 2023 18:19
dmitris pushed a commit to dmitris/cosign that referenced this pull request Mar 24, 2023
- adds exit code functionality that allows for cosign to return sensible
  exit codes for specific errors. the exit code document generation is
  automatically baked into the `docgen` step.
- adds first exit code for no matching signatures and added two more
  ready for addition in future PR.
- is backwards compatible and will throw exit code 1 for all non defined
  error types/exit code permutations.

Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
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.

4 participants