validateHookName checks the grammar and uniqueness; returns false when the name was rejected (caller skips the action).
(hookName, kind string)
| 186 | // validateHookName checks the grammar and uniqueness; returns false |
| 187 | // when the name was rejected (caller skips the action). |
| 188 | func (b *Builder) validateHookName(hookName, kind string) bool { |
| 189 | if !pluginNamePattern.MatchString(hookName) { |
| 190 | b.errs = append(b.errs, fmt.Errorf( |
| 191 | "%s %q: hookName must match ^[a-z0-9][a-z0-9-]*$", kind, hookName)) |
| 192 | return false |
| 193 | } |
| 194 | if b.hookNames[hookName] { |
| 195 | b.errs = append(b.errs, fmt.Errorf( |
| 196 | "%s %q: hookName already used in this plugin", kind, hookName)) |
| 197 | return false |
| 198 | } |
| 199 | b.hookNames[hookName] = true |
| 200 | return true |
| 201 | } |
| 202 | |
| 203 | // builtPlugin is the Plugin implementation the builder emits. |
| 204 | type builtPlugin struct { |