Skip to content

Commit

Permalink
fix builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeland73 committed Feb 26, 2024
1 parent dd716a7 commit 8aaec6b
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/devbox/devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ func (d *Devbox) AllInstallablePackages() ([]*devpkg.Package, error) {
func (d *Devbox) Includes() []plugin.Includable {
includes := []plugin.Includable{}
for _, includePath := range d.cfg.Include() {
if include, err := plugin.Parse(includePath); err == nil {
if include, err := d.pluginManager.ParseInclude(includePath); err == nil {
includes = append(includes, include)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (p *githubPlugin) FileContent(subpath string) ([]byte, error) {
p.Owner,
p.Repo,
lo.Ternary(p.Rev == "", "master", p.Rev),
p.withFilename(p.Dir),
p.Dir,
subpath,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestNewGithubPlugin(t *testing.T) {

for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
actual, _ := Parse(testCase.Include)
actual, _ := parseReflike(testCase.Include)
assert.Equal(t, &testCase.expected, actual)
})
}
Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (m *Manager) InitHooks(
allPkgs = append(allPkgs, pkg)
}
for _, include := range includes {
name, err := Parse(include)
name, err := m.ParseInclude(include)
if err != nil {
return nil, err
}
Expand Down
14 changes: 14 additions & 0 deletions internal/plugin/includes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package plugin

import (
"strings"

"go.jetpack.io/devbox/internal/devpkg"
)

func (m *Manager) ParseInclude(include string) (Includable, error) {
if t, name, _ := strings.Cut(include, ":"); t == "plugin" {
return devpkg.PackageFromStringWithDefaults(name, m.lockfile), nil
}
return parseReflike(include)
}
4 changes: 2 additions & 2 deletions internal/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *config) Services() (services.Services, error) {
}

func (m *Manager) Include(included string) error {
name, err := Parse(included)
name, err := m.ParseInclude(included)
if err != nil {
return err
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func (m *Manager) Env(
allPkgs = append(allPkgs, pkg)
}
for _, included := range includes {
input, err := Parse(included)
input, err := m.ParseInclude(included)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/reflike.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Includable interface {
FileContent(subpath string) ([]byte, error)
}

func Parse(s string) (Includable, error) {
func parseReflike(s string) (Includable, error) {
ref, err := flake.ParseRef(s)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (m *Manager) GetServices(
allPkgs = append(allPkgs, pkg)
}
for _, include := range includes {
name, err := Parse(include)
name, err := m.ParseInclude(include)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 8aaec6b

Please sign in to comment.