MCPcopy
hub / github.com/google/go-containerregistry / NewRepository

Function NewRepository

pkg/name/repository.go:79–109  ·  view source on GitHub ↗

NewRepository returns a new Repository representing the given name, according to the given strictness.

(name string, opts ...Option)

Source from the content-addressed store, hash-verified

77
78// NewRepository returns a new Repository representing the given name, according to the given strictness.
79func NewRepository(name string, opts ...Option) (Repository, error) {
80 opt := makeOptions(opts...)
81 if len(name) == 0 {
82 return Repository{}, newErrBadName("a repository name must be specified")
83 }
84
85 var registry string
86 repo := name
87 parts := strings.SplitN(name, regRepoDelimiter, 2)
88 maybeRegistry := parts[0]
89 if len(parts) == 2 && (maybeRegistry == "localhost" || strings.ContainsAny(maybeRegistry, ".:")) {
90 // The first part of the repository is treated as the registry domain
91 // if it is localhost or contains a '.' or ':' character, otherwise it
92 // is all repository and the domain defaults to Docker Hub.
93 registry = maybeRegistry
94 repo = parts[1]
95 }
96
97 if err := checkRepository(repo); err != nil {
98 return Repository{}, err
99 }
100
101 reg, err := NewRegistry(registry, opts...)
102 if err != nil {
103 return Repository{}, err
104 }
105 if hasImplicitNamespace(repo, reg) && opt.strict {
106 return Repository{}, newErrBadName("strict validation requires the full repository path (missing 'library')")
107 }
108 return Repository{reg, repo}, nil
109}
110
111// Tag returns a Tag in this Repository.
112func (r Repository) Tag(identifier string) Tag {

Callers 15

newCopierFunction · 0.92
renameMethod · 0.92
keychain_test.goFile · 0.92
repoFunction · 0.92
TestKubernetesAuthFunction · 0.92
TestListFunction · 0.92
TestCancelledListFunction · 0.92
TestGetNextPageURLFunction · 0.92
TestGetNextPageURL_SSRFFunction · 0.92
TestListFunction · 0.92
TestWalkFunction · 0.92
TestCancelledListFunction · 0.92

Calls 5

newErrBadNameFunction · 0.85
checkRepositoryFunction · 0.85
NewRegistryFunction · 0.85
hasImplicitNamespaceFunction · 0.85
makeOptionsFunction · 0.70

Tested by 15

repoFunction · 0.74
TestKubernetesAuthFunction · 0.74
TestListFunction · 0.74
TestCancelledListFunction · 0.74
TestGetNextPageURLFunction · 0.74
TestGetNextPageURL_SSRFFunction · 0.74
TestListFunction · 0.74
TestWalkFunction · 0.74
TestCancelledListFunction · 0.74
TestGetNextPageURLFunction · 0.74
TestGetNextPageURL_SSRFFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…