github / gh-valet

Valet helps facilitate the migration of Azure DevOps, CircleCI, GitLab CI, Jenkins, and Travis CI pipelines to GitHub Actions.
MIT License
510 stars 35 forks source link

Display troubleshooting context if update command fails #90

Closed luke-engle closed 1 year ago

luke-engle commented 1 year ago

What's changing?

When a user runs the update command with an invalid token, the login fails and the user gets a cryptic, unhelpful error message: Error response from daemon: Get "https://ghcr.io/v2/": denied: denied

Similarly, when a user runs the update command with a token that doesn't have the required scopes, they get this cryptic error message: Error response from daemon: denied

This change addresses this issue by providing the user with clear error messages in these scenarios.

How's this tested?

Unit tests, and running manually which you can see below πŸ‘‡

Invalid token:

➜ echo $INVALID_TOKEN | dotnet run --project src/Valet/Valet.csproj update --username luke-engle --password-stdin
You are not authorized to access Valet yet. Please ensure you've completed the following:
- Requested access to Valet and received onboarding instructions via email.
- Accepted all of the repository invites sent after being onboarded.

Invalid scopes:

➜ echo $TOKEN_WITH_INVALID_SCOPES | dotnet run --project src/Valet/Valet.csproj update --username luke-engle --password-stdin
Login Succeeded

Pulling valet-customers/valet-cli:latest from the ghcr.io docker repository...
You are not authorized to access Valet yet. Please ensure you've completed the following:
- Requested access to Valet and received onboarding instructions via email.
- Accepted all of the repository invites sent after being onboarded.
- The GitHub personal access token used above contains the 'read:packages' scope.

Closes #88

github-actions[bot] commented 1 year ago

Unit Test Results

37 tests  +2   37 :heavy_check_mark: +2   0s :stopwatch: Β±0s βŸβ€„1 suites Β±0β€‚β€ƒβ€ƒβŸβ€„0 :zzz: Β±0  βŸβ€„1 files   Β±0β€‚β€ƒβ€ƒβŸβ€„0 :x: Β±0 

Results for commit 28e2f194. ± Comparison against base commit ccfcad4e.

This pull request removes 3 and adds 5 tests. Note that renamed tests count towards both. ``` Valet.UnitTests.AppTests ‑ CheckForUpdates_NoUpdatesNeeded("4256ea72fd01deac3e967f6b19f907587dcd6f0a976301f1aecc73dc6f146a4a","67eed1493c461efd993be9777598a456562f4e0c6b0bddcb19d819220a06dd4b","A new version of the Valet CLI is available. Run 'gh valet update' to update.\n") Valet.UnitTests.Services.DockerServiceTests ‑ UpdateImageAsync_InvalidCredentialsProvided_ReturnsFalse Valet.UnitTests.Services.DockerServiceTests ‑ UpdateImageAsync_ValidCredentialsProvided_ReturnsTrue ``` ``` Valet.UnitTests.AppTests ‑ CheckForUpdates_NoUpdatesNeeded("4256ea72fd01deac3e967f6b19f907587dcd6f0a976301f1aecc73dc6f146a4a","67eed1493c461efd993be9777598a456562f4e0c6b0bddcb19d819220a06dd4b","A new version of the Valet CLI is available. Run 'gh valet update' to update.") Valet.UnitTests.Services.DockerServiceTests ‑ UpdateImageAsync_InvalidCredentialsProvided_ThrowsUnauthorized Valet.UnitTests.Services.DockerServiceTests ‑ UpdateImageAsync_InvalidCredentialsProvided_ThrowsUnknownError Valet.UnitTests.Services.DockerServiceTests ‑ UpdateImageAsync_InvalidScopes_ThrowsUnauthorized Valet.UnitTests.Services.DockerServiceTests ‑ UpdateImageAsync_ValidCredentialsProvided_ReturnsSuccessful ```

:recycle: This comment has been updated with latest results.