diff --git a/pkg/constraints/constraint.go b/pkg/constraints/constraint.go index bbce6b188..d59d04542 100644 --- a/pkg/constraints/constraint.go +++ b/pkg/constraints/constraint.go @@ -38,22 +38,22 @@ type Constraint struct { // CompoundConstraint holds a list of potentially nested constraints // over which a boolean operation is applied. type CompoundConstraint struct { - Constraints []Constraint `json:"constraints"` + Constraints []Constraint `json:"constraints" yaml:"constraints"` } // GVKConstraint defines a GVK constraint. type GVKConstraint struct { - Group string `json:"group"` - Kind string `json:"kind"` - Version string `json:"version"` + Group string `json:"group" yaml:"group"` + Kind string `json:"kind" yaml:"kind"` + Version string `json:"version" yaml:"version"` } // PackageConstraint defines a package constraint. type PackageConstraint struct { - // Name of the package. - Name string `json:"name"` + // PackageName is the name of the package. + PackageName string `json:"packageName" yaml:"packageName"` // VersionRange required for the package. - VersionRange string `json:"versionRange"` + VersionRange string `json:"versionRange" yaml:"versionRange"` } // maxConstraintSize defines the maximum raw size in bytes of an olm.constraint. diff --git a/pkg/constraints/constraint_test.go b/pkg/constraints/constraint_test.go index c2bc0138a..b35e36fa0 100644 --- a/pkg/constraints/constraint_test.go +++ b/pkg/constraints/constraint_test.go @@ -31,7 +31,7 @@ func TestParse(t *testing.T) { input: json.RawMessage(inputBasicPackage), expConstraint: Constraint{ Message: "blah", - Package: &PackageConstraint{Name: "foo", VersionRange: ">=1.0.0"}, + Package: &PackageConstraint{PackageName: "foo", VersionRange: ">=1.0.0"}, }, }, { @@ -43,7 +43,7 @@ func TestParse(t *testing.T) { Constraints: []Constraint{ { Message: "blah blah", - Package: &PackageConstraint{Name: "fuz", VersionRange: ">=1.0.0"}, + Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"}, }, }, }, @@ -58,7 +58,7 @@ func TestParse(t *testing.T) { Constraints: []Constraint{ { Message: "blah blah", - Package: &PackageConstraint{Name: "fuz", VersionRange: ">=1.0.0"}, + Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"}, }, }, }, @@ -73,7 +73,7 @@ func TestParse(t *testing.T) { Constraints: []Constraint{ { Message: "blah blah", - Package: &PackageConstraint{Name: "fuz", VersionRange: ">=1.0.0"}, + Package: &PackageConstraint{PackageName: "fuz", VersionRange: ">=1.0.0"}, }, }, }, @@ -86,14 +86,14 @@ func TestParse(t *testing.T) { Message: "blah", All: &CompoundConstraint{ Constraints: []Constraint{ - {Package: &PackageConstraint{Name: "fuz", VersionRange: ">=1.0.0"}}, + {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", All: &CompoundConstraint{ Constraints: []Constraint{ - {Package: &PackageConstraint{Name: "foo", VersionRange: ">=1.0.0"}}, - {Package: &PackageConstraint{Name: "buf", VersionRange: ">=1.0.0"}}, + {Package: &PackageConstraint{PackageName: "foo", VersionRange: ">=1.0.0"}}, + {Package: &PackageConstraint{PackageName: "buf", VersionRange: ">=1.0.0"}}, {GVK: &GVKConstraint{Group: "foos.example.com", Kind: "Foo", Version: "v1"}}, }, }, @@ -164,7 +164,7 @@ const ( inputBasicPackage = `{ "message": "blah", "package": { - "name": "foo", + "packageName": "foo", "versionRange": ">=1.0.0" } }` @@ -176,7 +176,7 @@ const ( { "message": "blah blah", "package": { - "name": "fuz", + "packageName": "fuz", "versionRange": ">=1.0.0" } } @@ -190,7 +190,7 @@ const ( "constraints": [ { "package": { - "name": "fuz", + "packageName": "fuz", "versionRange": ">=1.0.0" } }, @@ -207,13 +207,13 @@ const ( "constraints": [ { "package": { - "name": "foo", + "packageName": "foo", "versionRange": ">=1.0.0" } }, { "package": { - "name": "buf", + "packageName": "buf", "versionRange": ">=1.0.0" } },