MCPcopy
hub / github.com/helm/helm / Validate

Method Validate

internal/plugin/metadata.go:61–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59}
60
61func (m Metadata) Validate() error {
62 var errs []error
63
64 if !validPluginName.MatchString(m.Name) {
65 errs = append(errs, fmt.Errorf("invalid plugin name %q: must contain only a-z, A-Z, 0-9, _ and -", m.Name))
66 }
67
68 // Require version to be valid semver if specified
69 if m.Version != "" && !isValidSemver(m.Version) {
70 errs = append(errs, fmt.Errorf("invalid plugin version %q: must be valid semver", m.Version))
71 }
72
73 if m.APIVersion == "" {
74 errs = append(errs, errors.New("empty APIVersion"))
75 }
76
77 if m.Type == "" {
78 errs = append(errs, errors.New("empty type field"))
79 }
80
81 if m.Runtime == "" {
82 errs = append(errs, errors.New("empty runtime field"))
83 }
84
85 if m.Config == nil {
86 errs = append(errs, errors.New("missing config field"))
87 }
88
89 if m.RuntimeConfig == nil {
90 errs = append(errs, errors.New("missing runtimeConfig field"))
91 }
92
93 // Validate the config itself
94 if m.Config != nil {
95 if err := m.Config.Validate(); err != nil {
96 errs = append(errs, fmt.Errorf("config validation failed: %w", err))
97 }
98 }
99
100 // Validate the runtime config itself
101 if m.RuntimeConfig != nil {
102 if err := m.RuntimeConfig.Validate(); err != nil {
103 errs = append(errs, fmt.Errorf("runtime config validation failed: %w", err))
104 }
105 }
106
107 if len(errs) > 0 {
108 return errors.Join(errs...)
109 }
110
111 return nil
112}
113
114func fromMetadataLegacy(m MetadataLegacy) *Metadata {
115 pluginType := "cli/v1"

Callers 1

Calls 2

isValidSemverFunction · 0.70
ValidateMethod · 0.65

Tested by 1