Skip to content

Commit 3687756

Browse files
committed
Bring schemapatcher in line with CT coding style
This updates schemapatcher (formerly crdschema) rather drastically, reducing its scope a bit and cleaning up its code to bring it in line with the rest of controller-tools. Functionality changes: - change verification is removed -- use diff - yaml.v3 is used, which should preserve comments, style, etc - CRDs are written unconditionally. Doing this for unchanged CRDs should be a no-op, modulo slight whitespace changes.
1 parent 8c38549 commit 3687756

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1225
-811
lines changed

Gopkg.lock

Lines changed: 9 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/controller-gen/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ import (
2525
"github.com/spf13/cobra"
2626

2727
"sigs.k8s.io/controller-tools/pkg/crd"
28-
crdschema "sigs.k8s.io/controller-tools/pkg/crdschema"
2928
"sigs.k8s.io/controller-tools/pkg/deepcopy"
3029
"sigs.k8s.io/controller-tools/pkg/genall"
3130
"sigs.k8s.io/controller-tools/pkg/genall/help"
3231
prettyhelp "sigs.k8s.io/controller-tools/pkg/genall/help/pretty"
3332
"sigs.k8s.io/controller-tools/pkg/markers"
3433
"sigs.k8s.io/controller-tools/pkg/rbac"
34+
"sigs.k8s.io/controller-tools/pkg/schemapatcher"
3535
"sigs.k8s.io/controller-tools/pkg/webhook"
3636
)
3737

@@ -47,11 +47,11 @@ var (
4747
// each turns into a command line option,
4848
// and has options for output forms.
4949
allGenerators = map[string]genall.Generator{
50-
"crd": crd.Generator{},
51-
"rbac": rbac.Generator{},
52-
"object": deepcopy.Generator{},
53-
"webhook": webhook.Generator{},
54-
"crdschema": crdschema.Generator{},
50+
"crd": crd.Generator{},
51+
"rbac": rbac.Generator{},
52+
"object": deepcopy.Generator{},
53+
"webhook": webhook.Generator{},
54+
"schemapatch": schemapatcher.Generator{},
5555
}
5656

5757
// allOutputRules defines the list of all known output rules, giving
@@ -137,7 +137,7 @@ func main() {
137137
controller-gen object paths=./apis/v1beta1/some_types.go
138138
139139
# Generate OpenAPI v3 schemas for API packages and merge them into existing CRD manifests
140-
controller-gen crdschema paths=./pkg/apis/... crdschema:manifests=./manifests output:dir=./manifests
140+
controller-gen schemapatch:manifests=./manifests output:dir=./manifests paths=./pkg/apis/...
141141
142142
# Run all the generators for a given project
143143
controller-gen paths=./apis/...

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ require (
1616
github.com/modern-go/reflect2 v1.0.1 // indirect
1717
github.com/onsi/ginkgo v1.8.0
1818
github.com/onsi/gomega v1.5.0
19-
github.com/sergi/go-diff v1.0.0
2019
github.com/spf13/cobra v0.0.3
2120
github.com/spf13/pflag v1.0.3
2221
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09 // indirect
@@ -25,7 +24,8 @@ require (
2524
golang.org/x/tools v0.0.0-20190501045030-23463209683d
2625
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
2726
gopkg.in/inf.v0 v0.9.1 // indirect
28-
gopkg.in/yaml.v2 v2.2.2
27+
gopkg.in/yaml.v2 v2.2.2 // indirect
28+
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22
2929
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
3030
k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8
3131
k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
4343
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
4444
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4545
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
46-
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
47-
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
4846
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
4947
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
5048
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
@@ -86,6 +84,8 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
8684
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
8785
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
8886
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
87+
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22 h1:0efs3hwEZhFKsCoP8l6dDB1AZWMgnEl3yWXWRZTOaEA=
88+
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
8989
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b h1:aBGgKJUM9Hk/3AE8WaZIApnTxG35kbuQba2w+SXqezo=
9090
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
9191
k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8 h1:q1Qvjzs/iEdXF6A1a8H3AKVFDzJNcJn3nXMs6R6qFtA=

pkg/crd/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (p *Parser) NeedCRDFor(groupKind schema.GroupKind, maxDescLen *int) {
170170
Name: p.GroupVersions[pkg].Version,
171171
Served: true,
172172
Schema: &apiext.CustomResourceValidation{
173-
OpenAPIV3Schema: &fullSchema, // fine to take a reference since we deepcopy above
173+
OpenAPIV3Schema: &fullSchema, // fine to take a reference since we deepcopy above
174174
},
175175
}
176176
crd.Spec.Versions = append(crd.Spec.Versions, ver)

pkg/crdschema/fixtures/Makefile

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)