Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
760caea1
Commit
760caea1
authored
Jun 01, 2015
by
Eric Tune
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8863 from mfojtik/fix-default-registry-matcher
Add 'docker.io' and 'index.docker.io' to default registry matcher
parents
e0886e04
9a94f7cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
keyring.go
pkg/credentialprovider/keyring.go
+9
-0
keyring_test.go
pkg/credentialprovider/keyring_test.go
+20
-0
No files found.
pkg/credentialprovider/keyring.go
View file @
760caea1
...
...
@@ -108,11 +108,20 @@ const defaultRegistryHost = "index.docker.io/v1/"
func
isDefaultRegistryMatch
(
image
string
)
bool
{
parts
:=
strings
.
SplitN
(
image
,
"/"
,
2
)
if
len
(
parts
[
0
])
==
0
{
return
false
}
if
len
(
parts
)
==
1
{
// e.g. library/ubuntu
return
true
}
if
parts
[
0
]
==
"docker.io"
||
parts
[
0
]
==
"index.docker.io"
{
// resolve docker.io/image and index.docker.io/image as default registry
return
true
}
// From: http://blog.docker.com/2013/07/how-to-use-your-own-registry/
// Docker looks for either a “.” (domain separator) or “:” (port separator)
// to learn that the first part of the repository name is a location and not
...
...
pkg/credentialprovider/keyring_test.go
View file @
760caea1
...
...
@@ -413,6 +413,26 @@ func TestKeyringHitWithQualifiedDockerHub(t *testing.T) {
}
}
func
TestIsDefaultRegistryMatch
(
t
*
testing
.
T
)
{
samples
:=
[]
map
[
bool
]
string
{
{
true
:
"foo/bar"
},
{
true
:
"docker.io/foo/bar"
},
{
true
:
"index.docker.io/foo/bar"
},
{
true
:
"foo"
},
{
false
:
""
},
{
false
:
"registry.tld/foo/bar"
},
{
false
:
"registry:5000/foo/bar"
},
{
false
:
"myhostdocker.io/foo/bar"
},
}
for
_
,
sample
:=
range
samples
{
for
expected
,
imageName
:=
range
sample
{
if
got
:=
isDefaultRegistryMatch
(
imageName
);
got
!=
expected
{
t
.
Errorf
(
"Expected '%s' to be %s, got %s"
,
imageName
,
expected
,
got
)
}
}
}
}
type
testProvider
struct
{
Count
int
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment