[VC-43403] Refactor the CyberArk dataupload client to take an HTTP client#700
Merged
wallrj-cyberark merged 1 commit intomasterfrom Aug 28, 2025
Merged
[VC-43403] Refactor the CyberArk dataupload client to take an HTTP client#700wallrj-cyberark merged 1 commit intomasterfrom
wallrj-cyberark merged 1 commit intomasterfrom
Conversation
6c2e839 to
a49662f
Compare
a49662f to
5bd316d
Compare
25eccd6 to
e61ad7a
Compare
…ability - Replaced `NewCyberArkClient` with `New` for a cleaner API - Removed dependency on `x509.CertPool` and `transport.NewDebuggingRoundTripper` - Updated `CyberArkClient` to use `http.Client` directly - Refactored tests to use `MockDataUploadServer` with `testing.TB` for better cleanup - Simplified mock server setup and logging for improved maintainability Signed-off-by: Richard Wall <richard.wall@cyberark.com>
5bd316d to
3fa015d
Compare
wallrj-cyberark
commented
Aug 28, 2025
|
|
||
| serviceURL := fmt.Sprintf("https://%s%s%s.%s", subdomain, separator, discoveryContextServiceName, platformDomain) | ||
| // TODO(wallrj): get this from the servicediscovery API instead. | ||
| inventoryAPI := fmt.Sprintf("https://%s.inventory.%s", subdomain, platformDomain) |
Member
Author
There was a problem hiding this comment.
This TODO is implemented in a followup PR: #701
| "github.com/jetstack/preflight/pkg/version" | ||
| "k8s.io/client-go/transport" | ||
|
|
||
| _ "embed" |
Member
Author
There was a problem hiding this comment.
embed was never used in this mock. Other mocks load sample API responses from files, but this mock doesn't...yet.
| type CyberArkClient = dataupload.CyberArkClient | ||
|
|
||
| var NewCyberArkClient = dataupload.NewCyberArkClient | ||
| var NewCyberArkClient = dataupload.New |
Member
Author
There was a problem hiding this comment.
In #696 I will introduce a MachineHub / CyberArk outputter (data publisher) and put it in this file.
mladen-rusev-cyberark
approved these changes
Aug 28, 2025
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.
Similar to #699, I want all the cyberark API wrappers to take an httpClient as an injected dependency rather than them each instantiating their own client. This way the http client can be created once, with sensible defaults and roundtrippers, and supplied to all the API wrappers.
NewCyberArkClientwithNewto simplify client initializationby removing certificate pool handling and relying on an injected HTTP client.
CyberArkClientto usehttpClientinstead ofclientfor clarity.MockDataUploadServerto return both server URL and HTTP client,improving test setup and reducing boilerplate.
dataupload_test.goandmock.go.Follow up PRs