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

refactor(cli): improve CLI error handling. Fixes #1935 #13656

Merged
merged 8 commits into from
Oct 4, 2024

Commits on Sep 24, 2024

  1. refactor(cli): improve error handling. Fixes argoproj#1935

    It's tricky to write unit tests for the CLI code for three main reasons:
    exiting on errors, lack of dependency injection, and insufficient mocks.
    argoproj#3917 tried to solve all
    of these issues, but appears to have been abandoned. I thought about
    trying to revive that PR, but it's been over 4 years and there's
    certainly going to be a ton of conflicts. I figure it's better to take a
    more focused, incremental approach.
    
    This PR is focused on improving error handling in the following ways:
    1. Do argument validation using [cobra
       validators](https://cobra.dev/#positional-and-custom-arguments)
       instead of custom logic in the `Run` function. Besides being
       simpler, this leads to better error messages.
    2. Replace all `Run` functions with `RunE`, which allows returning
       errors. This is the same approach that Argo Rollouts is taking
       (example:
       https://github.com/argoproj/argo-rollouts/blob/00e39b114849010dd96221a8db441d58e860d4d0/pkg/kubectl-argo-rollouts/cmd/abort/abort.go#L41)
    3. Replace nearly all calls to `log.Fatal()`/`errors.CheckError()`/etc
       with error propagation.
    
    Signed-off-by: Mason Malone <mmalone@adobe.com>
    MasonM committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    1a40f65 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a8afeaa View commit details
    Browse the repository at this point in the history

Commits on Sep 26, 2024

  1. Configuration menu
    Copy the full SHA
    907f918 View commit details
    Browse the repository at this point in the history

Commits on Sep 27, 2024

  1. Configuration menu
    Copy the full SHA
    793e2c6 View commit details
    Browse the repository at this point in the history

Commits on Sep 29, 2024

  1. Merge branch 'main' into refactor-1935

    Signed-off-by: Mason Malone <mmalone@adobe.com>
    MasonM committed Sep 29, 2024
    Configuration menu
    Copy the full SHA
    48b6442 View commit details
    Browse the repository at this point in the history
  2. Merge remote-tracking branch 'origin/refactor-1935' into refactor-1935

    Signed-off-by: Mason Malone <mmalone@adobe.com>
    MasonM committed Sep 29, 2024
    Configuration menu
    Copy the full SHA
    9ec5f9c View commit details
    Browse the repository at this point in the history

Commits on Oct 2, 2024

  1. Merge branch 'main' into refactor-1935

    Signed-off-by: Mason Malone <mmalone@adobe.com>
    MasonM committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    6a971f5 View commit details
    Browse the repository at this point in the history

Commits on Oct 3, 2024

  1. refactor: minor cleanup

    Signed-off-by: Mason Malone <mmalone@adobe.com>
    MasonM committed Oct 3, 2024
    Configuration menu
    Copy the full SHA
    45067c3 View commit details
    Browse the repository at this point in the history