Comments (4)
@luke-engle could we refactor the ProcessService#RunAndCaptureAsync
method to be able to return both the text from the standard out/err streams (for example, by updating the method signature to return a tuple) and then the DockerService
could use the returned value to see if the error contains a certain text?
from gh-valet.
@ethanis We may need to speed up our timeframe of when we wanted to rewrite the ProcessService
in gh-valet
π I was looking into this and found that the error text weβre looking for (Error response from daemon: Get "https://ghcr.io/v2/": denied: denied
) never actually gets captured. Well, technically it does get captured, but by the ReadStream
method, which then immediately dumps it to the console and throws it away.
When the ProcessService
detects a non-zero exit code:
if (process.ExitCode != 0)
{
var error = await process.StandardError.ReadToEndAsync();
throw new Exception(error);
}
That error variable contains nothing every time, because the StandardError stream has already been consumed all the way to the end by the ReadStream
method. That means there's currently no way for us to tell if someone isn't authorized or is using a token that is not permissive enough.
One way we could manage this is by maintaining a string or an array for StandardError
by updating it in the ReadStream
method, then if we hit an error, check if standard_error.Contains("Error response from daemon: Get "https://ghcr.io/v2/": denied: denied")
? Not very performant if there happen to be a lot of errors, but I don't exactly expect that to be the case here - plus we'd only be doing this Contains
check if we failed to authenticate with docker, which means output to standard error at that point should be minimal. What do you think?
(Sorry for the novel)
from gh-valet.
@ethanis That's a good point, I forgot about the RunAndCaptureAsync
method! Although, I don't think we need to refactor it to return a tuple - it's already written to throw an exception with the stderr text if the process exits with a non-zero exit code. We can just try/catch and read it from the exception message. Does that sound good?
from gh-valet.
It sounds like a bit of a smell to use exceptions to control the flow like that. Returning a tuple and letting the caller determine what to do with an error would be a cleaner, and more easily tested, approach. We could even add in the exit code to the tuple that's being returned π
from gh-valet.
Related Issues (20)
- [Support]: valet unable to detect docker daemon HOT 4
- Add `--password-stdin` option to `gh valet update`
- [Support]: HOT 1
- Join or use gh-valet HOT 1
- Check if `valet-cli` container is current HOT 1
- Support linux-386 HOT 2
- [Support]: Azure DevOps audit trying to pull from nonexistent, non-default branch HOT 10
- [Support]: undefined method `[]' for nil:NilClass HOT 4
- [Support]: Support required HOT 2
- [Support]: SSL error when using valet for azure devops to Github Enterprise trial org pipeline migration HOT 2
- Expose new `migrate` command option `--workflow-file-prefix` HOT 1
- Output does not always have newline separators HOT 4
- Progress bar persists on the console after command finishes HOT 1
- Create forecast subcommand for GitHub
- [Support]: Cannot run valet commands HOT 6
- YAML files in multiple branches HOT 1
- Support darwin-arm64 HOT 7
- [Support]: Caching not working HOT 9
- Point to new repo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gh-valet.