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
Show file tree
Hide file tree
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
Fix lint issue
  • Loading branch information
mikeland73 committed Feb 26, 2024
commit dd716a77953a234e85aee707ac5c1044914e9504
4 changes: 2 additions & 2 deletions internal/plugin/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ type githubPlugin struct {
RefLike
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of embedding the struct, could we make it an explicit field to distinguish methods/fields that are from RefLike versus native to githubPlugin?

But its tolerable if it means having to re-implement a lot of methods unnecessarily

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can make that change. It does mean that plugin.Repo becomes plugin.ref.Repo so the code is a big uglier. (There's roughly 12 callsites in this file that would change)

}

func newGithubPlugin(ref RefLike) (*githubPlugin, error) {
func newGithubPlugin(ref RefLike) *githubPlugin {
if ref.Ref.Ref == "" && ref.Rev == "" {
ref.Ref.Ref = "master"
}
return &githubPlugin{RefLike: ref}, nil
return &githubPlugin{RefLike: ref}
}

func (p *githubPlugin) Fetch() ([]byte, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/reflike.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Parse(s string) (Includable, error) {
case flake.TypePath:
return newLocalPlugin(reflike)
case flake.TypeGitHub:
return newGithubPlugin(reflike)
return newGithubPlugin(reflike), nil
default:
return nil, fmt.Errorf("unsupported ref type %q", ref.Type)
}
Expand Down