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
01ccaa6a
Kaydet (Commit)
01ccaa6a
authored
Kas 30, 2018
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make AuthConfig a dict subclass for backward-compatibility
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
bc5d7c8c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
auth.py
docker/auth.py
+11
-7
auth_test.py
tests/unit/auth_test.py
+2
-2
No files found.
docker/auth.py
Dosyayı görüntüle @
01ccaa6a
...
@@ -43,7 +43,7 @@ def get_config_header(client, registry):
...
@@ -43,7 +43,7 @@ def get_config_header(client, registry):
log
.
debug
(
log
.
debug
(
"No auth config in memory - loading from filesystem"
"No auth config in memory - loading from filesystem"
)
)
client
.
_auth_configs
=
load_config
()
client
.
_auth_configs
=
load_config
(
credstore_env
=
client
.
credstore_env
)
authcfg
=
resolve_authconfig
(
authcfg
=
resolve_authconfig
(
client
.
_auth_configs
,
registry
,
credstore_env
=
client
.
credstore_env
client
.
_auth_configs
,
registry
,
credstore_env
=
client
.
credstore_env
)
)
...
@@ -70,14 +70,16 @@ def split_repo_name(repo_name):
...
@@ -70,14 +70,16 @@ def split_repo_name(repo_name):
def
get_credential_store
(
authconfig
,
registry
):
def
get_credential_store
(
authconfig
,
registry
):
if
not
isinstance
(
authconfig
,
AuthConfig
):
authconfig
=
AuthConfig
(
authconfig
)
return
authconfig
.
get_credential_store
(
registry
)
return
authconfig
.
get_credential_store
(
registry
)
class
AuthConfig
(
obje
ct
):
class
AuthConfig
(
di
ct
):
def
__init__
(
self
,
dct
,
credstore_env
=
None
):
def
__init__
(
self
,
dct
,
credstore_env
=
None
):
if
'auths'
not
in
dct
:
if
'auths'
not
in
dct
:
dct
[
'auths'
]
=
{}
dct
[
'auths'
]
=
{}
self
.
_dct
=
dct
self
.
update
(
dct
)
self
.
_credstore_env
=
credstore_env
self
.
_credstore_env
=
credstore_env
self
.
_stores
=
{}
self
.
_stores
=
{}
...
@@ -200,15 +202,15 @@ class AuthConfig(object):
...
@@ -200,15 +202,15 @@ class AuthConfig(object):
@property
@property
def
auths
(
self
):
def
auths
(
self
):
return
self
.
_dct
.
get
(
'auths'
,
{})
return
self
.
get
(
'auths'
,
{})
@property
@property
def
creds_store
(
self
):
def
creds_store
(
self
):
return
self
.
_dct
.
get
(
'credsStore'
,
None
)
return
self
.
get
(
'credsStore'
,
None
)
@property
@property
def
cred_helpers
(
self
):
def
cred_helpers
(
self
):
return
self
.
_dct
.
get
(
'credHelpers'
,
{})
return
self
.
get
(
'credHelpers'
,
{})
def
resolve_authconfig
(
self
,
registry
=
None
):
def
resolve_authconfig
(
self
,
registry
=
None
):
"""
"""
...
@@ -305,10 +307,12 @@ class AuthConfig(object):
...
@@ -305,10 +307,12 @@ class AuthConfig(object):
return
auth_data
return
auth_data
def
add_auth
(
self
,
reg
,
data
):
def
add_auth
(
self
,
reg
,
data
):
self
.
_dct
[
'auths'
][
reg
]
=
data
self
[
'auths'
][
reg
]
=
data
def
resolve_authconfig
(
authconfig
,
registry
=
None
,
credstore_env
=
None
):
def
resolve_authconfig
(
authconfig
,
registry
=
None
,
credstore_env
=
None
):
if
not
isinstance
(
authconfig
,
AuthConfig
):
authconfig
=
AuthConfig
(
authconfig
,
credstore_env
)
return
authconfig
.
resolve_authconfig
(
registry
)
return
authconfig
.
resolve_authconfig
(
registry
)
...
...
tests/unit/auth_test.py
Dosyayı görüntüle @
01ccaa6a
...
@@ -466,7 +466,7 @@ class LoadConfigTest(unittest.TestCase):
...
@@ -466,7 +466,7 @@ class LoadConfigTest(unittest.TestCase):
json
.
dump
(
config
,
f
)
json
.
dump
(
config
,
f
)
cfg
=
auth
.
load_config
(
dockercfg_path
)
cfg
=
auth
.
load_config
(
dockercfg_path
)
assert
cfg
.
_dct
==
{
'auths'
:
{}}
assert
dict
(
cfg
)
==
{
'auths'
:
{}}
def
test_load_config_invalid_auth_dict
(
self
):
def
test_load_config_invalid_auth_dict
(
self
):
folder
=
tempfile
.
mkdtemp
()
folder
=
tempfile
.
mkdtemp
()
...
@@ -481,7 +481,7 @@ class LoadConfigTest(unittest.TestCase):
...
@@ -481,7 +481,7 @@ class LoadConfigTest(unittest.TestCase):
json
.
dump
(
config
,
f
)
json
.
dump
(
config
,
f
)
cfg
=
auth
.
load_config
(
dockercfg_path
)
cfg
=
auth
.
load_config
(
dockercfg_path
)
assert
cfg
.
_dct
==
{
'auths'
:
{
'scarlet.net'
:
{}}}
assert
dict
(
cfg
)
==
{
'auths'
:
{
'scarlet.net'
:
{}}}
def
test_load_config_identity_token
(
self
):
def
test_load_config_identity_token
(
self
):
folder
=
tempfile
.
mkdtemp
()
folder
=
tempfile
.
mkdtemp
()
...
...
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