Skip to content

Commit 4e78dbe

Browse files
committed
Report ambiguous syscfg configuration
This addresses: #565
1 parent b2468d9 commit 4e78dbe

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

newt/cli/target_cmds.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ func pkgVarSliceString(pack *pkg.LocalPackage, key string) string {
9797
func amendSysCfg(value string, t *target.Target) error {
9898
// Get the current syscfg.vals name-value pairs
9999
sysVals, err := t.Package().SyscfgY.GetValStringMapString("syscfg.vals", nil)
100-
util.OneTimeWarningError(err)
100+
if err != nil {
101+
return err
102+
}
101103

102104
// Convert the input syscfg into name-value pairs
103105
amendSysVals, err := syscfg.KeyValueFromStr(value)

newt/syscfg/syscfg.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,9 @@ func (cfg *Cfg) readValsOnce(lpkg *pkg.LocalPackage,
708708
lsettings := cfg.settingsForLpkg(lpkg, settings)
709709

710710
values, err := yc.GetValStringMap("syscfg.vals", lsettings)
711-
util.OneTimeWarningError(err)
711+
if err != nil {
712+
return err
713+
}
712714

713715
for k, v := range values {
714716
switch v.(type) {

newt/ycfg/ycfg.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,13 @@ func (yc *YCfg) GetStringMap(
469469
Expr: mapEntry.Expr,
470470
}
471471

472-
// XXX: Report collisions?
472+
if _, exists := result[k]; exists {
473+
if (entry.Value != result[k].Value) && (result[k].Expr != nil) {
474+
return nil, fmt.Errorf("Setting %s collision - two conditions true:\n[%s, %s]\n"+
475+
"Conflicting file: %s",
476+
k, entry.Expr.String(), result[k].Expr.String(), yc.name)
477+
}
478+
}
473479
result[k] = entry
474480
}
475481
}
@@ -607,7 +613,13 @@ func (yc *YCfg) GetStringMapString(key string,
607613
Expr: mapEntry.Expr,
608614
}
609615

610-
// XXX: Report collisions?
616+
if _, exists := result[k]; exists {
617+
if (entry.Value != result[k].Value) && (result[k].Expr != nil) {
618+
return nil, fmt.Errorf("Setting %s collision - two conditions true:\n[%s, %s]\n"+
619+
"Conflicting file: %s",
620+
k, entry.Expr.String(), result[k].Expr.String(), yc.name)
621+
}
622+
}
611623
result[k] = entry
612624
}
613625
}
@@ -623,6 +635,9 @@ func (yc *YCfg) GetValStringMapString(key string,
623635
settings *cfgv.Settings) (map[string]string, error) {
624636

625637
entryMap, getErr := yc.GetStringMapString(key, settings)
638+
if getErr != nil {
639+
return nil, getErr
640+
}
626641

627642
valMap := make(map[string]string, len(entryMap))
628643
for k, v := range entryMap {
@@ -631,7 +646,7 @@ func (yc *YCfg) GetValStringMapString(key string,
631646
}
632647
}
633648

634-
return valMap, getErr
649+
return valMap, nil
635650
}
636651

637652
// FullName calculates a node's name with the following form:

0 commit comments

Comments
 (0)