MCPcopy Create free account
hub / github.com/containers/image / WithName

Function WithName

docker/reference/reference.go:254–267  ·  view source on GitHub ↗

WithName returns a named object representing the given string. If the input is invalid ErrReferenceInvalidFormat will be returned.

(name string)

Source from the content-addressed store, hash-verified

252// WithName returns a named object representing the given string. If the input
253// is invalid ErrReferenceInvalidFormat will be returned.
254func WithName(name string) (Named, error) {
255 if len(name) > NameTotalLengthMax {
256 return nil, ErrNameTooLong
257 }
258
259 match := anchoredNameRegexp.FindStringSubmatch(name)
260 if match == nil || len(match) != 3 {
261 return nil, ErrReferenceInvalidFormat
262 }
263 return repository{
264 domain: match[1],
265 path: match[2],
266 }, nil
267}
268
269// WithTag combines the name from "name" and the tag from "tag" to form a
270// reference incorporating both the name and the tag.

Callers 5

ParseDockerRefFunction · 0.85
TestWithNameFailureFunction · 0.85
TestSplitHostnameFunction · 0.85
TestWithTagFunction · 0.85
TestWithDigestFunction · 0.85

Calls 1

FindStringSubmatchMethod · 0.80

Tested by 4

TestWithNameFailureFunction · 0.68
TestSplitHostnameFunction · 0.68
TestWithTagFunction · 0.68
TestWithDigestFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…