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: unify http client creation #448

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

h0lyalg0rithm
Copy link
Contributor

@h0lyalg0rithm h0lyalg0rithm commented Aug 5, 2024

Proposed changes

Unifies the httpclient used across the application.
No validation of server certificate

Types of changes

What types of changes does your code introduce to the repo? Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

@h0lyalg0rithm h0lyalg0rithm requested a review from a team as a code owner August 5, 2024 19:39
Copy link
Member

@glimchb glimchb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe i miss something....
why not just daemon.downloadAndValidateImage() call to utils.doTLSRequest() ?

the method post vs get can be an argument

happy to discuss ....

@h0lyalg0rithm
Copy link
Contributor Author

maybe i miss something.... why not just daemon.downloadAndValidateImage() call to utils.doTLSRequest() ?

the method post vs get can be an argument

happy to discuss ....

@glimchb I kept them seperate because there were some extra http headers (basic auth etc) being passed in the post request, no sure if that was needed in the get version.
I had to change inject the http client to enable testing for the caching feature.

@@ -171,3 +184,25 @@ func (a *Agent) SetContentTypeReq(ct string) {
func (a *Agent) SetProgressJSON(p ProgressJSON) {
a.ProgressJSON = p
}

func NewHttpClient(bootstrapTrustAnchorCert string, deviceEndEntityCert string, devicePrivateKey string) http.Client {
caCert, _ := os.ReadFile(bootstrapTrustAnchorCert)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move this from agent to tls ?

@glimchb
Copy link
Member

glimchb commented Aug 6, 2024

I had to change inject the http client to enable testing for the caching feature.

so this should be separate PR or separate commit just for injection

Copy link
Member

@glimchb glimchb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so NewHttpClient() should move to another file - right ?

sztp-agent/pkg/secureagent/tls.go Dismissed Show dismissed Hide dismissed
@h0lyalg0rithm h0lyalg0rithm force-pushed the refactor_http_client branch 5 times, most recently from b8e5e6e to 0b7a567 Compare August 17, 2024 13:20
Signed-off-by: Suraj Shirvankar <[email protected]>
Copy link
Member

@glimchb glimchb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@glimchb
Copy link
Member

glimchb commented Sep 11, 2024

@h0lyalg0rithm I wanna merge this

This branch cannot be rebased due to conflicts

please rebase ?

@bhoopesh369
Copy link
Contributor

LGTM
if @h0lyalg0rithm is away for now, I'd be happy to cherry-pick the changes and open a new PR.

@glimchb glimchb merged commit 28e1a09 into opiproject:main Oct 7, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants