MCPcopy
hub / github.com/containers/toolbox / IsContainerNameValid

Function IsContainerNameValid

src/pkg/utils/utils.go:752–761  ·  view source on GitHub ↗

IsContainerNameValid checks if the name of a container matches the right pattern

(containerName string)

Source from the content-addressed store, hash-verified

750
751// IsContainerNameValid checks if the name of a container matches the right pattern
752func IsContainerNameValid(containerName string) bool {
753 pattern := "^" + ContainerNameRegexp + "$"
754 matched, err := regexp.MatchString(pattern, containerName)
755 if err != nil {
756 panicMsg := fmt.Sprintf("failed to parse regular expression for container name: %v", err)
757 panic(panicMsg)
758 }
759
760 return matched
761}
762
763func IsInsideContainer() bool {
764 return PathExists("/run/.containerenv")

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…