mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-22 08:43:44 +02:00
Create constant for Docker conf location
This commit is contained in:
@@ -53,6 +53,7 @@ type withUserAgent struct {
|
||||
|
||||
const (
|
||||
UpstreamClientUaKey = "UPSTREAM_CLIENT_TYPE"
|
||||
DockerConfLocation = "/kaniko/.docker/config.json"
|
||||
)
|
||||
|
||||
func (w *withUserAgent) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||
@@ -129,7 +130,7 @@ func CheckPushPermissions(opts *config.KanikoOptions) error {
|
||||
if strings.Contains(destRef.RegistryStr(), "gcr.io") {
|
||||
// Checking for existence of docker.config as it's normally required for
|
||||
// authenticated registries and prevent overwriting user provided docker conf
|
||||
if _, err := fs.Stat("/kaniko/.docker/config.json"); os.IsNotExist(err) {
|
||||
if _, err := fs.Stat(DockerConfLocation); os.IsNotExist(err) {
|
||||
if err := execCommand("docker-credential-gcr", "configure-docker").Run(); err != nil {
|
||||
return errors.Wrap(err, "error while configuring docker-credential-gcr helper")
|
||||
}
|
||||
|
||||
@@ -334,7 +334,6 @@ func TestCheckPushPermissionsGCR(t *testing.T) {
|
||||
Destinations: []string{"gcr.io/test-image"},
|
||||
}
|
||||
fs = afero.NewMemMapFs()
|
||||
//afero.WriteFile(fs, "/kaniko/.docker/config.json", []byte(""), os.FileMode(0644))
|
||||
CheckPushPermissions(&opts)
|
||||
if called != true {
|
||||
t.Error("execCommand should have been called")
|
||||
@@ -350,7 +349,7 @@ func TestCheckPushPermissionsGCRExistingDockerConf(t *testing.T) {
|
||||
Destinations: []string{"gcr.io/test-image"},
|
||||
}
|
||||
fs = afero.NewMemMapFs()
|
||||
afero.WriteFile(fs, "/kaniko/.docker/config.json", []byte(""), os.FileMode(0644))
|
||||
afero.WriteFile(fs, DockerConfLocation, []byte(""), os.FileMode(0644))
|
||||
CheckPushPermissions(&opts)
|
||||
if called != false {
|
||||
t.Error("execCommand should not have been called")
|
||||
|
||||
Reference in New Issue
Block a user