Repository: helm/helm
File: pkg/plugin/plugin.go (Go)

Code before:
	cmds := p.Metadata.PlatformCommand
	if len(cmds) == 0 && len(p.Metadata.Command) > 0 {
		cmds = []PlatformCommand{{Command: p.Metadata.Command}}
	}

	return PrepareCommands(cmds, true, extraArgsIn)
}

// validPluginName is a regular expression that validates plugin names.
//
// Plugin names can only contain the ASCII characters a-z, A-Z, 0-9, ​_​ and ​-.
var validPluginName = regexp.MustCompile("^[A-Za-z0-9_-]+$")

// validatePluginData validates a plugin's YAML data.
func validatePluginData(plug *Plugin, filepath string) error {
	// When metadata section missing, initialize with no data
	if plug.Metadata == nil {
		plug.Metadata = &Metadata{}
	}
	if !validPluginName.MatchString(plug.Metadata.Name) {
		return fmt.Errorf("invalid plugin name at %q", filepath)
	}
	plug.Metadata.Usage = sanitizeString(plug.Metadata.Usage)

	if len(plug.Metadata.PlatformCommand) > 0 && len(plug.Metadata.Command) > 0 {
		fmt.Printf("both platformCommand and command are set in %q. It's deprecated and will not be possible in Helm v4\n", filepath)
	}

	if len(plug.Metadata.PlatformHooks) > 0 && len(plug.Metadata.Hooks) > 0 {
		fmt.Printf("both platformHooks and hooks are set in %q. It's deprecated and will not be possible in Helm v4\n", filepath)
	}

	// We could also validate SemVer, executable, and other fields should we so choose.
	return nil
}

// sanitizeString normalize spaces and removes non-printable characters.
func sanitizeString(str string) string {
	return strings.Map(func(r rune) rune {
		if unicode.IsSpace(r) {
			return ' '
		}
		if unicode.IsPrint(r) {
			return r
		}
		return -1
	}, str)
}

func detectDuplicates(plugs []*Plugin) error {
	names := map[string]string{}

Review comment (suggestion):
```suggestion
		fmt.Printf("WARNING: both 'platformCommand' and 'command' are set in %q (this will become an error in a future Helm version)\n", filepath)
```

Code after:
	cmds := p.Metadata.PlatformCommand
	if len(cmds) == 0 && len(p.Metadata.Command) > 0 {
		cmds = []PlatformCommand{{Command: p.Metadata.Command}}
	}

	return PrepareCommands(cmds, true, extraArgsIn)
}

// validPluginName is a regular expression that validates plugin names.
//
// Plugin names can only contain the ASCII characters a-z, A-Z, 0-9, ​_​ and ​-.
var validPluginName = regexp.MustCompile("^[A-Za-z0-9_-]+$")

// validatePluginData validates a plugin's YAML data.
func validatePluginData(plug *Plugin, filepath string) error {
	// When metadata section missing, initialize with no data
	if plug.Metadata == nil {
		plug.Metadata = &Metadata{}
	}
	if !validPluginName.MatchString(plug.Metadata.Name) {
		return fmt.Errorf("invalid plugin name at %q", filepath)
	}
	plug.Metadata.Usage = sanitizeString(plug.Metadata.Usage)

	if len(plug.Metadata.PlatformCommand) > 0 && len(plug.Metadata.Command) > 0 {
		fmt.Printf("WARNING: both 'platformCommand' and 'command' are set in %q (this will become an error in a future Helm version)\n", filepath)
	}

	if len(plug.Metadata.PlatformHooks) > 0 && len(plug.Metadata.Hooks) > 0 {
		fmt.Printf("WARNING: both 'platformHooks' and 'hooks' are set in %q (this will become an error in a future Helm version)\n", filepath)
	}

	// We could also validate SemVer, executable, and other fields should we so choose.
	return nil
}

// sanitizeString normalize spaces and removes non-printable characters.
func sanitizeString(str string) string {
	return strings.Map(func(r rune) rune {
		if unicode.IsSpace(r) {
			return ' '
		}
		if unicode.IsPrint(r) {
			return r
		}
		return -1
	}, str)
}

func detectDuplicates(plugs []*Plugin) error {
	names := map[string]string{}