diff --git a/ignite/config/plugins/config.go b/ignite/config/plugins/config.go index 5142fd3818..5a3b4f7986 100644 --- a/ignite/config/plugins/config.go +++ b/ignite/config/plugins/config.go @@ -76,6 +76,11 @@ 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 @@ -83,7 +88,7 @@ func (p Plugin) IsGlobal() bool { // 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. diff --git a/ignite/services/plugin/plugin.go b/ignite/services/plugin/plugin.go index ac3696593a..6955d14ab7 100644 --- a/ignite/services/plugin/plugin.go +++ b/ignite/services/plugin/plugin.go @@ -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)