Skip to content

Commit 1602407

Browse files
authored
fix(constraint): Correct the message field to be failureMessage (#211)
The constraint EP uses `failureMessage`, not `message`. This is a mistake that should be corrected. Signed-off-by: Vu Dinh <[email protected]>
1 parent 3199880 commit 1602407

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

pkg/constraints/constraint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const OLMConstraintType = "olm.constraint"
1212

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

1919
// The cel struct that contraints CEL expression
2020
Cel *Cel `json:"cel,omitempty" yaml:"cel,omitempty"`

pkg/constraints/constraint_test.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,28 @@ func TestParse(t *testing.T) {
2222
name: "Valid/BasicGVK",
2323
input: json.RawMessage(inputBasicGVK),
2424
expConstraint: Constraint{
25-
Message: "blah",
26-
GVK: &GVKConstraint{Group: "example.com", Version: "v1", Kind: "Foo"},
25+
FailureMessage: "blah",
26+
GVK: &GVKConstraint{Group: "example.com", Version: "v1", Kind: "Foo"},
2727
},
2828
},
2929
{
3030
name: "Valid/BasicPackage",
3131
input: json.RawMessage(inputBasicPackage),
3232
expConstraint: Constraint{
33-
Message: "blah",
34-
Package: &PackageConstraint{PackageName: "foo", VersionRange: ">=1.0.0"},
33+
FailureMessage: "blah",
34+
Package: &PackageConstraint{PackageName: "foo", VersionRange: ">=1.0.0"},
3535
},
3636
},
3737
{
3838
name: "Valid/BasicAll",
3939
input: json.RawMessage(fmt.Sprintf(inputBasicCompoundTmpl, "all")),
4040
expConstraint: Constraint{
41-
Message: "blah",
41+
FailureMessage: "blah",
4242
All: &CompoundConstraint{
4343
Constraints: []Constraint{
4444
{
45-
Message: "blah blah",
46-
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
45+
FailureMessage: "blah blah",
46+
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
4747
},
4848
},
4949
},
@@ -53,12 +53,12 @@ func TestParse(t *testing.T) {
5353
name: "Valid/BasicAny",
5454
input: json.RawMessage(fmt.Sprintf(inputBasicCompoundTmpl, "any")),
5555
expConstraint: Constraint{
56-
Message: "blah",
56+
FailureMessage: "blah",
5757
Any: &CompoundConstraint{
5858
Constraints: []Constraint{
5959
{
60-
Message: "blah blah",
61-
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
60+
FailureMessage: "blah blah",
61+
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
6262
},
6363
},
6464
},
@@ -68,12 +68,12 @@ func TestParse(t *testing.T) {
6868
name: "Valid/BasicNone",
6969
input: json.RawMessage(fmt.Sprintf(inputBasicCompoundTmpl, "none")),
7070
expConstraint: Constraint{
71-
Message: "blah",
71+
FailureMessage: "blah",
7272
None: &CompoundConstraint{
7373
Constraints: []Constraint{
7474
{
75-
Message: "blah blah",
76-
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
75+
FailureMessage: "blah blah",
76+
Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"},
7777
},
7878
},
7979
},
@@ -83,13 +83,13 @@ func TestParse(t *testing.T) {
8383
name: "Valid/Complex",
8484
input: json.RawMessage(inputComplex),
8585
expConstraint: Constraint{
86-
Message: "blah",
86+
FailureMessage: "blah",
8787
All: &CompoundConstraint{
8888
Constraints: []Constraint{
8989
{Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"}},
9090
{GVK: &GVKConstraint{Group: "fals.example.com", Kind: "Fal", Version: "v1"}},
9191
{
92-
Message: "foo and buf must be stable versions",
92+
FailureMessage: "foo and buf must be stable versions",
9393
All: &CompoundConstraint{
9494
Constraints: []Constraint{
9595
{Package: &PackageConstraint{PackageName: "foo", VersionRange: ">=1.0.0"}},
@@ -99,7 +99,7 @@ func TestParse(t *testing.T) {
9999
},
100100
},
101101
{
102-
Message: "blah blah",
102+
FailureMessage: "blah blah",
103103
Any: &CompoundConstraint{
104104
Constraints: []Constraint{
105105
{GVK: &GVKConstraint{Group: "foos.example.com", Kind: "Foo", Version: "v1beta1"}},
@@ -132,7 +132,7 @@ func TestParse(t *testing.T) {
132132
{
133133
name: "Invalid/UnknownField",
134134
input: json.RawMessage(
135-
`{"message": "something", "arbitrary": {"key": "value"}}`,
135+
`{"failureMessage": "something", "arbitrary": {"key": "value"}}`,
136136
),
137137
expError: `json: unknown field "arbitrary"`,
138138
},
@@ -153,7 +153,7 @@ func TestParse(t *testing.T) {
153153

154154
const (
155155
inputBasicGVK = `{
156-
"message": "blah",
156+
"failureMessage": "blah",
157157
"gvk": {
158158
"group": "example.com",
159159
"version": "v1",
@@ -162,19 +162,19 @@ const (
162162
}`
163163

164164
inputBasicPackage = `{
165-
"message": "blah",
165+
"failureMessage": "blah",
166166
"package": {
167167
"packageName": "foo",
168168
"versionRange": ">=1.0.0"
169169
}
170170
}`
171171

172172
inputBasicCompoundTmpl = `{
173-
"message": "blah",
173+
"failureMessage": "blah",
174174
"%s": {
175175
"constraints": [
176176
{
177-
"message": "blah blah",
177+
"failureMessage": "blah blah",
178178
"package": {
179179
"packageName": "fuz",
180180
"versionRange": ">=1.0.0"
@@ -185,7 +185,7 @@ const (
185185
`
186186

187187
inputComplex = `{
188-
"message": "blah",
188+
"failureMessage": "blah",
189189
"all": {
190190
"constraints": [
191191
{
@@ -202,7 +202,7 @@ const (
202202
}
203203
},
204204
{
205-
"message": "foo and buf must be stable versions",
205+
"failureMessage": "foo and buf must be stable versions",
206206
"all": {
207207
"constraints": [
208208
{
@@ -228,7 +228,7 @@ const (
228228
}
229229
},
230230
{
231-
"message": "blah blah",
231+
"failureMessage": "blah blah",
232232
"any": {
233233
"constraints": [
234234
{

0 commit comments

Comments
 (0)