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

Commit

Permalink
Merge pull request #53 from pmcatominey/policy-get-panic
Browse files Browse the repository at this point in the history
pkg/policy: fix panic in get policy by job and group
  • Loading branch information
jrasell authored Sep 26, 2019
2 parents 7ad44ee + 3857923 commit 0d6c67c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/policy/backend/consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ func (p *PolicyBackend) GetJobGroupPolicy(job, group string) (*policy.GroupScali
return nil, err
}

if kv == nil {
return nil, nil
}

out := &policy.GroupScalingPolicy{}

if err := json.Unmarshal(kv.Value, out); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/policy/v1/policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (p *Policy) GetJobGroupPolicy(w http.ResponseWriter, r *http.Request) {
return
}

if *gPolicy == (policy.GroupScalingPolicy{}) || gPolicy == nil {
if gPolicy == nil || *gPolicy == (policy.GroupScalingPolicy{}) {
http.NotFound(w, r)
return
}
Expand Down

0 comments on commit 0d6c67c

Please sign in to comment.