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
988a413a
Commit
988a413a
authored
Jun 05, 2015
by
Quinton Hoole
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9058 from deads2k/serialize-with-auth
serialize dockercfg with matching auth field
parents
21db71db
ac2c43fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
+8
-10
config.go
pkg/credentialprovider/config.go
+7
-7
config_test.go
pkg/credentialprovider/config_test.go
+1
-3
No files found.
pkg/credentialprovider/config.go
View file @
988a413a
...
@@ -175,6 +175,13 @@ func (ident *DockerConfigEntry) UnmarshalJSON(data []byte) error {
...
@@ -175,6 +175,13 @@ func (ident *DockerConfigEntry) UnmarshalJSON(data []byte) error {
return
err
return
err
}
}
func
(
ident
DockerConfigEntry
)
MarshalJSON
()
([]
byte
,
error
)
{
toEncode
:=
dockerConfigEntryWithAuth
{
ident
.
Username
,
ident
.
Password
,
ident
.
Email
,
""
}
toEncode
.
Auth
=
encodeDockerConfigFieldAuth
(
ident
.
Username
,
ident
.
Password
)
return
json
.
Marshal
(
toEncode
)
}
// decodeDockerConfigFieldAuth deserializes the "auth" field from dockercfg into a
// decodeDockerConfigFieldAuth deserializes the "auth" field from dockercfg into a
// username and a password. The format of the auth field is base64(<username>:<password>).
// username and a password. The format of the auth field is base64(<username>:<password>).
func
decodeDockerConfigFieldAuth
(
field
string
)
(
username
,
password
string
,
err
error
)
{
func
decodeDockerConfigFieldAuth
(
field
string
)
(
username
,
password
string
,
err
error
)
{
...
@@ -195,13 +202,6 @@ func decodeDockerConfigFieldAuth(field string) (username, password string, err e
...
@@ -195,13 +202,6 @@ func decodeDockerConfigFieldAuth(field string) (username, password string, err e
return
return
}
}
func
(
ident
DockerConfigEntry
)
ConvertToDockerConfigCompatible
()
dockerConfigEntryWithAuth
{
ret
:=
dockerConfigEntryWithAuth
{
ident
.
Username
,
ident
.
Password
,
ident
.
Email
,
""
}
ret
.
Auth
=
encodeDockerConfigFieldAuth
(
ident
.
Username
,
ident
.
Password
)
return
ret
}
func
encodeDockerConfigFieldAuth
(
username
,
password
string
)
string
{
func
encodeDockerConfigFieldAuth
(
username
,
password
string
)
string
{
fieldValue
:=
username
+
":"
+
password
fieldValue
:=
username
+
":"
+
password
...
...
pkg/credentialprovider/config_test.go
View file @
988a413a
...
@@ -184,9 +184,7 @@ func TestDockerConfigEntryJSONCompatibleEncode(t *testing.T) {
...
@@ -184,9 +184,7 @@ func TestDockerConfigEntryJSONCompatibleEncode(t *testing.T) {
}
}
for
i
,
tt
:=
range
tests
{
for
i
,
tt
:=
range
tests
{
toEncode
:=
tt
.
input
.
ConvertToDockerConfigCompatible
()
actual
,
err
:=
json
.
Marshal
(
tt
.
input
)
actual
,
err
:=
json
.
Marshal
(
toEncode
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"case %d: unexpected error: %v"
,
i
,
err
)
t
.
Errorf
(
"case %d: unexpected error: %v"
,
i
,
err
)
}
}
...
...
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