Skip to content

Commit 48782d9

Browse files
committed
crdupgradesafety: fixup apiextensionsv1 import aliases
Signed-off-by: Joe Lanford <[email protected]>
1 parent 1ff946a commit 48782d9

File tree

3 files changed

+85
-85
lines changed

3 files changed

+85
-85
lines changed

internal/operator-controller/rukpak/preflights/crdupgradesafety/change_validator.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"reflect"
1212

1313
"github.com/openshift/crd-schema-checker/pkg/manifestcomparators"
14-
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
14+
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1515
"k8s.io/apimachinery/pkg/util/validation/field"
1616
)
1717

@@ -46,7 +46,7 @@ func (cv *ChangeValidator) Name() string {
4646
//
4747
// Additionally, any changes that are not validated and handled by the known ChangeValidations
4848
// are deemed as unsafe and returns an error.
49-
func (cv *ChangeValidator) Validate(old, new v1.CustomResourceDefinition) error {
49+
func (cv *ChangeValidator) Validate(old, new apiextensionsv1.CustomResourceDefinition) error {
5050
errs := []error{}
5151
for _, version := range old.Spec.Versions {
5252
newVersion := manifestcomparators.GetVersionByName(&new, version.Name)
@@ -89,12 +89,12 @@ func (cv *ChangeValidator) Validate(old, new v1.CustomResourceDefinition) error
8989
}
9090

9191
type FieldDiff struct {
92-
Old *v1.JSONSchemaProps
93-
New *v1.JSONSchemaProps
92+
Old *apiextensionsv1.JSONSchemaProps
93+
New *apiextensionsv1.JSONSchemaProps
9494
}
9595

9696
// FlatSchema is a flat representation of a CRD schema.
97-
type FlatSchema map[string]*v1.JSONSchemaProps
97+
type FlatSchema map[string]*apiextensionsv1.JSONSchemaProps
9898

9999
// FlattenSchema takes in a CRD version OpenAPIV3Schema and returns
100100
// a flattened representation of it. For example, a CRD with a schema of:
@@ -113,22 +113,22 @@ type FlatSchema map[string]*v1.JSONSchemaProps
113113
// ```
114114
// would be represented as:
115115
//
116-
// map[string]*v1.JSONSchemaProps{
116+
// map[string]*apiextensionsv1.JSONSchemaProps{
117117
// "^": {},
118118
// "^.spec": {},
119119
// "^.spec.foo": {},
120120
// "^.spec.bar": {},
121121
// }
122122
//
123123
// where "^" represents the "root" schema
124-
func FlattenSchema(schema *v1.JSONSchemaProps) FlatSchema {
125-
fieldMap := map[string]*v1.JSONSchemaProps{}
124+
func FlattenSchema(schema *apiextensionsv1.JSONSchemaProps) FlatSchema {
125+
fieldMap := map[string]*apiextensionsv1.JSONSchemaProps{}
126126

127127
manifestcomparators.SchemaHas(schema,
128128
field.NewPath("^"),
129129
field.NewPath("^"),
130130
nil,
131-
func(s *v1.JSONSchemaProps, _, simpleLocation *field.Path, _ []*v1.JSONSchemaProps) bool {
131+
func(s *apiextensionsv1.JSONSchemaProps, _, simpleLocation *field.Path, _ []*apiextensionsv1.JSONSchemaProps) bool {
132132
fieldMap[simpleLocation.String()] = s.DeepCopy()
133133
return false
134134
})

internal/operator-controller/rukpak/preflights/crdupgradesafety/change_validator_test.go

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"testing"
1111

1212
"github.com/stretchr/testify/assert"
13-
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
13+
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1414

1515
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/preflights/crdupgradesafety"
1616
)
@@ -26,42 +26,42 @@ func TestCalculateFlatSchemaDiff(t *testing.T) {
2626
{
2727
name: "no diff in schemas, empty diff, no error",
2828
old: crdupgradesafety.FlatSchema{
29-
"foo": &v1.JSONSchemaProps{},
29+
"foo": &apiextensionsv1.JSONSchemaProps{},
3030
},
3131
new: crdupgradesafety.FlatSchema{
32-
"foo": &v1.JSONSchemaProps{},
32+
"foo": &apiextensionsv1.JSONSchemaProps{},
3333
},
3434
expectedDiff: map[string]crdupgradesafety.FieldDiff{},
3535
},
3636
{
3737
name: "diff in schemas, diff returned, no error",
3838
old: crdupgradesafety.FlatSchema{
39-
"foo": &v1.JSONSchemaProps{},
39+
"foo": &apiextensionsv1.JSONSchemaProps{},
4040
},
4141
new: crdupgradesafety.FlatSchema{
42-
"foo": &v1.JSONSchemaProps{
42+
"foo": &apiextensionsv1.JSONSchemaProps{
4343
ID: "bar",
4444
},
4545
},
4646
expectedDiff: map[string]crdupgradesafety.FieldDiff{
4747
"foo": {
48-
Old: &v1.JSONSchemaProps{},
49-
New: &v1.JSONSchemaProps{ID: "bar"},
48+
Old: &apiextensionsv1.JSONSchemaProps{},
49+
New: &apiextensionsv1.JSONSchemaProps{ID: "bar"},
5050
},
5151
},
5252
},
5353
{
5454
name: "diff in child properties only, no diff returned, no error",
5555
old: crdupgradesafety.FlatSchema{
56-
"foo": &v1.JSONSchemaProps{
57-
Properties: map[string]v1.JSONSchemaProps{
56+
"foo": &apiextensionsv1.JSONSchemaProps{
57+
Properties: map[string]apiextensionsv1.JSONSchemaProps{
5858
"bar": {ID: "bar"},
5959
},
6060
},
6161
},
6262
new: crdupgradesafety.FlatSchema{
63-
"foo": &v1.JSONSchemaProps{
64-
Properties: map[string]v1.JSONSchemaProps{
63+
"foo": &apiextensionsv1.JSONSchemaProps{
64+
Properties: map[string]apiextensionsv1.JSONSchemaProps{
6565
"bar": {ID: "baz"},
6666
},
6767
},
@@ -71,10 +71,10 @@ func TestCalculateFlatSchemaDiff(t *testing.T) {
7171
{
7272
name: "field exists in old but not new, no diff returned, error",
7373
old: crdupgradesafety.FlatSchema{
74-
"foo": &v1.JSONSchemaProps{},
74+
"foo": &apiextensionsv1.JSONSchemaProps{},
7575
},
7676
new: crdupgradesafety.FlatSchema{
77-
"bar": &v1.JSONSchemaProps{},
77+
"bar": &apiextensionsv1.JSONSchemaProps{},
7878
},
7979
expectedDiff: map[string]crdupgradesafety.FieldDiff{},
8080
shouldError: true,
@@ -89,10 +89,10 @@ func TestCalculateFlatSchemaDiff(t *testing.T) {
8989
}
9090

9191
func TestFlattenSchema(t *testing.T) {
92-
schema := &v1.JSONSchemaProps{
93-
Properties: map[string]v1.JSONSchemaProps{
92+
schema := &apiextensionsv1.JSONSchemaProps{
93+
Properties: map[string]apiextensionsv1.JSONSchemaProps{
9494
"foo": {
95-
Properties: map[string]v1.JSONSchemaProps{
95+
Properties: map[string]apiextensionsv1.JSONSchemaProps{
9696
"bar": {},
9797
},
9898
},
@@ -119,8 +119,8 @@ func TestChangeValidator(t *testing.T) {
119119
for _, tc := range []struct {
120120
name string
121121
changeValidator *crdupgradesafety.ChangeValidator
122-
old v1.CustomResourceDefinition
123-
new v1.CustomResourceDefinition
122+
old apiextensionsv1.CustomResourceDefinition
123+
new apiextensionsv1.CustomResourceDefinition
124124
shouldError bool
125125
}{
126126
{
@@ -132,25 +132,25 @@ func TestChangeValidator(t *testing.T) {
132132
},
133133
},
134134
},
135-
old: v1.CustomResourceDefinition{
136-
Spec: v1.CustomResourceDefinitionSpec{
137-
Versions: []v1.CustomResourceDefinitionVersion{
135+
old: apiextensionsv1.CustomResourceDefinition{
136+
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
137+
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
138138
{
139139
Name: "v1alpha1",
140-
Schema: &v1.CustomResourceValidation{
141-
OpenAPIV3Schema: &v1.JSONSchemaProps{},
140+
Schema: &apiextensionsv1.CustomResourceValidation{
141+
OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{},
142142
},
143143
},
144144
},
145145
},
146146
},
147-
new: v1.CustomResourceDefinition{
148-
Spec: v1.CustomResourceDefinitionSpec{
149-
Versions: []v1.CustomResourceDefinitionVersion{
147+
new: apiextensionsv1.CustomResourceDefinition{
148+
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
149+
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
150150
{
151151
Name: "v1alpha1",
152-
Schema: &v1.CustomResourceValidation{
153-
OpenAPIV3Schema: &v1.JSONSchemaProps{},
152+
Schema: &apiextensionsv1.CustomResourceValidation{
153+
OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{},
154154
},
155155
},
156156
},
@@ -166,25 +166,25 @@ func TestChangeValidator(t *testing.T) {
166166
},
167167
},
168168
},
169-
old: v1.CustomResourceDefinition{
170-
Spec: v1.CustomResourceDefinitionSpec{
171-
Versions: []v1.CustomResourceDefinitionVersion{
169+
old: apiextensionsv1.CustomResourceDefinition{
170+
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
171+
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
172172
{
173173
Name: "v1alpha1",
174-
Schema: &v1.CustomResourceValidation{
175-
OpenAPIV3Schema: &v1.JSONSchemaProps{},
174+
Schema: &apiextensionsv1.CustomResourceValidation{
175+
OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{},
176176
},
177177
},
178178
},
179179
},
180180
},
181-
new: v1.CustomResourceDefinition{
182-
Spec: v1.CustomResourceDefinitionSpec{
183-
Versions: []v1.CustomResourceDefinitionVersion{
181+
new: apiextensionsv1.CustomResourceDefinition{
182+
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
183+
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
184184
{
185185
Name: "v1alpha1",
186-
Schema: &v1.CustomResourceValidation{
187-
OpenAPIV3Schema: &v1.JSONSchemaProps{
186+
Schema: &apiextensionsv1.CustomResourceValidation{
187+
OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{
188188
ID: "foo",
189189
},
190190
},
@@ -202,25 +202,25 @@ func TestChangeValidator(t *testing.T) {
202202
},
203203
},
204204
},
205-
old: v1.CustomResourceDefinition{
206-
Spec: v1.CustomResourceDefinitionSpec{
207-
Versions: []v1.CustomResourceDefinitionVersion{
205+
old: apiextensionsv1.CustomResourceDefinition{
206+
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
207+
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
208208
{
209209
Name: "v1alpha1",
210-
Schema: &v1.CustomResourceValidation{
211-
OpenAPIV3Schema: &v1.JSONSchemaProps{},
210+
Schema: &apiextensionsv1.CustomResourceValidation{
211+
OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{},
212212
},
213213
},
214214
},
215215
},
216216
},
217-
new: v1.CustomResourceDefinition{
218-
Spec: v1.CustomResourceDefinitionSpec{
219-
Versions: []v1.CustomResourceDefinitionVersion{
217+
new: apiextensionsv1.CustomResourceDefinition{
218+
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
219+
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
220220
{
221221
Name: "v1alpha1",
222-
Schema: &v1.CustomResourceValidation{
223-
OpenAPIV3Schema: &v1.JSONSchemaProps{
222+
Schema: &apiextensionsv1.CustomResourceValidation{
223+
OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{
224224
ID: "foo",
225225
},
226226
},
@@ -239,25 +239,25 @@ func TestChangeValidator(t *testing.T) {
239239
},
240240
},
241241
},
242-
old: v1.CustomResourceDefinition{
243-
Spec: v1.CustomResourceDefinitionSpec{
244-
Versions: []v1.CustomResourceDefinitionVersion{
242+
old: apiextensionsv1.CustomResourceDefinition{
243+
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
244+
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
245245
{
246246
Name: "v1alpha1",
247-
Schema: &v1.CustomResourceValidation{
248-
OpenAPIV3Schema: &v1.JSONSchemaProps{},
247+
Schema: &apiextensionsv1.CustomResourceValidation{
248+
OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{},
249249
},
250250
},
251251
},
252252
},
253253
},
254-
new: v1.CustomResourceDefinition{
255-
Spec: v1.CustomResourceDefinitionSpec{
256-
Versions: []v1.CustomResourceDefinitionVersion{
254+
new: apiextensionsv1.CustomResourceDefinition{
255+
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
256+
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
257257
{
258258
Name: "v1alpha1",
259-
Schema: &v1.CustomResourceValidation{
260-
OpenAPIV3Schema: &v1.JSONSchemaProps{
259+
Schema: &apiextensionsv1.CustomResourceValidation{
260+
OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{
261261
ID: "foo",
262262
},
263263
},
@@ -276,25 +276,25 @@ func TestChangeValidator(t *testing.T) {
276276
},
277277
},
278278
},
279-
old: v1.CustomResourceDefinition{
280-
Spec: v1.CustomResourceDefinitionSpec{
281-
Versions: []v1.CustomResourceDefinitionVersion{
279+
old: apiextensionsv1.CustomResourceDefinition{
280+
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
281+
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
282282
{
283283
Name: "v1alpha1",
284-
Schema: &v1.CustomResourceValidation{
285-
OpenAPIV3Schema: &v1.JSONSchemaProps{},
284+
Schema: &apiextensionsv1.CustomResourceValidation{
285+
OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{},
286286
},
287287
},
288288
},
289289
},
290290
},
291-
new: v1.CustomResourceDefinition{
292-
Spec: v1.CustomResourceDefinitionSpec{
293-
Versions: []v1.CustomResourceDefinitionVersion{
291+
new: apiextensionsv1.CustomResourceDefinition{
292+
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
293+
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
294294
{
295295
Name: "v1alpha1",
296-
Schema: &v1.CustomResourceValidation{
297-
OpenAPIV3Schema: &v1.JSONSchemaProps{
296+
Schema: &apiextensionsv1.CustomResourceValidation{
297+
OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{
298298
ID: "foo",
299299
},
300300
},

0 commit comments

Comments
 (0)