Skip to content

fix(constraint): Correct the message field to be failureMessage #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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