MCPcopy Create free account
hub / github.com/docker/cli / ValidateContextName

Function ValidateContextName

cli/context/store/store.go:216–227  ·  view source on GitHub ↗

ValidateContextName checks a context name is valid.

(name string)

Source from the content-addressed store, hash-verified

214
215// ValidateContextName checks a context name is valid.
216func ValidateContextName(name string) error {
217 if name == "" {
218 return errors.New("context name cannot be empty")
219 }
220 if name == "default" {
221 return errors.New(`"default" is a reserved context name`)
222 }
223 if !isValidName(name) {
224 return fmt.Errorf("context name %q is invalid, names are validated against regexp %q", name, validNameFormat)
225 }
226 return nil
227}
228
229// validNameFormat is used as part of errors for invalid context-names.
230// We should consider making this less technical ("must start with "a-z",

Callers 2

parseMetadataFunction · 0.85
TestValidateContextNameFunction · 0.85

Calls 1

isValidNameFunction · 0.85

Tested by 1

TestValidateContextNameFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…