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

[plugins] Use reflikes for plugins #1845

Merged
merged 24 commits into from
Feb 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use cmp.Or
  • Loading branch information
mikeland73 committed Feb 28, 2024
commit 1bf645a3dd00f0d7e70537bdffb11e41513d1a96
6 changes: 3 additions & 3 deletions internal/plugin/github.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package plugin

import (
"cmp"
"io"
"net/http"
"net/url"

"github.com/samber/lo"
"go.jetpack.io/devbox/internal/boxcli/usererr"
"go.jetpack.io/devbox/internal/cachehash"
)
Expand All @@ -28,7 +28,7 @@ func (p *githubPlugin) Fetch() ([]byte, error) {
"https://raw.githubusercontent.com/",
p.Owner,
p.Repo,
lo.Ternary(p.Rev == "", "master", p.Rev),
cmp.Or(p.Rev, "master"),
p.withFilename(p.Dir),
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure I follow: why are we passing in p.Dir (a directory) as an argument for withFilename?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

different plugin types have different fields represent the path. Local plugins use Path while github plugins use Dir

Maybe a cleaner solution could be to implement a configPath() function for each type. (though they would still both have some duplicate code)

)
if err != nil {
Expand Down Expand Up @@ -68,7 +68,7 @@ func (p *githubPlugin) FileContent(subpath string) ([]byte, error) {
"https://raw.githubusercontent.com/",
p.Owner,
p.Repo,
lo.Ternary(p.Rev == "", "master", p.Rev),
cmp.Or(p.Rev, "master"),
p.Dir,
subpath,
)
Expand Down