Fix some warnings
This commit is contained in:
parent
ad6cbcbae2
commit
6b5b3eacdd
@ -176,7 +176,7 @@ type VariableValue struct {
|
|||||||
|
|
||||||
// Platforms that use this value. Only one of "Platform" and "Platforms" may be set.
|
// Platforms that use this value. Only one of "Platform" and "Platforms" may be set.
|
||||||
Platform string `yaml:"platform,omitempty" json:"platform,omitempty"`
|
Platform string `yaml:"platform,omitempty" json:"platform,omitempty"`
|
||||||
Platforms []string `yaml:"platforms,omitempty,flow" json:"platforms,omitempty,flow"`
|
Platforms []string `yaml:"platforms,omitempty,flow" json:"platforms,omitempty"`
|
||||||
|
|
||||||
// The actual value of the variable for this audience+platform.
|
// The actual value of the variable for this audience+platform.
|
||||||
Value string `yaml:"value" json:"value"`
|
Value string `yaml:"value" json:"value"`
|
||||||
@ -352,11 +352,8 @@ func (c *Conf) ExpandVariables(valueToExpand string, audience VariableAudience,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// checkVariables performs some basic checks on variable definitions.
|
// checkVariables performs some basic checks on variable definitions.
|
||||||
// Note that the returned error only reflects the last-found error.
|
// All errors are logged, not returned.
|
||||||
// All errors are logged, though.
|
func (c *Conf) checkVariables() {
|
||||||
func (c *Conf) checkVariables() error {
|
|
||||||
var err error
|
|
||||||
|
|
||||||
directionNames := []string{"oneway", "twoway"}
|
directionNames := []string{"oneway", "twoway"}
|
||||||
validDirections := map[string]bool{}
|
validDirections := map[string]bool{}
|
||||||
for _, direction := range directionNames {
|
for _, direction := range directionNames {
|
||||||
@ -370,7 +367,6 @@ func (c *Conf) checkVariables() error {
|
|||||||
Str("direction", variable.Direction).
|
Str("direction", variable.Direction).
|
||||||
Strs("validChoices", directionNames).
|
Strs("validChoices", directionNames).
|
||||||
Msg("variable has invalid direction")
|
Msg("variable has invalid direction")
|
||||||
err = ErrBadDirection
|
|
||||||
}
|
}
|
||||||
for valueIndex, value := range variable.Values {
|
for valueIndex, value := range variable.Values {
|
||||||
// No platforms at all.
|
// No platforms at all.
|
||||||
@ -379,7 +375,6 @@ func (c *Conf) checkVariables() error {
|
|||||||
Str("name", name).
|
Str("name", name).
|
||||||
Interface("value", value).
|
Interface("value", value).
|
||||||
Msg("variable has a platformless value")
|
Msg("variable has a platformless value")
|
||||||
err = ErrMissingVariablePlatform
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,8 +403,6 @@ func (c *Conf) checkVariables() error {
|
|||||||
variable.Values[valueIndex] = value
|
variable.Values[valueIndex] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conf) checkDatabase() {
|
func (c *Conf) checkDatabase() {
|
||||||
|
@ -60,8 +60,7 @@ func TestVariableValidation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
c.Variables["blender"] = platformless
|
c.Variables["blender"] = platformless
|
||||||
|
|
||||||
err := c.checkVariables()
|
c.checkVariables()
|
||||||
assert.Equal(t, ErrMissingVariablePlatform, err)
|
|
||||||
|
|
||||||
assert.Equal(t, c.Variables["blender"].Values[0].Value, "/path/to/blender")
|
assert.Equal(t, c.Variables["blender"].Values[0].Value, "/path/to/blender")
|
||||||
assert.Equal(t, c.Variables["blender"].Values[1].Value, "/valid/path/blender")
|
assert.Equal(t, c.Variables["blender"].Values[1].Value, "/valid/path/blender")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user