feat: add global --verbose flag for HTTP debugging#370
Open
Aditya200247 wants to merge 4 commits into
Open
Conversation
|
Welcome to the Microcks community! 💖 Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly. Hope you have a great time there! |
Member
|
@Aditya200247 Can you please sign-off your commits? It's mendatory to sign-off commits while contributing to CNCF projects. |
The old approach used a config.Verbose global and scattered httputil.DumpRequestOut/DumpResponse calls across every method. Replace it with a small loggingTransport that wraps the HTTP client's RoundTripper once at construction time. - Logs >> METHOD URL and each request header to stderr - Redacts the Authorization header value - Logs << STATUS after each response - Removes the Verbose global and DumpRequestIfRequired / DumpResponseIfRequired helpers from pkg/config Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
Also remove the now-dead config.Verbose assignments from all command Run functions - the flag value flows through ClientOptions.Verbose directly into the HTTP client transport. Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
- Add verbose bool field to loggingTransport; RoundTrip is a no-op when verbose is false so the transport is always safe to install - Add verbose param to NewMicrocksClient and NewKeycloakClient so the direct-auth code path (--microcksURL + --keycloakClientId) also logs when -v is passed - Pass c.Verbose into the internal keycloak client used for token refresh so logging is consistent across the whole session - Remove the local --verbose flag from import-dir (it conflicted with the root persistent flag); globalClientOpts.Verbose now drives both HTTP logging and the file-listing output - Fix TestLoggingTransportSilentWhenVerboseFalse: read stderr before closing the pipe and assert zero bytes written - Drop deprecated filepath.HasPrefix in importDir_test.go - Remove the benchmark that was noise for this PR Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
- Remove dead ImportError type from importDir.go - Add direct-auth path (--microcksURL + keycloak flags) to import-dir so it matches the other commands (import, test, import-url) - Redirect verbose diagnostic output to stderr per issue spec - Fix silent fmt.Errorf in executor.go (was swallowing the error) replaced with fmt.Fprintf(os.Stderr, ...) Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
563459b to
775349b
Compare
Author
|
Hey @Harsh4902 , |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
go test -v ./pkg/connectors
=== RUN TestDownloadArtifactReturnsResponseBody
--- PASS: TestDownloadArtifactReturnsResponseBody (0.00s)
=== RUN TestLoggingTransportSilentWhenVerboseFalse
--- PASS: TestLoggingTransportSilentWhenVerboseFalse (0.00s)
=== RUN TestLoggingTransportRedactsAuth
--- PASS: TestLoggingTransportRedactsAuth (0.00s)
PASS
ok github.com/microcks/microcks-cli/pkg/connectors 1.298s
go test -v ./cmd
=== RUN TestImportDirectory
=== RUN TestImportDirectory/successful_import_of_all_files
--- PASS: TestImportDirectory/successful_import_of_all_files (0.00s)
=== RUN TestImportDirectory/partial_failure
--- PASS: TestImportDirectory/partial_failure (0.00s)
=== RUN TestImportDirectory/recursive_scan
--- PASS: TestImportDirectory/recursive_scan (0.00s)
=== RUN TestImportDirectory/pattern_filtering
--- PASS: TestImportDirectory/pattern_filtering (0.00s)
--- PASS: TestImportDirectory (0.00s)
=== RUN TestValidateDirectory
--- PASS: TestValidateDirectory (0.00s)
=== RUN TestFindSpecificationFilesWithFS
--- PASS: TestFindSpecificationFilesWithFS (0.00s)
=== RUN TestDetectFileTypeWithLogic
--- PASS: TestDetectFileTypeWithLogic (0.00s)
=== RUN TestNewImportDirCommand
--- PASS: TestNewImportDirCommand (0.00s)
=== RUN TestImportResult
--- PASS: TestImportResult (0.00s)
--- FAIL: TestDeleteContext (0.00s) ← pre-existing upstream failure (unrelated to this PR)
open ./testdata/local.config: The system cannot find the path specified.
Description
Added a global -v / --verbose persistent flag to the root command to help users debug local connection issues.
Implemented a custom RoundTripper for the HTTP client that logs the request method, target URL, and response status to stderr.
Added security masking to ensure sensitive headers (specifically the Authorization header) are redacted and not printed to the console.
Related issue(s)
resolved #347