Skip to content

Commit

Permalink
fix(constraint): Correct the message field to be failureMessage (#211)
Browse files Browse the repository at this point in the history
The constraint EP uses `failureMessage`, not `message`. This is a
mistake that should be corrected.

Signed-off-by: Vu Dinh <vudinh@outlook.com>
  • Loading branch information
dinhxuanvu authored Jan 12, 2022
1 parent 3199880 commit 1602407
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions pkg/constraints/constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const OLMConstraintType = "olm.constraint"

// Constraint holds parsed, potentially nested dependency constraints.
type Constraint struct {
// Constraint message that surfaces in resolution
// Constraint failure message that surfaces in resolution
// This field is optional
Message string `json:"message,omitempty" yaml:"message,omitempty"`
FailureMessage string `json:"failureMessage,omitempty" yaml:"failureMessage,omitempty"`

// The cel struct that contraints CEL expression
Cel *Cel `json:"cel,omitempty" yaml:"cel,omitempty"`
Expand Down
48 changes: 24 additions & 24 deletions pkg/constraints/constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ func TestParse(t *testing.T) {
name: "Valid/BasicGVK",
input: json.RawMessage(inputBasicGVK),
expConstraint: Constraint{
Message: "blah",
GVK: &GVKConstraint{Group: "example.com", Version: "v1", Kind: "Foo"},
FailureMessage: "blah",
GVK: &GVKConstraint{Group: "example.com", Version: "v1", Kind: "Foo"},
},
},
{
name: "Valid/BasicPackage",
input: json.RawMessage(inputBasicPackage),
expConstraint: Constraint{
Message: "blah",
Package: &PackageConstraint{PackageName: "foo", VersionRange: ">=1.0.0"},
FailureMessage: "blah",
Package: &PackageConstraint{PackageName: "foo", VersionRange: ">=1.0.0"},
},
},
{
name: "Valid/BasicAll",
input: json.RawMessage(fmt.Sprintf(inputBasicCompoundTmpl, "all")),
expConstraint: Constraint{
Message: "blah",
FailureMessage: "blah",
All: &CompoundConstraint{
Constraints: []Constraint{
{
Message: "blah blah",
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
FailureMessage: "blah blah",
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
},
},
},
Expand All @@ -53,12 +53,12 @@ func TestParse(t *testing.T) {
name: "Valid/BasicAny",
input: json.RawMessage(fmt.Sprintf(inputBasicCompoundTmpl, "any")),
expConstraint: Constraint{
Message: "blah",
FailureMessage: "blah",
Any: &CompoundConstraint{
Constraints: []Constraint{
{
Message: "blah blah",
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
FailureMessage: "blah blah",
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
},
},
},
Expand All @@ -68,12 +68,12 @@ func TestParse(t *testing.T) {
name: "Valid/BasicNone",
input: json.RawMessage(fmt.Sprintf(inputBasicCompoundTmpl, "none")),
expConstraint: Constraint{
Message: "blah",
FailureMessage: "blah",
None: &CompoundConstraint{
Constraints: []Constraint{
{
Message: "blah blah",
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
FailureMessage: "blah blah",
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
},
},
},
Expand All @@ -83,13 +83,13 @@ func TestParse(t *testing.T) {
name: "Valid/Complex",
input: json.RawMessage(inputComplex),
expConstraint: Constraint{
Message: "blah",
FailureMessage: "blah",
All: &CompoundConstraint{
Constraints: []Constraint{
{Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"}},
{GVK: &GVKConstraint{Group: "fals.example.com", Kind: "Fal", Version: "v1"}},
{
Message: "foo and buf must be stable versions",
FailureMessage: "foo and buf must be stable versions",
All: &CompoundConstraint{
Constraints: []Constraint{
{Package: &PackageConstraint{PackageName: "foo", VersionRange: ">=1.0.0"}},
Expand All @@ -99,7 +99,7 @@ func TestParse(t *testing.T) {
},
},
{
Message: "blah blah",
FailureMessage: "blah blah",
Any: &CompoundConstraint{
Constraints: []Constraint{
{GVK: &GVKConstraint{Group: "foos.example.com", Kind: "Foo", Version: "v1beta1"}},
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestParse(t *testing.T) {
{
name: "Invalid/UnknownField",
input: json.RawMessage(
`{"message": "something", "arbitrary": {"key": "value"}}`,
`{"failureMessage": "something", "arbitrary": {"key": "value"}}`,
),
expError: `json: unknown field "arbitrary"`,
},
Expand All @@ -153,7 +153,7 @@ func TestParse(t *testing.T) {

const (
inputBasicGVK = `{
"message": "blah",
"failureMessage": "blah",
"gvk": {
"group": "example.com",
"version": "v1",
Expand All @@ -162,19 +162,19 @@ const (
}`

inputBasicPackage = `{
"message": "blah",
"failureMessage": "blah",
"package": {
"packageName": "foo",
"versionRange": ">=1.0.0"
}
}`

inputBasicCompoundTmpl = `{
"message": "blah",
"failureMessage": "blah",
"%s": {
"constraints": [
{
"message": "blah blah",
"failureMessage": "blah blah",
"package": {
"packageName": "fuz",
"versionRange": ">=1.0.0"
Expand All @@ -185,7 +185,7 @@ const (
`

inputComplex = `{
"message": "blah",
"failureMessage": "blah",
"all": {
"constraints": [
{
Expand All @@ -202,7 +202,7 @@ const (
}
},
{
"message": "foo and buf must be stable versions",
"failureMessage": "foo and buf must be stable versions",
"all": {
"constraints": [
{
Expand All @@ -228,7 +228,7 @@ const (
}
},
{
"message": "blah blah",
"failureMessage": "blah blah",
"any": {
"constraints": [
{
Expand Down

0 comments on commit 1602407

Please sign in to comment.