validatePluginName checks if the plugin directory name matches the plugin name from plugin.yaml when the plugin is in a subdirectory.
(pluginRoot string, expectedName string)
| 54 | // validatePluginName checks if the plugin directory name matches the plugin name |
| 55 | // from plugin.yaml when the plugin is in a subdirectory. |
| 56 | func validatePluginName(pluginRoot string, expectedName string) error { |
| 57 | // Only validate if plugin is in a subdirectory |
| 58 | dirName := filepath.Base(pluginRoot) |
| 59 | if dirName == expectedName { |
| 60 | return nil |
| 61 | } |
| 62 | |
| 63 | // Load plugin.yaml to get the actual name |
| 64 | p, err := plugin.LoadDir(pluginRoot) |
| 65 | if err != nil { |
| 66 | return fmt.Errorf("failed to load plugin from %s: %w", pluginRoot, err) |
| 67 | } |
| 68 | |
| 69 | m := p.Metadata() |
| 70 | actualName := m.Name |
| 71 | |
| 72 | // For now, just log a warning if names don't match |
| 73 | // In the future, we might want to enforce this more strictly |
| 74 | if actualName != dirName && actualName != strings.TrimSuffix(expectedName, filepath.Ext(expectedName)) { |
| 75 | // This is just informational - not an error |
| 76 | return nil |
| 77 | } |
| 78 | |
| 79 | return nil |
| 80 | } |
searching dependent graphs…