Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
Fixes a bug introduced while renaming a policy check param.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasell committed Nov 28, 2019
1 parent 488cd15 commit 8acc621
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions pkg/state/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ type PolicyCheck struct {
// not.
Enabled bool `json:"Enabled"`

// ScaleResource identifies the Nomad resource which will be checked within this policy check
// Resource identifies the Nomad resource which will be checked within this policy check
// evaluation.
Resource ScaleResource `json:"ScaleResource"`
Resource ScaleResource `json:"Resource"`

// ComparisonOperator determines how the value if compared to the theshold.
ComparisonOperator ComparisonOperator `json:"ComparisonOperator"`
Expand Down Expand Up @@ -90,15 +90,15 @@ func (c ClientScalingPolicy) Validate() error {
// rather than collecting.
for name, check := range c.Checks {
if err := check.Resource.Validate(); err != nil {
return errors.Wrap(err, "failed to validate check"+name)
return errors.Wrap(err, "failed to validate check: "+name)
}

if err := check.ComparisonOperator.Validate(); err != nil {
return errors.Wrap(err, "failed to validate check"+name)
return errors.Wrap(err, "failed to validate check: "+name)
}

if err := check.Action.Validate(); err != nil {
return errors.Wrap(err, "failed to validate check"+name)
return errors.Wrap(err, "failed to validate check: "+name)
}
}
return nil
Expand All @@ -118,7 +118,7 @@ func (c ClientProvider) Validate() error {
case AWSAutoScaling:
return nil
default:
return errors.Errorf("unsupported client provider %s", c.String())
return errors.Errorf("unsupported client provider \"%s\"", c.String())
}
}

Expand All @@ -140,7 +140,7 @@ func (co ComparisonOperator) Validate() error {
case ComparisonGreaterThan, ComparisonLessThan:
return nil
default:
return errors.Errorf("ComparisonOperator %s is not a valid option", co.String())
return errors.Errorf("ComparisonOperator \"%s\" is not a valid option", co.String())
}
}

Expand All @@ -162,7 +162,7 @@ func (ca ComparisonAction) Validate() error {
case ActionScaleIn, ActionScaleOut:
return nil
default:
return errors.Errorf("Action %s is not a valid option", ca.String())
return errors.Errorf("Action \"%s\" is not a valid option", ca.String())
}
}

Expand All @@ -186,7 +186,7 @@ func (r ScaleResource) Validate() error {
case ScaleResourceCPU, ScaleResourceMemory:
return nil
default:
return errors.Errorf("ScaleResource %s is not a valid option", r.String())
return errors.Errorf("ScaleResource \"%s\" is not a valid option", r.String())
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/state/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestClientProvider_Validate(t *testing.T) {
},
{
inputClientProvider: fakeProvider,
expectedOutput: errors.New("unsupported client provider fake"),
expectedOutput: errors.New("unsupported client provider \"fake\""),
name: "invalid scaling provider",
},
}
Expand Down

0 comments on commit 8acc621

Please sign in to comment.