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
a7e328c2
Commit
a7e328c2
authored
Jul 20, 2018
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix acr sp access issue
parent
b68c9440
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
19 deletions
+29
-19
azure_credentials.go
pkg/credentialprovider/azure/azure_credentials.go
+20
-16
azure_credentials_test.go
pkg/credentialprovider/azure/azure_credentials_test.go
+9
-3
No files found.
pkg/credentialprovider/azure/azure_credentials.go
View file @
a7e328c2
...
@@ -40,6 +40,8 @@ var flagConfigFile = pflag.String("azure-container-registry-config", "",
...
@@ -40,6 +40,8 @@ var flagConfigFile = pflag.String("azure-container-registry-config", "",
const
dummyRegistryEmail
=
"name@contoso.com"
const
dummyRegistryEmail
=
"name@contoso.com"
var
containerRegistryUrls
=
[]
string
{
"*.azurecr.io"
,
"*.azurecr.cn"
,
"*.azurecr.de"
,
"*.azurecr.us"
}
// init registers the various means by which credentials may
// init registers the various means by which credentials may
// be resolved on Azure.
// be resolved on Azure.
func
init
()
{
func
init
()
{
...
@@ -176,31 +178,33 @@ func (a *acrProvider) Provide() credentialprovider.DockerConfig {
...
@@ -176,31 +178,33 @@ func (a *acrProvider) Provide() credentialprovider.DockerConfig {
ctx
,
cancel
:=
getContextWithCancel
()
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
defer
cancel
()
glog
.
V
(
4
)
.
Infof
(
"listing registries"
)
if
a
.
config
.
UseManagedIdentityExtension
{
result
,
err
:=
a
.
registryClient
.
List
(
ctx
)
glog
.
V
(
4
)
.
Infof
(
"listing registries"
)
if
err
!=
nil
{
result
,
err
:=
a
.
registryClient
.
List
(
ctx
)
glog
.
Errorf
(
"Failed to list registries: %v"
,
err
)
if
err
!=
nil
{
return
cfg
glog
.
Errorf
(
"Failed to list registries: %v"
,
err
)
}
return
cfg
}
for
ix
:=
range
result
{
loginServer
:=
getLoginServer
(
result
[
ix
])
var
cred
*
credentialprovider
.
DockerConfigEntry
if
a
.
config
.
UseManagedIdentityExtension
{
for
ix
:=
range
result
{
cred
,
err
=
getACRDockerEntryFromARMToken
(
a
,
loginServer
)
loginServer
:=
getLoginServer
(
result
[
ix
])
glog
.
V
(
2
)
.
Infof
(
"loginServer: %s"
,
loginServer
)
cred
,
err
:=
getACRDockerEntryFromARMToken
(
a
,
loginServer
)
if
err
!=
nil
{
if
err
!=
nil
{
continue
continue
}
}
}
else
{
cfg
[
loginServer
]
=
*
cred
cred
=
&
credentialprovider
.
DockerConfigEntry
{
}
}
else
{
// Add our entry for each of the supported container registry URLs
for
_
,
url
:=
range
containerRegistryUrls
{
cred
:=
&
credentialprovider
.
DockerConfigEntry
{
Username
:
a
.
config
.
AADClientID
,
Username
:
a
.
config
.
AADClientID
,
Password
:
a
.
config
.
AADClientSecret
,
Password
:
a
.
config
.
AADClientSecret
,
Email
:
dummyRegistryEmail
,
Email
:
dummyRegistryEmail
,
}
}
cfg
[
url
]
=
*
cred
}
}
cfg
[
loginServer
]
=
*
cred
}
}
return
cfg
return
cfg
}
}
...
...
pkg/credentialprovider/azure/azure_credentials_test.go
View file @
a7e328c2
...
@@ -43,19 +43,25 @@ func Test(t *testing.T) {
...
@@ -43,19 +43,25 @@ func Test(t *testing.T) {
{
{
Name
:
to
.
StringPtr
(
"foo"
),
Name
:
to
.
StringPtr
(
"foo"
),
RegistryProperties
:
&
containerregistry
.
RegistryProperties
{
RegistryProperties
:
&
containerregistry
.
RegistryProperties
{
LoginServer
:
to
.
StringPtr
(
"
foo-microsoft
.azurecr.io"
),
LoginServer
:
to
.
StringPtr
(
"
*
.azurecr.io"
),
},
},
},
},
{
{
Name
:
to
.
StringPtr
(
"bar"
),
Name
:
to
.
StringPtr
(
"bar"
),
RegistryProperties
:
&
containerregistry
.
RegistryProperties
{
RegistryProperties
:
&
containerregistry
.
RegistryProperties
{
LoginServer
:
to
.
StringPtr
(
"
bar-microsoft.azurecr.io
"
),
LoginServer
:
to
.
StringPtr
(
"
*.azurecr.cn
"
),
},
},
},
},
{
{
Name
:
to
.
StringPtr
(
"baz"
),
Name
:
to
.
StringPtr
(
"baz"
),
RegistryProperties
:
&
containerregistry
.
RegistryProperties
{
RegistryProperties
:
&
containerregistry
.
RegistryProperties
{
LoginServer
:
to
.
StringPtr
(
"baz-microsoft.azurecr.io"
),
LoginServer
:
to
.
StringPtr
(
"*.azurecr.de"
),
},
},
{
Name
:
to
.
StringPtr
(
"bus"
),
RegistryProperties
:
&
containerregistry
.
RegistryProperties
{
LoginServer
:
to
.
StringPtr
(
"*.azurecr.us"
),
},
},
},
},
}
}
...
...
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