mirror of https://github.com/docker/compose.git
Fix credential checking on ACR image (for linux)
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
e5e87d3357
commit
a72ffee4ff
|
@ -83,7 +83,7 @@ func getRegistryCredentials(project compose.Project, registryLoader registryConf
|
||||||
hostname = parsedURL.Path
|
hostname = parsedURL.Path
|
||||||
}
|
}
|
||||||
if _, ok := usedRegistries[hostname]; ok {
|
if _, ok := usedRegistries[hostname]; ok {
|
||||||
if oneCred.Username != "" {
|
if oneCred.Password != "" {
|
||||||
aciCredential := containerinstance.ImageRegistryCredential{
|
aciCredential := containerinstance.ImageRegistryCredential{
|
||||||
Server: to.StringPtr(hostname),
|
Server: to.StringPtr(hostname),
|
||||||
Password: to.StringPtr(oneCred.Password),
|
Password: to.StringPtr(oneCred.Password),
|
||||||
|
@ -91,10 +91,14 @@ func getRegistryCredentials(project compose.Project, registryLoader registryConf
|
||||||
}
|
}
|
||||||
registryCreds = append(registryCreds, aciCredential)
|
registryCreds = append(registryCreds, aciCredential)
|
||||||
} else if oneCred.IdentityToken != "" {
|
} else if oneCred.IdentityToken != "" {
|
||||||
|
userName := tokenUsername
|
||||||
|
if oneCred.Username != "" {
|
||||||
|
userName = oneCred.Username
|
||||||
|
}
|
||||||
aciCredential := containerinstance.ImageRegistryCredential{
|
aciCredential := containerinstance.ImageRegistryCredential{
|
||||||
Server: to.StringPtr(hostname),
|
Server: to.StringPtr(hostname),
|
||||||
Password: to.StringPtr(oneCred.IdentityToken),
|
Password: to.StringPtr(oneCred.IdentityToken),
|
||||||
Username: to.StringPtr(tokenUsername),
|
Username: to.StringPtr(userName),
|
||||||
}
|
}
|
||||||
registryCreds = append(registryCreds, aciCredential)
|
registryCreds = append(registryCreds, aciCredential)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package convert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/Azure/go-autorest/autorest/to"
|
"github.com/Azure/go-autorest/autorest/to"
|
||||||
"github.com/compose-spec/compose-go/types"
|
"github.com/compose-spec/compose-go/types"
|
||||||
|
@ -27,8 +28,6 @@ import (
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/profiles/latest/containerinstance/mgmt/containerinstance"
|
"github.com/Azure/azure-sdk-for-go/profiles/latest/containerinstance/mgmt/containerinstance"
|
||||||
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
@ -101,6 +100,22 @@ func (suite *RegistryConvertTestSuite) TestAcrPrivateImage() {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *RegistryConvertTestSuite) TestAcrPrivateImageLinux() {
|
||||||
|
token := tokenCreds("123456")
|
||||||
|
token.Username = tokenUsername
|
||||||
|
suite.loader.On(getAllCredentials).Return(registry("https://mycontainerregistrygta.azurecr.io", token), nil)
|
||||||
|
|
||||||
|
creds, err := getRegistryCredentials(composeServices("mycontainerregistrygta.azurecr.io/privateimg"), suite.loader)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
Expect(creds).To(Equal([]containerinstance.ImageRegistryCredential{
|
||||||
|
{
|
||||||
|
Server: to.StringPtr("mycontainerregistrygta.azurecr.io"),
|
||||||
|
Username: to.StringPtr(tokenUsername),
|
||||||
|
Password: to.StringPtr("123456"),
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
func (suite *RegistryConvertTestSuite) TestNoMoreRegistriesThanImages() {
|
func (suite *RegistryConvertTestSuite) TestNoMoreRegistriesThanImages() {
|
||||||
configs := map[string]cliconfigtypes.AuthConfig{
|
configs := map[string]cliconfigtypes.AuthConfig{
|
||||||
"https://mycontainerregistrygta.azurecr.io": tokenCreds("123456"),
|
"https://mycontainerregistrygta.azurecr.io": tokenCreds("123456"),
|
||||||
|
|
Loading…
Reference in New Issue