config: Do not migrate config file if not needed. (#4264)

Also improve the error message returned by `pkg/quick`.

Fixes #4233
This commit is contained in:
Harshavardhana
2017-05-06 10:16:59 -07:00
committed by GitHub
parent 2df1e2e9a9
commit 610dbe3479
7 changed files with 214 additions and 91 deletions

View File

@@ -127,7 +127,7 @@ func (d config) Diff(c Config) ([]structs.Field, error) {
return fields, nil
}
//DeepDiff - list fields in A that are missing or not equal to fields in B
// DeepDiff - list fields in A that are missing or not equal to fields in B
func (d config) DeepDiff(c Config) ([]structs.Field, error) {
var fields []structs.Field
@@ -196,12 +196,22 @@ func New(data interface{}) (Config, error) {
return d, nil
}
// GetVersion - extracts the version information.
func GetVersion(filename string) (version string, err error) {
var qc Config
if qc, err = Load(filename, &struct {
Version string
}{}); err != nil {
return "", err
}
return qc.Version(), err
}
// Load - loads json config from filename for the a given struct data
func Load(filename string, data interface{}) (qc Config, err error) {
if qc, err = New(data); err == nil {
err = qc.Load(filename)
}
return qc, err
}