Merge pull request #2599 from thaJeztah/ignore_empty_configfile

config: ignore empty config file instead of printing warning
This commit is contained in:
Silvin Lubecki 2020-07-09 15:27:29 +02:00 committed by GitHub
commit cae16e70b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 5 deletions

View File

@ -3,7 +3,6 @@ package config
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
@ -13,7 +12,6 @@ import (
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/cli/config/credentials"
"github.com/pkg/errors"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/env"
@ -89,8 +87,7 @@ func TestEmptyFile(t *testing.T) {
assert.NilError(t, err)
_, err = Load(tmpHome)
assert.Assert(t, errors.Is(err, io.EOF))
assert.ErrorContains(t, err, ConfigFileName)
assert.NilError(t, err)
}
func TestEmptyJSON(t *testing.T) {

View File

@ -118,7 +118,7 @@ func (configFile *ConfigFile) LegacyLoadFromReader(configData io.Reader) error {
// LoadFromReader reads the configuration data given and sets up the auth config
// information with given directory and populates the receiver object
func (configFile *ConfigFile) LoadFromReader(configData io.Reader) error {
if err := json.NewDecoder(configData).Decode(&configFile); err != nil {
if err := json.NewDecoder(configData).Decode(&configFile); err != nil && !errors.Is(err, io.EOF) {
return err
}
var err error