Skip to content

Commit ebf8b0e

Browse files
committed
Update imports w/o code changes for CRD v1
This includes all the basic imports from apiextensions/v1 --> apiextensions/v1beta1 that didn't also have signification code changes.
1 parent d556e7d commit ebf8b0e

12 files changed

+162
-178
lines changed

pkg/crd/crd_spec_test.go

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package crd_test
1919
import (
2020
. "github.com/onsi/ginkgo"
2121
. "github.com/onsi/gomega"
22-
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
22+
apiextlegacy "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
2323

2424
"sigs.k8s.io/controller-tools/pkg/crd"
2525
)
@@ -28,97 +28,97 @@ var _ = Describe("CRD Generation", func() {
2828
Describe("Utilities", func() {
2929
Describe("MergeIdenticalVersionInfo", func() {
3030
It("should replace per-version schemata with a top-level schema if only one version", func() {
31-
spec := &apiext.CustomResourceDefinition{
32-
Spec: apiext.CustomResourceDefinitionSpec{
33-
Versions: []apiext.CustomResourceDefinitionVersion{
31+
spec := &apiextlegacy.CustomResourceDefinition{
32+
Spec: apiextlegacy.CustomResourceDefinitionSpec{
33+
Versions: []apiextlegacy.CustomResourceDefinitionVersion{
3434
{
3535
Name: "v1",
3636
Storage: true,
37-
Schema: &apiext.CustomResourceValidation{
38-
OpenAPIV3Schema: &apiext.JSONSchemaProps{
37+
Schema: &apiextlegacy.CustomResourceValidation{
38+
OpenAPIV3Schema: &apiextlegacy.JSONSchemaProps{
3939
Required: []string{"foo"},
4040
Type: "object",
41-
Properties: map[string]apiext.JSONSchemaProps{"foo": apiext.JSONSchemaProps{Type: "string"}},
41+
Properties: map[string]apiextlegacy.JSONSchemaProps{"foo": apiextlegacy.JSONSchemaProps{Type: "string"}},
4242
},
4343
},
4444
},
4545
},
4646
},
4747
}
4848
crd.MergeIdenticalVersionInfo(spec)
49-
Expect(spec.Spec.Validation).To(Equal(&apiext.CustomResourceValidation{
50-
OpenAPIV3Schema: &apiext.JSONSchemaProps{
49+
Expect(spec.Spec.Validation).To(Equal(&apiextlegacy.CustomResourceValidation{
50+
OpenAPIV3Schema: &apiextlegacy.JSONSchemaProps{
5151
Required: []string{"foo"},
5252
Type: "object",
53-
Properties: map[string]apiext.JSONSchemaProps{"foo": apiext.JSONSchemaProps{Type: "string"}},
53+
Properties: map[string]apiextlegacy.JSONSchemaProps{"foo": apiextlegacy.JSONSchemaProps{Type: "string"}},
5454
},
5555
}))
56-
Expect(spec.Spec.Versions).To(Equal([]apiext.CustomResourceDefinitionVersion{
56+
Expect(spec.Spec.Versions).To(Equal([]apiextlegacy.CustomResourceDefinitionVersion{
5757
{Name: "v1", Storage: true},
5858
}))
5959
})
6060
It("should replace per-version schemata with a top-level schema if all are identical", func() {
61-
spec := &apiext.CustomResourceDefinition{
62-
Spec: apiext.CustomResourceDefinitionSpec{
63-
Versions: []apiext.CustomResourceDefinitionVersion{
61+
spec := &apiextlegacy.CustomResourceDefinition{
62+
Spec: apiextlegacy.CustomResourceDefinitionSpec{
63+
Versions: []apiextlegacy.CustomResourceDefinitionVersion{
6464
{
6565
Name: "v1",
66-
Schema: &apiext.CustomResourceValidation{
67-
OpenAPIV3Schema: &apiext.JSONSchemaProps{
66+
Schema: &apiextlegacy.CustomResourceValidation{
67+
OpenAPIV3Schema: &apiextlegacy.JSONSchemaProps{
6868
Required: []string{"foo"},
6969
Type: "object",
70-
Properties: map[string]apiext.JSONSchemaProps{"foo": apiext.JSONSchemaProps{Type: "string"}},
70+
Properties: map[string]apiextlegacy.JSONSchemaProps{"foo": apiextlegacy.JSONSchemaProps{Type: "string"}},
7171
},
7272
},
7373
},
7474
{
7575
Name: "v2",
7676
Storage: true,
77-
Schema: &apiext.CustomResourceValidation{
78-
OpenAPIV3Schema: &apiext.JSONSchemaProps{
77+
Schema: &apiextlegacy.CustomResourceValidation{
78+
OpenAPIV3Schema: &apiextlegacy.JSONSchemaProps{
7979
Required: []string{"foo"},
8080
Type: "object",
81-
Properties: map[string]apiext.JSONSchemaProps{"foo": apiext.JSONSchemaProps{Type: "string"}},
81+
Properties: map[string]apiextlegacy.JSONSchemaProps{"foo": apiextlegacy.JSONSchemaProps{Type: "string"}},
8282
},
8383
},
8484
},
8585
},
8686
},
8787
}
8888
crd.MergeIdenticalVersionInfo(spec)
89-
Expect(spec.Spec.Validation).To(Equal(&apiext.CustomResourceValidation{
90-
OpenAPIV3Schema: &apiext.JSONSchemaProps{
89+
Expect(spec.Spec.Validation).To(Equal(&apiextlegacy.CustomResourceValidation{
90+
OpenAPIV3Schema: &apiextlegacy.JSONSchemaProps{
9191
Required: []string{"foo"},
9292
Type: "object",
93-
Properties: map[string]apiext.JSONSchemaProps{"foo": apiext.JSONSchemaProps{Type: "string"}},
93+
Properties: map[string]apiextlegacy.JSONSchemaProps{"foo": apiextlegacy.JSONSchemaProps{Type: "string"}},
9494
},
9595
}))
96-
Expect(spec.Spec.Versions).To(Equal([]apiext.CustomResourceDefinitionVersion{
96+
Expect(spec.Spec.Versions).To(Equal([]apiextlegacy.CustomResourceDefinitionVersion{
9797
{Name: "v1"}, {Name: "v2", Storage: true},
9898
}))
9999
})
100100

101101
It("shouldn't merge different schemata", func() {
102-
spec := &apiext.CustomResourceDefinition{
103-
Spec: apiext.CustomResourceDefinitionSpec{
104-
Versions: []apiext.CustomResourceDefinitionVersion{
102+
spec := &apiextlegacy.CustomResourceDefinition{
103+
Spec: apiextlegacy.CustomResourceDefinitionSpec{
104+
Versions: []apiextlegacy.CustomResourceDefinitionVersion{
105105
{
106106
Name: "v1",
107-
Schema: &apiext.CustomResourceValidation{
108-
OpenAPIV3Schema: &apiext.JSONSchemaProps{
107+
Schema: &apiextlegacy.CustomResourceValidation{
108+
OpenAPIV3Schema: &apiextlegacy.JSONSchemaProps{
109109
Type: "object",
110-
Properties: map[string]apiext.JSONSchemaProps{"foo": apiext.JSONSchemaProps{Type: "string"}},
110+
Properties: map[string]apiextlegacy.JSONSchemaProps{"foo": apiextlegacy.JSONSchemaProps{Type: "string"}},
111111
},
112112
},
113113
},
114114
{
115115
Name: "v2",
116116
Storage: true,
117-
Schema: &apiext.CustomResourceValidation{
118-
OpenAPIV3Schema: &apiext.JSONSchemaProps{
117+
Schema: &apiextlegacy.CustomResourceValidation{
118+
OpenAPIV3Schema: &apiextlegacy.JSONSchemaProps{
119119
Required: []string{"foo"},
120120
Type: "object",
121-
Properties: map[string]apiext.JSONSchemaProps{"foo": apiext.JSONSchemaProps{Type: "string"}},
121+
Properties: map[string]apiextlegacy.JSONSchemaProps{"foo": apiextlegacy.JSONSchemaProps{Type: "string"}},
122122
},
123123
},
124124
},
@@ -131,67 +131,67 @@ var _ = Describe("CRD Generation", func() {
131131
})
132132

133133
It("should replace per-version subresources with top-level subresources if only one version", func() {
134-
spec := &apiext.CustomResourceDefinition{
135-
Spec: apiext.CustomResourceDefinitionSpec{
136-
Versions: []apiext.CustomResourceDefinitionVersion{
134+
spec := &apiextlegacy.CustomResourceDefinition{
135+
Spec: apiextlegacy.CustomResourceDefinitionSpec{
136+
Versions: []apiextlegacy.CustomResourceDefinitionVersion{
137137
{
138138
Name: "v1",
139139
Storage: true,
140-
Subresources: &apiext.CustomResourceSubresources{
141-
Status: &apiext.CustomResourceSubresourceStatus{},
140+
Subresources: &apiextlegacy.CustomResourceSubresources{
141+
Status: &apiextlegacy.CustomResourceSubresourceStatus{},
142142
},
143143
},
144144
},
145145
},
146146
}
147147

148148
crd.MergeIdenticalVersionInfo(spec)
149-
Expect(spec.Spec.Subresources).To(Equal(&apiext.CustomResourceSubresources{
150-
Status: &apiext.CustomResourceSubresourceStatus{},
149+
Expect(spec.Spec.Subresources).To(Equal(&apiextlegacy.CustomResourceSubresources{
150+
Status: &apiextlegacy.CustomResourceSubresourceStatus{},
151151
}))
152-
Expect(spec.Spec.Versions).To(Equal([]apiext.CustomResourceDefinitionVersion{
152+
Expect(spec.Spec.Versions).To(Equal([]apiextlegacy.CustomResourceDefinitionVersion{
153153
{Name: "v1", Storage: true},
154154
}))
155155
})
156156

157157
It("should replace per-version subresources with top-level subresources if all are identical", func() {
158-
spec := &apiext.CustomResourceDefinition{
159-
Spec: apiext.CustomResourceDefinitionSpec{
160-
Versions: []apiext.CustomResourceDefinitionVersion{
158+
spec := &apiextlegacy.CustomResourceDefinition{
159+
Spec: apiextlegacy.CustomResourceDefinitionSpec{
160+
Versions: []apiextlegacy.CustomResourceDefinitionVersion{
161161
{
162162
Name: "v1",
163-
Subresources: &apiext.CustomResourceSubresources{
164-
Status: &apiext.CustomResourceSubresourceStatus{},
163+
Subresources: &apiextlegacy.CustomResourceSubresources{
164+
Status: &apiextlegacy.CustomResourceSubresourceStatus{},
165165
},
166166
},
167167
{
168168
Name: "v2",
169169
Storage: true,
170-
Subresources: &apiext.CustomResourceSubresources{
171-
Status: &apiext.CustomResourceSubresourceStatus{},
170+
Subresources: &apiextlegacy.CustomResourceSubresources{
171+
Status: &apiextlegacy.CustomResourceSubresourceStatus{},
172172
},
173173
},
174174
},
175175
},
176176
}
177177

178178
crd.MergeIdenticalVersionInfo(spec)
179-
Expect(spec.Spec.Subresources).To(Equal(&apiext.CustomResourceSubresources{
180-
Status: &apiext.CustomResourceSubresourceStatus{},
179+
Expect(spec.Spec.Subresources).To(Equal(&apiextlegacy.CustomResourceSubresources{
180+
Status: &apiextlegacy.CustomResourceSubresourceStatus{},
181181
}))
182-
Expect(spec.Spec.Versions).To(Equal([]apiext.CustomResourceDefinitionVersion{
182+
Expect(spec.Spec.Versions).To(Equal([]apiextlegacy.CustomResourceDefinitionVersion{
183183
{Name: "v1"}, {Name: "v2", Storage: true},
184184
}))
185185
})
186186

187187
It("shouldn't merge different subresources", func() {
188-
spec := &apiext.CustomResourceDefinition{
189-
Spec: apiext.CustomResourceDefinitionSpec{
190-
Versions: []apiext.CustomResourceDefinitionVersion{
188+
spec := &apiextlegacy.CustomResourceDefinition{
189+
Spec: apiextlegacy.CustomResourceDefinitionSpec{
190+
Versions: []apiextlegacy.CustomResourceDefinitionVersion{
191191
{
192192
Name: "v1",
193-
Subresources: &apiext.CustomResourceSubresources{
194-
Status: &apiext.CustomResourceSubresourceStatus{},
193+
Subresources: &apiextlegacy.CustomResourceSubresources{
194+
Status: &apiextlegacy.CustomResourceSubresourceStatus{},
195195
},
196196
},
197197
{
@@ -207,13 +207,13 @@ var _ = Describe("CRD Generation", func() {
207207
})
208208

209209
It("should replace per-version printer columns with top-level printer columns if only one version", func() {
210-
spec := &apiext.CustomResourceDefinition{
211-
Spec: apiext.CustomResourceDefinitionSpec{
212-
Versions: []apiext.CustomResourceDefinitionVersion{
210+
spec := &apiextlegacy.CustomResourceDefinition{
211+
Spec: apiextlegacy.CustomResourceDefinitionSpec{
212+
Versions: []apiextlegacy.CustomResourceDefinitionVersion{
213213
{
214214
Name: "v1",
215215
Storage: true,
216-
AdditionalPrinterColumns: []apiext.CustomResourceColumnDefinition{
216+
AdditionalPrinterColumns: []apiextlegacy.CustomResourceColumnDefinition{
217217
{Name: "Cheddar", JSONPath: ".spec.cheddar"},
218218
{Name: "Parmesan", JSONPath: ".status.parmesan"},
219219
},
@@ -223,30 +223,30 @@ var _ = Describe("CRD Generation", func() {
223223
}
224224

225225
crd.MergeIdenticalVersionInfo(spec)
226-
Expect(spec.Spec.AdditionalPrinterColumns).To(Equal([]apiext.CustomResourceColumnDefinition{
226+
Expect(spec.Spec.AdditionalPrinterColumns).To(Equal([]apiextlegacy.CustomResourceColumnDefinition{
227227
{Name: "Cheddar", JSONPath: ".spec.cheddar"},
228228
{Name: "Parmesan", JSONPath: ".status.parmesan"},
229229
}))
230-
Expect(spec.Spec.Versions).To(Equal([]apiext.CustomResourceDefinitionVersion{
230+
Expect(spec.Spec.Versions).To(Equal([]apiextlegacy.CustomResourceDefinitionVersion{
231231
{Name: "v1", Storage: true},
232232
}))
233233
})
234234

235235
It("should replace per-version printer columns with top-level printer columns if all are identical", func() {
236-
spec := &apiext.CustomResourceDefinition{
237-
Spec: apiext.CustomResourceDefinitionSpec{
238-
Versions: []apiext.CustomResourceDefinitionVersion{
236+
spec := &apiextlegacy.CustomResourceDefinition{
237+
Spec: apiextlegacy.CustomResourceDefinitionSpec{
238+
Versions: []apiextlegacy.CustomResourceDefinitionVersion{
239239
{
240240
Name: "v1",
241-
AdditionalPrinterColumns: []apiext.CustomResourceColumnDefinition{
241+
AdditionalPrinterColumns: []apiextlegacy.CustomResourceColumnDefinition{
242242
{Name: "Cheddar", JSONPath: ".spec.cheddar"},
243243
{Name: "Parmesan", JSONPath: ".status.parmesan"},
244244
},
245245
},
246246
{
247247
Name: "v2",
248248
Storage: true,
249-
AdditionalPrinterColumns: []apiext.CustomResourceColumnDefinition{
249+
AdditionalPrinterColumns: []apiextlegacy.CustomResourceColumnDefinition{
250250
{Name: "Cheddar", JSONPath: ".spec.cheddar"},
251251
{Name: "Parmesan", JSONPath: ".status.parmesan"},
252252
},
@@ -256,22 +256,22 @@ var _ = Describe("CRD Generation", func() {
256256
}
257257

258258
crd.MergeIdenticalVersionInfo(spec)
259-
Expect(spec.Spec.AdditionalPrinterColumns).To(Equal([]apiext.CustomResourceColumnDefinition{
259+
Expect(spec.Spec.AdditionalPrinterColumns).To(Equal([]apiextlegacy.CustomResourceColumnDefinition{
260260
{Name: "Cheddar", JSONPath: ".spec.cheddar"},
261261
{Name: "Parmesan", JSONPath: ".status.parmesan"},
262262
}))
263-
Expect(spec.Spec.Versions).To(Equal([]apiext.CustomResourceDefinitionVersion{
263+
Expect(spec.Spec.Versions).To(Equal([]apiextlegacy.CustomResourceDefinitionVersion{
264264
{Name: "v1"}, {Name: "v2", Storage: true},
265265
}))
266266
})
267267

268268
It("shouldn't merge different printer columns", func() {
269-
spec := &apiext.CustomResourceDefinition{
270-
Spec: apiext.CustomResourceDefinitionSpec{
271-
Versions: []apiext.CustomResourceDefinitionVersion{
269+
spec := &apiextlegacy.CustomResourceDefinition{
270+
Spec: apiextlegacy.CustomResourceDefinitionSpec{
271+
Versions: []apiextlegacy.CustomResourceDefinitionVersion{
272272
{
273273
Name: "v1",
274-
AdditionalPrinterColumns: []apiext.CustomResourceColumnDefinition{
274+
AdditionalPrinterColumns: []apiextlegacy.CustomResourceColumnDefinition{
275275
{Name: "Cheddar", JSONPath: ".spec.cheddar"},
276276
{Name: "Parmesan", JSONPath: ".status.parmesan"},
277277
},

pkg/crd/desc_visitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"strings"
2121
"unicode"
2222

23-
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
23+
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2424
)
2525

2626
// TruncateDescription truncates the description of fields in given schema if it

pkg/crd/desc_visitor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
. "github.com/onsi/ginkgo"
2121
. "github.com/onsi/gomega"
2222

23-
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
23+
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2424

2525
"sigs.k8s.io/controller-tools/pkg/crd"
2626
)

pkg/crd/flatten.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"strings"
2424
"sync"
2525

26-
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
26+
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2727

2828
"sigs.k8s.io/controller-tools/pkg/loader"
2929
)

pkg/crd/flatten_all_of_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
. "github.com/onsi/ginkgo"
2121
. "github.com/onsi/gomega"
2222
. "github.com/onsi/gomega/gstruct"
23-
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
23+
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2424

2525
"sigs.k8s.io/controller-tools/pkg/crd"
2626
)

pkg/crd/flatten_type_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
. "github.com/onsi/ginkgo"
2323
. "github.com/onsi/gomega"
24-
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
24+
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2525

2626
"golang.org/x/tools/go/packages"
2727
"sigs.k8s.io/controller-tools/pkg/crd"

pkg/crd/known_types.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616
package crd
1717

1818
import (
19-
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
19+
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2020

2121
"sigs.k8s.io/controller-tools/pkg/loader"
2222
)
@@ -91,6 +91,12 @@ var KnownPackages = map[string]PackageOverride{
9191
}
9292
p.AddPackage(pkg) // get the rest of the types
9393
},
94+
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1": func(p *Parser, pkg *loader.Package) {
95+
p.Schemata[TypeIdent{Name: "JSON", Package: pkg}] = apiext.JSONSchemaProps{
96+
XPreserveUnknownFields: boolPtr(true),
97+
}
98+
p.AddPackage(pkg) // get the rest of the types
99+
},
94100
}
95101

96102
func boolPtr(b bool) *bool {

0 commit comments

Comments
 (0)