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

Add optional headers to DownloadableFile messages when downloading files #306

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RichardChukwu
Copy link

Fixes #299

This PR implements the recent specification change that allows for optional headers in the DownloadableFile message, which can be used during file downloads to support authentication and other header-based configurations.

The downloadFile function in the packagesSyncer struct has been modified to include optional headers from the DownloadableFile message. This enhancement allows Agents to set custom HTTP headers when downloading files from the server. For instance, headers such as Authorization can now be included to facilitate secure downloads.

Changes Made:

-Updated the downloadFile method to check for the presence of optional headers in the DownloadableFile message.
-Added logic to incorporate these headers into the HTTP request when downloading files.
-Ensured compatibility with the updated protocol specification that outlines the use of headers for authentication and other purposes.

@RichardChukwu RichardChukwu requested a review from a team as a code owner October 23, 2024 13:21
@@ -280,6 +280,13 @@ func (s *packagesSyncer) downloadFile(ctx context.Context, pkgName string, file
return fmt.Errorf("cannot download file from %s: %v", file.DownloadUrl, err)
}

// Add optional headers if they exist
if file.Headers != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Can we verify this functionality in the tests, somewhere around

func TestUpdatePackages(t *testing.T) {
?

Copy link
Author

Choose a reason for hiding this comment

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

Let me see

Copy link
Author

@RichardChukwu RichardChukwu Oct 23, 2024

Choose a reason for hiding this comment

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

Kindly check the latest update. I did notice though that the opamp.proto file though is in a separate repo which makes it difficult for testing locally when working on this repo.

@tigrannajaryan tigrannajaryan changed the title "Add optional headers to DownloadableFile messages when downloading files" Add optional headers to DownloadableFile messages when downloading files Oct 23, 2024
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.

Use optional headers in DownloadableFile messages when fetching files
2 participants