Skip to content

Update lifecycle.DownloadBinary to work with local file#5398

Merged
khanhtc1202 merged 1 commit intomasterfrom
support-download-local-file
Dec 9, 2024
Merged

Update lifecycle.DownloadBinary to work with local file#5398
khanhtc1202 merged 1 commit intomasterfrom
support-download-local-file

Conversation

@khanhtc1202
Copy link
Member

What this PR does:

Update lifecycle.DownloadBinary logic to work with local files. After this pr, pipedv1 can fetch plugins from a remote source (via HTTP protocol) or local files from another file path.

Why we need it:

Which issue(s) this PR fixes:

Part of #4980
Follow #5394

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com>
return "", fmt.Errorf("HTTP GET %s failed with error %d", url, resp.StatusCode)
}
switch u.Scheme {
case "http", "https":
Copy link
Member Author

@khanhtc1202 khanhtc1202 Dec 9, 2024

Choose a reason for hiding this comment

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

This makes the test easier since I don't want to mock the HTTPS server. The validation logic in the piped configuration remains to only allow the "https" and "file" schemes.

Copy link
Member

Choose a reason for hiding this comment

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

📝 It is difficult to test with https server because DownloadBinary uses http.Client{} internally and can't inject for now. So we can't use httptest.NewTLSServer.

Copy link
Member Author

Choose a reason for hiding this comment

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

@t-kikuc For the question you asked 🙏

Copy link
Member

Choose a reason for hiding this comment

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

@khanhtc1202

I got it.
binary.go allows http and https, PipedPlugin disallows http.

pipecd/pkg/configv1/piped.go

Lines 1328 to 1330 in dcecc2d

if u.Scheme != "file" && u.Scheme != "https" {
return errors.New("only file and https schemes are supported")
}

@khanhtc1202 khanhtc1202 enabled auto-merge (squash) December 9, 2024 04:42
@codecov
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 42.42424% with 19 lines in your changes missing coverage. Please review.

Project coverage is 25.76%. Comparing base (dcecc2d) to head (8bbba8e).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/lifecycle/binary.go 42.42% 13 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5398      +/-   ##
==========================================
+ Coverage   25.74%   25.76%   +0.02%     
==========================================
  Files         449      449              
  Lines       48401    48416      +15     
==========================================
+ Hits        12459    12474      +15     
+ Misses      34971    34969       -2     
- Partials      971      973       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

👍

return "", fmt.Errorf("HTTP GET %s failed with error %d", url, resp.StatusCode)
}
switch u.Scheme {
case "http", "https":
Copy link
Member

Choose a reason for hiding this comment

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

[ASK] Are we gonna support http too? or only https?

Copy link
Member Author

Choose a reason for hiding this comment

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

No we don't, just place http there to make testing process simpler 🙏

@khanhtc1202 khanhtc1202 merged commit 38af047 into master Dec 9, 2024
@khanhtc1202 khanhtc1202 deleted the support-download-local-file branch December 9, 2024 06:07
@github-actions github-actions bot mentioned this pull request Jan 21, 2025
@github-actions github-actions bot mentioned this pull request Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants