Skip to content

Commit

Permalink
chore: comments of #4125 (#4135)
Browse files Browse the repository at this point in the history
* fix(plugins): correct relative path support

* updates

* helper

---------

Co-authored-by: Danilo Pantani <[email protected]>
  • Loading branch information
julienrbrt and Pantani committed May 29, 2024
1 parent cd82f94 commit 8fa6f94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ignite/config/plugins/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,19 @@ func RemoveDuplicates(plugins []Plugin) (unique []Plugin) {
return unique
}

// IsLocalPath returns true if the path is a local directory.
func IsLocalPath(path string) bool {
return strings.HasPrefix(path, "/") || strings.HasPrefix(path, ".") || strings.HasPrefix(path, "~")
}

// IsGlobal returns whether the plugin is installed globally or locally for a chain.
func (p Plugin) IsGlobal() bool {
return p.Global
}

// IsLocalPath returns true if the plugin path is a local directory.
func (p Plugin) IsLocalPath() bool {
return strings.HasPrefix(p.Path, "/") || strings.HasPrefix(p.Path, ".") || strings.HasPrefix(p.Path, "~")
return IsLocalPath(p.Path)
}

// HasPath verifies if a plugin has the given path regardless of version.
Expand Down
2 changes: 1 addition & 1 deletion ignite/services/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func newPlugin(pluginsDir string, cp pluginsconfig.Plugin, options ...Option) *P
}

// This is a local plugin, check if the file exists
if tp := (&Plugin{Plugin: pluginsconfig.Plugin{Path: pluginPath}}); tp.IsLocalPath() {
if pluginsconfig.IsLocalPath(pluginPath) {
// if directory is relative, make it absolute
if !filepath.IsAbs(pluginPath) {
pluginPathAbs, err := filepath.Abs(pluginPath)
Expand Down

0 comments on commit 8fa6f94

Please sign in to comment.