Skip to content

Commit f8024ab

Browse files
authored
Merge pull request kubernetes#74904 from sttts/sttts-proto-tests
Rework proto generation scripts and add tests
2 parents 18cc115 + 220242a commit f8024ab

File tree

74 files changed

+1720
-59
lines changed

Some content is hidden

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

74 files changed

+1720
-59
lines changed

Godeps/Godeps.json

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Godeps/LICENSES

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

hack/update-generated-protobuf-dockerized.sh

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -41,57 +41,8 @@ fi
4141

4242
gotoprotobuf=$(kube::util::find-binary "go-to-protobuf")
4343

44-
PACKAGES=(
45-
k8s.io/apiserver/pkg/apis/example/v1
46-
k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1
47-
k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1
48-
k8s.io/kube-aggregator/pkg/apis/apiregistration/v1
49-
k8s.io/api/core/v1
50-
k8s.io/api/policy/v1beta1
51-
k8s.io/api/extensions/v1beta1
52-
k8s.io/api/autoscaling/v1
53-
k8s.io/api/authorization/v1
54-
k8s.io/api/autoscaling/v2beta1
55-
k8s.io/api/autoscaling/v2beta2
56-
k8s.io/api/authorization/v1beta1
57-
k8s.io/api/batch/v1
58-
k8s.io/api/batch/v1beta1
59-
k8s.io/api/batch/v2alpha1
60-
k8s.io/api/apps/v1beta1
61-
k8s.io/api/apps/v1beta2
62-
k8s.io/api/apps/v1
63-
k8s.io/api/authentication/v1
64-
k8s.io/api/authentication/v1beta1
65-
k8s.io/api/events/v1beta1
66-
k8s.io/api/rbac/v1alpha1
67-
k8s.io/api/rbac/v1beta1
68-
k8s.io/api/rbac/v1
69-
k8s.io/api/certificates/v1beta1
70-
k8s.io/api/coordination/v1beta1
71-
k8s.io/api/coordination/v1
72-
k8s.io/api/imagepolicy/v1alpha1
73-
k8s.io/api/scheduling/v1alpha1
74-
k8s.io/api/scheduling/v1beta1
75-
k8s.io/api/scheduling/v1
76-
k8s.io/api/settings/v1alpha1
77-
k8s.io/api/storage/v1alpha1
78-
k8s.io/api/storage/v1beta1
79-
k8s.io/api/storage/v1
80-
k8s.io/api/admissionregistration/v1beta1
81-
k8s.io/api/admission/v1beta1
82-
k8s.io/api/auditregistration/v1alpha1
83-
k8s.io/api/networking/v1beta1
84-
k8s.io/api/networking/v1
85-
k8s.io/metrics/pkg/apis/metrics/v1alpha1
86-
k8s.io/metrics/pkg/apis/metrics/v1beta1
87-
k8s.io/metrics/pkg/apis/custom_metrics/v1beta1
88-
k8s.io/metrics/pkg/apis/custom_metrics/v1beta2
89-
k8s.io/metrics/pkg/apis/external_metrics/v1beta1
90-
k8s.io/apiserver/pkg/apis/audit/v1alpha1
91-
k8s.io/apiserver/pkg/apis/audit/v1beta1
92-
k8s.io/apiserver/pkg/apis/audit/v1
93-
k8s.io/apiserver/pkg/apis/example2/v1
94-
)
44+
APIROOTS=( ${1} )
45+
shift
9546

9647
# requires the 'proto' tag to build (will remove when ready)
9748
# searches for the protoc-gen-gogo extension in the output directory
@@ -101,6 +52,6 @@ PATH="${KUBE_ROOT}/_output/bin:${PATH}" \
10152
"${gotoprotobuf}" \
10253
--proto-import="${KUBE_ROOT}/vendor" \
10354
--proto-import="${KUBE_ROOT}/third_party/protobuf" \
104-
--packages=$(IFS=, ; echo "${PACKAGES[*]}") \
55+
--packages=$(IFS=, ; echo "${APIROOTS[*]}") \
10556
--go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt \
10657
"$@"

hack/update-generated-protobuf.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
2424
# source tree. This is managed in kube::build::copy_output in build/common.sh.
2525
# If the output set is changed update that function.
2626

27-
"${KUBE_ROOT}/build/run.sh" hack/update-generated-protobuf-dockerized.sh "$@"
27+
APIROOTS=${APIROOTS:-$(git grep --files-with-matches -e '// +k8s:protobuf-gen=package' cmd pkg staging | \
28+
xargs -n 1 dirname | \
29+
sed 's,^,k8s.io/kubernetes/,;s,k8s.io/kubernetes/staging/src/,,' | \
30+
sort | uniq
31+
)}
32+
33+
"${KUBE_ROOT}/build/run.sh" hack/update-generated-protobuf-dockerized.sh "${APIROOTS}" "$@"
2834

2935
# ex: ts=2 sw=2 et filetype=sh

hack/verify-generated-protobuf.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
2323

2424
kube::golang::setup_env
2525

26-
APIROOTS=${APIROOTS:-pkg/api pkg/apis pkg/watch staging/src/k8s.io/apimachinery/pkg/api staging/src/k8s.io/apimachinery/pkg/apis staging/src/k8s.io/apiserver/pkg staging/src/k8s.io/api staging/src/k8s.io/metrics/pkg/apis}
26+
APIROOTS=$(git grep --files-with-matches -e '// +k8s:protobuf-gen=package' cmd pkg staging | xargs -n 1 dirname | sort | uniq)
27+
2728
_tmp="${KUBE_ROOT}/_tmp"
2829

2930
cleanup() {

staging/src/k8s.io/api/admission/v1beta1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
*/
1616

1717
// +k8s:deepcopy-gen=package
18+
// +k8s:protobuf-gen=package
1819
// +k8s:openapi-gen=false
1920

2021
// +groupName=admission.k8s.io

staging/src/k8s.io/api/admissionregistration/v1beta1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
*/
1616

1717
// +k8s:deepcopy-gen=package
18+
// +k8s:protobuf-gen=package
1819
// +k8s:openapi-gen=true
1920
// +groupName=admissionregistration.k8s.io
2021

staging/src/k8s.io/api/apps/v1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
*/
1616

1717
// +k8s:deepcopy-gen=package
18+
// +k8s:protobuf-gen=package
1819
// +k8s:openapi-gen=true
1920

2021
package v1 // import "k8s.io/api/apps/v1"

staging/src/k8s.io/api/apps/v1beta1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
*/
1616

1717
// +k8s:deepcopy-gen=package
18+
// +k8s:protobuf-gen=package
1819
// +k8s:openapi-gen=true
1920

2021
package v1beta1 // import "k8s.io/api/apps/v1beta1"

staging/src/k8s.io/api/apps/v1beta2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
*/
1616

1717
// +k8s:deepcopy-gen=package
18+
// +k8s:protobuf-gen=package
1819
// +k8s:openapi-gen=true
1920

2021
package v1beta2 // import "k8s.io/api/apps/v1beta2"

0 commit comments

Comments
 (0)