Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
be8c1448
Kaydet (Commit)
be8c1448
authored
Haz 22, 2017
tarafından
Joffrey F
Kaydeden (comit)
GitHub
Haz 22, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1662 from docker/1633-credhelpers-support
Support credHelpers section in config.json
üst
28e76a6f
320c8104
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
7 deletions
+74
-7
auth.py
docker/auth.py
+23
-7
auth_test.py
tests/unit/auth_test.py
+51
-0
No files found.
docker/auth.py
Dosyayı görüntüle @
be8c1448
...
@@ -70,6 +70,15 @@ def split_repo_name(repo_name):
...
@@ -70,6 +70,15 @@ def split_repo_name(repo_name):
return
tuple
(
parts
)
return
tuple
(
parts
)
def
get_credential_store
(
authconfig
,
registry
):
if
not
registry
or
registry
==
INDEX_NAME
:
registry
=
'https://index.docker.io/v1/'
return
authconfig
.
get
(
'credHelpers'
,
{})
.
get
(
registry
)
or
authconfig
.
get
(
'credsStore'
)
def
resolve_authconfig
(
authconfig
,
registry
=
None
):
def
resolve_authconfig
(
authconfig
,
registry
=
None
):
"""
"""
Returns the authentication data from the given auth configuration for a
Returns the authentication data from the given auth configuration for a
...
@@ -77,13 +86,17 @@ def resolve_authconfig(authconfig, registry=None):
...
@@ -77,13 +86,17 @@ def resolve_authconfig(authconfig, registry=None):
with full URLs are stripped down to hostnames before checking for a match.
with full URLs are stripped down to hostnames before checking for a match.
Returns None if no match was found.
Returns None if no match was found.
"""
"""
if
'credsStore'
in
authconfig
:
log
.
debug
(
if
'credHelpers'
in
authconfig
or
'credsStore'
in
authconfig
:
'Using credentials store "{0}"'
.
format
(
authconfig
[
'credsStore'
])
store_name
=
get_credential_store
(
authconfig
,
registry
)
)
if
store_name
is
not
None
:
return
_resolve_authconfig_credstore
(
log
.
debug
(
authconfig
,
registry
,
authconfig
[
'credsStore'
]
'Using credentials store "{0}"'
.
format
(
store_name
)
)
)
return
_resolve_authconfig_credstore
(
authconfig
,
registry
,
store_name
)
# Default to the public index server
# Default to the public index server
registry
=
resolve_index_name
(
registry
)
if
registry
else
INDEX_NAME
registry
=
resolve_index_name
(
registry
)
if
registry
else
INDEX_NAME
log
.
debug
(
"Looking for auth entry for {0}"
.
format
(
repr
(
registry
)))
log
.
debug
(
"Looking for auth entry for {0}"
.
format
(
repr
(
registry
)))
...
@@ -274,6 +287,9 @@ def load_config(config_path=None):
...
@@ -274,6 +287,9 @@ def load_config(config_path=None):
if
data
.
get
(
'credsStore'
):
if
data
.
get
(
'credsStore'
):
log
.
debug
(
"Found 'credsStore' section"
)
log
.
debug
(
"Found 'credsStore' section"
)
res
.
update
({
'credsStore'
:
data
[
'credsStore'
]})
res
.
update
({
'credsStore'
:
data
[
'credsStore'
]})
if
data
.
get
(
'credHelpers'
):
log
.
debug
(
"Found 'credHelpers' section"
)
res
.
update
({
'credHelpers'
:
data
[
'credHelpers'
]})
if
res
:
if
res
:
return
res
return
res
else
:
else
:
...
...
tests/unit/auth_test.py
Dosyayı görüntüle @
be8c1448
...
@@ -272,6 +272,57 @@ class ResolveAuthTest(unittest.TestCase):
...
@@ -272,6 +272,57 @@ class ResolveAuthTest(unittest.TestCase):
)
)
class
CredStoreTest
(
unittest
.
TestCase
):
def
test_get_credential_store
(
self
):
auth_config
=
{
'credHelpers'
:
{
'registry1.io'
:
'truesecret'
,
'registry2.io'
:
'powerlock'
},
'credsStore'
:
'blackbox'
,
}
assert
auth
.
get_credential_store
(
auth_config
,
'registry1.io'
)
==
'truesecret'
assert
auth
.
get_credential_store
(
auth_config
,
'registry2.io'
)
==
'powerlock'
assert
auth
.
get_credential_store
(
auth_config
,
'registry3.io'
)
==
'blackbox'
def
test_get_credential_store_no_default
(
self
):
auth_config
=
{
'credHelpers'
:
{
'registry1.io'
:
'truesecret'
,
'registry2.io'
:
'powerlock'
},
}
assert
auth
.
get_credential_store
(
auth_config
,
'registry2.io'
)
==
'powerlock'
assert
auth
.
get_credential_store
(
auth_config
,
'registry3.io'
)
is
None
def
test_get_credential_store_default_index
(
self
):
auth_config
=
{
'credHelpers'
:
{
'https://index.docker.io/v1/'
:
'powerlock'
},
'credsStore'
:
'truesecret'
}
assert
auth
.
get_credential_store
(
auth_config
,
None
)
==
'powerlock'
assert
auth
.
get_credential_store
(
auth_config
,
'docker.io'
)
==
'powerlock'
assert
auth
.
get_credential_store
(
auth_config
,
'images.io'
)
==
'truesecret'
class
FindConfigFileTest
(
unittest
.
TestCase
):
class
FindConfigFileTest
(
unittest
.
TestCase
):
def
tmpdir
(
self
,
name
):
def
tmpdir
(
self
,
name
):
tmpdir
=
ensuretemp
(
name
)
tmpdir
=
ensuretemp
(
name
)
...
...
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