Skip to content

Commit

Permalink
PolicyFromSpec: return nil on error
Browse files Browse the repository at this point in the history
Returning nil wrapped in Policy interface along with error returns in an
interface with a nil value. This can't be used to perform a nil check.
To make it safe, turn nil value on error.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
  • Loading branch information
darkowlzz committed Sep 20, 2021
1 parent 687ece4 commit 17c2981
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/policy/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ func PolicerFromSpec(choice imagev1.ImagePolicyChoice) (Policer, error) {
return nil, fmt.Errorf("given ImagePolicyChoice object is invalid")
}

return p, err
if err != nil {
return nil, err
}
return p, nil
}

0 comments on commit 17c2981

Please sign in to comment.