MCPcopy
hub / github.com/helm/helm / validatePluginName

Function validatePluginName

internal/plugin/installer/plugin_structure.go:56–80  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

54// validatePluginName checks if the plugin directory name matches the plugin name
55// from plugin.yaml when the plugin is in a subdirectory.
56func 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}

Callers 2

TestValidatePluginNameFunction · 0.85
InstallMethod · 0.85

Calls 2

LoadDirFunction · 0.92
MetadataMethod · 0.65

Tested by 1

TestValidatePluginNameFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…