Commit 63597af8 authored by Aneesh Agrawal's avatar Aneesh Agrawal

Clarify the plugin discovery search & priority orders.

parent fc6b78b8
...@@ -49,11 +49,13 @@ func decodeConfig(r io.Reader, c *config) error { ...@@ -49,11 +49,13 @@ func decodeConfig(r io.Reader, c *config) error {
// Discover discovers plugins. // Discover discovers plugins.
// //
// This looks in the directory of the executable and the CWD, in that // Search the directory of the executable, then the plugins directory, and
// order for priority. // finally the CWD, in that order. Any conflicts will overwrite previously
// found plugins, in that order.
// Hence, the priority order is the reverse of the search order - i.e., the
// CWD has the highest priority.
func (c *config) Discover() error { func (c *config) Discover() error {
// Next, look in the same directory as the executable. Any conflicts // First, look in the same directory as the executable.
// will overwrite those found in our current directory.
exePath, err := osext.Executable() exePath, err := osext.Executable()
if err != nil { if err != nil {
log.Printf("[ERR] Error loading exe directory: %s", err) log.Printf("[ERR] Error loading exe directory: %s", err)
...@@ -63,7 +65,7 @@ func (c *config) Discover() error { ...@@ -63,7 +65,7 @@ func (c *config) Discover() error {
} }
} }
// Look in the plugins directory // Next, look in the plugins directory.
dir, err := ConfigDir() dir, err := ConfigDir()
if err != nil { if err != nil {
log.Printf("[ERR] Error loading config directory: %s", err) log.Printf("[ERR] Error loading config directory: %s", err)
...@@ -73,7 +75,7 @@ func (c *config) Discover() error { ...@@ -73,7 +75,7 @@ func (c *config) Discover() error {
} }
} }
// Look in the cwd. // Last, look in the CWD.
if err := c.discover("."); err != nil { if err := c.discover("."); err != nil {
return err return err
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment