├── cmd ├── go-to-protobuf │ ├── .gitignore │ ├── OWNERS │ ├── protobuf │ │ └── tags.go │ └── main.go ├── validation-gen │ ├── output_tests │ │ ├── no_types_match │ │ │ ├── testdata │ │ │ │ └── validate-false.json │ │ │ ├── zz_generated.validations_test.go │ │ │ ├── zz_generated.validations.go │ │ │ └── doc.go │ │ ├── all_types_match │ │ │ ├── trivial │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ ├── zz_generated.validations_test.go │ │ │ │ ├── doc.go │ │ │ │ └── zz_generated.validations.go │ │ │ ├── with_type_validations │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ │ └── with_field_validations │ │ │ │ ├── testdata │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ ├── cohorts │ │ │ ├── testdata │ │ │ │ └── validate-false.json │ │ │ └── zz_generated.validations_test.go │ │ ├── public_private │ │ │ ├── testdata │ │ │ │ └── validate-false.json │ │ │ └── zz_generated.validations_test.go │ │ ├── one_type_match │ │ │ ├── with_type_validations │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ ├── zz_generated.validations_test.go │ │ │ │ └── doc.go │ │ │ ├── with_field_validations │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ │ └── trivial │ │ │ │ ├── doc.go │ │ │ │ └── zz_generated.validations.go │ │ ├── embedded │ │ │ ├── testdata │ │ │ │ └── validate-false.json │ │ │ └── zz_generated.validations_test.go │ │ ├── update_validations │ │ │ ├── lists │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ ├── zz_generated.validations_test.go │ │ │ │ └── doc.go │ │ │ ├── maps │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ ├── zz_generated.validations_test.go │ │ │ │ └── doc.go │ │ │ ├── primitives │ │ │ │ └── doc.go │ │ │ └── primitive_pointers │ │ │ │ └── doc.go │ │ ├── elide_no_validations │ │ │ ├── testdata │ │ │ │ └── validate-false.json │ │ │ └── zz_generated.validations_test.go │ │ ├── tags │ │ │ ├── README.md │ │ │ ├── validate_true │ │ │ │ ├── doc_test.go │ │ │ │ └── doc.go │ │ │ ├── subfield │ │ │ │ └── nonincluded │ │ │ │ │ ├── doc_test.go │ │ │ │ │ └── doc.go │ │ │ ├── union │ │ │ │ └── union │ │ │ │ │ └── discriminated │ │ │ │ │ └── empty │ │ │ │ │ ├── doc_test.go │ │ │ │ │ └── doc.go │ │ │ ├── validate_false │ │ │ │ └── doc.go │ │ │ ├── supported_resources │ │ │ │ ├── issubresource │ │ │ │ │ └── doc.go │ │ │ │ └── subresource │ │ │ │ │ └── doc.go │ │ │ ├── neq │ │ │ │ └── neqbool │ │ │ │ │ └── doc.go │ │ │ ├── eachval │ │ │ │ ├── slice_of_primitive │ │ │ │ │ └── doc.go │ │ │ │ └── map_of_primitive │ │ │ │ │ └── doc.go │ │ │ └── item │ │ │ │ └── union │ │ │ │ └── simple │ │ │ │ └── doc.go │ │ ├── ordering │ │ │ ├── typedefs │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ │ └── structs │ │ │ │ ├── testdata │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ ├── slices │ │ │ ├── multiple_validations │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ │ ├── slice_of_primitive │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ │ ├── typedef_to_slice │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ │ └── slice_of_struct │ │ │ │ ├── testdata │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ ├── pointers │ │ │ ├── testdata │ │ │ │ └── validate-false.json │ │ │ └── zz_generated.validations_test.go │ │ ├── multiple_tags │ │ │ ├── testdata │ │ │ │ └── validate-false.json │ │ │ └── zz_generated.validations_test.go │ │ ├── maps │ │ │ ├── multiple_validations │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ │ ├── map_of_primitive │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ │ ├── map_of_struct │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ │ ├── typedef_to_map │ │ │ │ ├── testdata │ │ │ │ │ └── validate-false.json │ │ │ │ └── zz_generated.validations_test.go │ │ │ └── keys │ │ │ │ ├── zz_generated.validations_test.go │ │ │ │ └── testdata │ │ │ │ └── validate-false.json │ │ ├── primitives │ │ │ ├── testdata │ │ │ │ └── validate-false.json │ │ │ └── zz_generated.validations_test.go │ │ ├── generate.go │ │ ├── typedefs │ │ │ ├── zz_generated.validations_test.go │ │ │ └── testdata │ │ │ │ └── validate-false.json │ │ ├── cross_pkg │ │ │ └── zz_generated.validations_test.go │ │ ├── recursive │ │ │ ├── maps │ │ │ │ └── zz_generated.validations_test.go │ │ │ ├── pointers │ │ │ │ └── zz_generated.validations_test.go │ │ │ └── slices │ │ │ │ └── zz_generated.validations_test.go │ │ ├── type_args │ │ │ └── zz_generated.validations_test.go │ │ └── no_generation │ │ │ └── doc.go │ ├── lint_rules.go │ └── validators │ │ └── common.go ├── client-gen │ ├── README.md │ ├── OWNERS │ ├── generators │ │ └── util │ │ │ └── gvpackages.go │ └── types │ │ └── helpers_test.go ├── defaulter-gen │ └── output_tests │ │ ├── marker │ │ ├── external2 │ │ │ └── type.go │ │ ├── doc.go │ │ ├── external │ │ │ ├── constant.go │ │ │ └── external │ │ │ │ └── constant.go │ │ ├── external3 │ │ │ └── constant.go │ │ └── defaults.go │ │ ├── empty │ │ ├── doc.go │ │ ├── type.go │ │ └── zz_generated.defaults.go │ │ ├── pointer │ │ ├── doc.go │ │ ├── type.go │ │ └── defaults.go │ │ ├── slices │ │ ├── doc.go │ │ ├── defaults.go │ │ └── type.go │ │ ├── wholepkg │ │ ├── doc.go │ │ └── defaults.go │ │ └── generate.go ├── register-gen │ └── output_tests │ │ ├── simpletype │ │ └── v1 │ │ │ ├── doc.go │ │ │ └── types.go │ │ └── generate.go └── deepcopy-gen │ └── output_tests │ ├── wholepkg │ ├── b.go │ ├── doc.go │ └── interfaces.go │ ├── otherpkg │ └── interfaces.go │ ├── generate.go │ ├── interfaces │ └── doc.go │ ├── pointer │ └── doc.go │ ├── builtins │ ├── doc.go │ └── zz_generated.deepcopy.go │ └── structs │ └── doc.go ├── examples ├── .gitignore ├── go.work ├── hack │ └── boilerplate.go.txt ├── apiserver │ ├── apis │ │ ├── core │ │ │ ├── doc.go │ │ │ ├── v1 │ │ │ │ ├── doc.go │ │ │ │ └── zz_generated.defaults.go │ │ │ └── install │ │ │ │ └── install.go │ │ ├── example │ │ │ ├── doc.go │ │ │ ├── v1 │ │ │ │ ├── doc.go │ │ │ │ └── zz_generated.defaults.go │ │ │ └── install │ │ │ │ └── install.go │ │ ├── example2 │ │ │ ├── doc.go │ │ │ ├── v1 │ │ │ │ ├── doc.go │ │ │ │ └── zz_generated.defaults.go │ │ │ └── install │ │ │ │ └── install.go │ │ └── example3.io │ │ │ ├── doc.go │ │ │ └── v1 │ │ │ ├── doc.go │ │ │ └── zz_generated.defaults.go │ ├── listers │ │ ├── example2 │ │ │ └── v1 │ │ │ │ ├── expansion_generated.go │ │ │ │ └── testtype_expansion.go │ │ ├── core │ │ │ └── v1 │ │ │ │ └── expansion_generated.go │ │ ├── example │ │ │ └── v1 │ │ │ │ └── expansion_generated.go │ │ └── example3.io │ │ │ └── v1 │ │ │ └── expansion_generated.go │ └── clientset │ │ └── versioned │ │ ├── fake │ │ └── doc.go │ │ ├── typed │ │ ├── core │ │ │ └── v1 │ │ │ │ ├── generated_expansion.go │ │ │ │ ├── doc.go │ │ │ │ └── fake │ │ │ │ ├── doc.go │ │ │ │ └── fake_core_client.go │ │ ├── example │ │ │ └── v1 │ │ │ │ ├── generated_expansion.go │ │ │ │ ├── doc.go │ │ │ │ └── fake │ │ │ │ └── doc.go │ │ ├── example2 │ │ │ └── v1 │ │ │ │ ├── generated_expansion.go │ │ │ │ ├── doc.go │ │ │ │ └── fake │ │ │ │ └── doc.go │ │ └── example3.io │ │ │ └── v1 │ │ │ ├── generated_expansion.go │ │ │ ├── doc.go │ │ │ └── fake │ │ │ └── doc.go │ │ └── scheme │ │ └── doc.go ├── single │ ├── api │ │ └── v1 │ │ │ ├── doc.go │ │ │ └── zz_generated.defaults.go │ ├── clientset │ │ └── versioned │ │ │ ├── fake │ │ │ └── doc.go │ │ │ ├── typed │ │ │ └── api │ │ │ │ └── v1 │ │ │ │ ├── doc.go │ │ │ │ ├── fake │ │ │ │ └── doc.go │ │ │ │ └── generated_expansion.go │ │ │ └── scheme │ │ │ └── doc.go │ └── listers │ │ └── api │ │ └── v1 │ │ └── expansion_generated.go ├── MixedCase │ ├── apis │ │ └── example │ │ │ └── v1 │ │ │ ├── doc.go │ │ │ └── zz_generated.defaults.go │ ├── clientset │ │ └── versioned │ │ │ ├── fake │ │ │ └── doc.go │ │ │ ├── typed │ │ │ └── example │ │ │ │ └── v1 │ │ │ │ ├── doc.go │ │ │ │ ├── fake │ │ │ │ └── doc.go │ │ │ │ └── generated_expansion.go │ │ │ └── scheme │ │ │ └── doc.go │ └── listers │ │ └── example │ │ └── v1 │ │ └── expansion_generated.go ├── crd │ ├── apis │ │ ├── example │ │ │ └── v1 │ │ │ │ ├── doc.go │ │ │ │ └── zz_generated.defaults.go │ │ ├── example2 │ │ │ └── v1 │ │ │ │ ├── doc.go │ │ │ │ └── zz_generated.defaults.go │ │ ├── extensions │ │ │ └── v1 │ │ │ │ ├── doc.go │ │ │ │ └── zz_generated.defaults.go │ │ ├── conflicting │ │ │ └── v1 │ │ │ │ ├── doc.go │ │ │ │ └── zz_generated.defaults.go │ │ └── gateway-api │ │ │ └── v1 │ │ │ └── shared_types.go │ ├── clientset │ │ └── versioned │ │ │ ├── fake │ │ │ └── doc.go │ │ │ ├── typed │ │ │ ├── conflicting │ │ │ │ └── v1 │ │ │ │ │ ├── generated_expansion.go │ │ │ │ │ ├── doc.go │ │ │ │ │ └── fake │ │ │ │ │ └── doc.go │ │ │ ├── example2 │ │ │ │ └── v1 │ │ │ │ │ ├── generated_expansion.go │ │ │ │ │ ├── doc.go │ │ │ │ │ └── fake │ │ │ │ │ └── doc.go │ │ │ ├── extensions │ │ │ │ └── v1 │ │ │ │ │ ├── generated_expansion.go │ │ │ │ │ ├── doc.go │ │ │ │ │ └── fake │ │ │ │ │ └── doc.go │ │ │ └── example │ │ │ │ └── v1 │ │ │ │ ├── doc.go │ │ │ │ ├── fake │ │ │ │ └── doc.go │ │ │ │ └── generated_expansion.go │ │ │ └── scheme │ │ │ └── doc.go │ └── listers │ │ ├── example2 │ │ └── v1 │ │ │ └── expansion_generated.go │ │ ├── conflicting │ │ └── v1 │ │ │ └── expansion_generated.go │ │ ├── extensions │ │ └── v1 │ │ │ └── expansion_generated.go │ │ └── example │ │ └── v1 │ │ └── expansion_generated.go └── HyphenGroup │ ├── clientset │ └── versioned │ │ ├── fake │ │ └── doc.go │ │ ├── typed │ │ └── example │ │ │ └── v1 │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ └── doc.go │ │ │ └── generated_expansion.go │ │ └── scheme │ │ └── doc.go │ ├── apis │ └── example │ │ └── v1 │ │ ├── doc.go │ │ └── zz_generated.defaults.go │ └── listers │ └── example │ └── v1 │ └── expansion_generated.go ├── code-of-conduct.md ├── .github └── PULL_REQUEST_TEMPLATE.md ├── OWNERS ├── SECURITY_CONTACTS ├── doc.go ├── CONTRIBUTING.md ├── generate-groups.sh └── generate-internal-groups.sh /cmd/go-to-protobuf/.gitignore: -------------------------------------------------------------------------------- 1 | go-to-protobuf 2 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/no_types_match/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/all_types_match/trivial/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | # avoid constant churn as this file is not kept in sync with the root 2 | go.work.sum 3 | -------------------------------------------------------------------------------- /cmd/client-gen/README.md: -------------------------------------------------------------------------------- 1 | See [generating-clientset.md](https://git.k8s.io/community/contributors/devel/sig-api-machinery/generating-clientset.md) 2 | 3 | -------------------------------------------------------------------------------- /cmd/go-to-protobuf/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | approvers: 4 | - smarterclayton 5 | reviewers: 6 | - smarterclayton 7 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/cohorts/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*cohorts.T": { 3 | "": [ 4 | "type T ShortCircuit" 5 | ] 6 | } 7 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/public_private/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*publicprivate.T1": { 3 | "public": [ 4 | "field T1.Public" 5 | ] 6 | } 7 | } -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | # Kubernetes Community Code of Conduct 2 | 3 | Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Sorry, we do not accept changes directly against this repository. Please see 2 | CONTRIBUTING.md for information on where and how to contribute instead. 3 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/one_type_match/with_type_validations/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*withtypevalidations.T1": { 3 | "": [ 4 | "type T1" 5 | ] 6 | } 7 | } -------------------------------------------------------------------------------- /examples/go.work: -------------------------------------------------------------------------------- 1 | // This is a hack, but it prevents go from climbing further and trying to 2 | // reconcile the various deps across the "real" modules and this one. 3 | 4 | go 1.25.0 5 | 6 | godebug default=go1.25 7 | 8 | use . 9 | -------------------------------------------------------------------------------- /cmd/client-gen/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | approvers: 4 | - wojtek-t 5 | - caesarxuchao 6 | reviewers: 7 | - wojtek-t 8 | - caesarxuchao 9 | - jpbetz 10 | emeritus_approvers: 11 | - lavalamp 12 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/embedded/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*embedded.T1": { 3 | "T2.intField": [ 4 | "T2.IntField" 5 | ], 6 | "T3.intField": [ 7 | "T3.IntField" 8 | ], 9 | "T3.stringField": [ 10 | "T3.StringField" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/update_validations/lists/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*lists.M1": { 3 | "s": [ 4 | "M1.S" 5 | ] 6 | }, 7 | "*lists.T1": { 8 | "lm1[0].s": [ 9 | "M1.S" 10 | ], 11 | "lm1[1].s": [ 12 | "M1.S" 13 | ] 14 | } 15 | } -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | approvers: 4 | - deads2k 5 | - jpbetz 6 | - wojtek-t 7 | - sttts 8 | reviewers: 9 | - deads2k 10 | - wojtek-t 11 | - sttts 12 | labels: 13 | - sig/api-machinery 14 | - area/code-generation 15 | emeritus_approvers: 16 | - lavalamp 17 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/update_validations/maps/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*maps.M1": { 3 | "s": [ 4 | "M1.S" 5 | ] 6 | }, 7 | "*maps.T1": { 8 | "msm1[ƒ岯Ȉ\u0026\u003c沲3镟Ō仲牚輠ɟɛ].s": [ 9 | "M1.S" 10 | ], 11 | "msm1[Ȱ轷N].s": [ 12 | "M1.S" 13 | ] 14 | } 15 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/all_types_match/with_type_validations/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*withtypevalidations.E1": { 3 | "": [ 4 | "type E1" 5 | ] 6 | }, 7 | "*withtypevalidations.T1": { 8 | "": [ 9 | "type T1" 10 | ], 11 | "s": [ 12 | "field T1.S" 13 | ] 14 | } 15 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/elide_no_validations/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*elidenovalidations.T1": { 3 | "hasFieldVal.s": [ 4 | "field HasFieldVal.S" 5 | ], 6 | "hasNoValFieldVal": [ 7 | "field T1.HasNoValFieldVal" 8 | ], 9 | "hasTypeVal": [ 10 | "type HasTypeVal" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/README.md: -------------------------------------------------------------------------------- 1 | # Tag tests 2 | 3 | Tests in this directory are intended to validate specific tags, rather than 4 | general behavior of the code generator. Some tags are deeply integrated into 5 | the code-generation and will end up with similar tests elsewhere. 6 | 7 | These test cases should be as focused as possible. 8 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/one_type_match/with_field_validations/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*withfieldvalidations.T1": { 3 | "e1": [ 4 | "field T1.E1", 5 | "type E1" 6 | ], 7 | "e2": [ 8 | "field T1.E2" 9 | ], 10 | "s": [ 11 | "field T1.S" 12 | ], 13 | "t2": [ 14 | "field T1.T2" 15 | ], 16 | "t2.s": [ 17 | "field T2.S" 18 | ], 19 | "t3": [ 20 | "field T1.T3" 21 | ] 22 | } 23 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/ordering/typedefs/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*typedefs.E01": { 3 | "": [ 4 | "E01, no flags" 5 | ] 6 | }, 7 | "*typedefs.E02": { 8 | "": [ 9 | "E02, ShortCircuit" 10 | ] 11 | }, 12 | "*typedefs.E03": { 13 | "": [ 14 | "E03, ShortCircuit" 15 | ] 16 | }, 17 | "*typedefs.EMultiple": { 18 | "": [ 19 | "EMultiple, ShortCircuit 1", 20 | "EMultiple, ShortCircuit 2" 21 | ] 22 | } 23 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/all_types_match/with_field_validations/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*withfieldvalidations.T1": { 3 | "s": [ 4 | "field T1.S" 5 | ], 6 | "t2": [ 7 | "field T1.T2" 8 | ], 9 | "t2.s": [ 10 | "field T2.S" 11 | ], 12 | "t3": [ 13 | "field T1.T3" 14 | ] 15 | }, 16 | "*withfieldvalidations.T2": { 17 | "s": [ 18 | "field T2.S" 19 | ] 20 | }, 21 | "*withfieldvalidations.T4": { 22 | "s": [ 23 | "field T4.S" 24 | ] 25 | } 26 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/slices/multiple_validations/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*multiplevalidations.Struct": { 3 | "": [ 4 | "type Struct #1", 5 | "type Struct #2" 6 | ], 7 | "listField": [ 8 | "field Struct.ListField #1", 9 | "field Struct.ListField #2" 10 | ], 11 | "listField[0]": [ 12 | "field Struct.ListField[*] #1", 13 | "field Struct.ListField[*] #2" 14 | ], 15 | "listField[1]": [ 16 | "field Struct.ListField[*] #1", 17 | "field Struct.ListField[*] #2" 18 | ] 19 | } 20 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/pointers/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*pointers.T1": { 3 | "pb": [ 4 | "field T1.PB" 5 | ], 6 | "pf": [ 7 | "field T1.PF" 8 | ], 9 | "pi": [ 10 | "field T1.PI" 11 | ], 12 | "ps": [ 13 | "field T1.PS" 14 | ], 15 | "pt2": [ 16 | "field T1.PT2" 17 | ], 18 | "pt2.pb": [ 19 | "field T2.PB" 20 | ], 21 | "pt2.pf": [ 22 | "field T2.PF" 23 | ], 24 | "pt2.pi": [ 25 | "field T2.PI" 26 | ], 27 | "pt2.ps": [ 28 | "field T2.PS" 29 | ] 30 | } 31 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/multiple_tags/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*multipletags.T1": { 3 | "": [ 4 | "type T1 #1", 5 | "type T1 #2", 6 | "type T1 #3" 7 | ], 8 | "s": [ 9 | "field T1.S false #1", 10 | "field T1.S false #2", 11 | "field T1.S false #3" 12 | ], 13 | "t2": [ 14 | "field T1.T2 false #1", 15 | "field T1.T2 false #2", 16 | "field T1.T2 false #3", 17 | "type T2 false #1", 18 | "type T2 false #2" 19 | ], 20 | "t2.s": [ 21 | "field T2.S false #1", 22 | "field T2.S false #2" 23 | ] 24 | } 25 | } -------------------------------------------------------------------------------- /SECURITY_CONTACTS: -------------------------------------------------------------------------------- 1 | # Defined below are the security contacts for this repo. 2 | # 3 | # They are the contact point for the Product Security Committee to reach out 4 | # to for triaging and handling of incoming issues. 5 | # 6 | # The below names agree to abide by the 7 | # [Embargo Policy](https://git.k8s.io/security/private-distributors-list.md#embargo-policy) 8 | # and will be removed and replaced if they violate that agreement. 9 | # 10 | # DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE 11 | # INSTRUCTIONS AT https://kubernetes.io/security/ 12 | 13 | cheftako 14 | deads2k 15 | lavalamp 16 | sttts 17 | -------------------------------------------------------------------------------- /examples/hack/boilerplate.go.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package codegenerator 18 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/slices/slice_of_primitive/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*sliceofprimitive.Struct": { 3 | "": [ 4 | "type Struct" 5 | ], 6 | "listField": [ 7 | "field Struct.ListField" 8 | ], 9 | "listField[0]": [ 10 | "field Struct.ListField[*]" 11 | ], 12 | "listField[1]": [ 13 | "field Struct.ListField[*]" 14 | ], 15 | "listTypedefField": [ 16 | "field Struct.ListTypedefField" 17 | ], 18 | "listTypedefField[0]": [ 19 | "field Struct.ListTypedefField[*]", 20 | "type StringType" 21 | ], 22 | "listTypedefField[1]": [ 23 | "field Struct.ListTypedefField[*]", 24 | "type StringType" 25 | ] 26 | } 27 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/maps/multiple_validations/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*multiplevalidations.Struct": { 3 | "": [ 4 | "type Struct" 5 | ], 6 | "mapField": [ 7 | "field Struct.MapField #1", 8 | "field Struct.MapField #2", 9 | "field Struct.MapField(keys) #1", 10 | "field Struct.MapField(keys) #1", 11 | "field Struct.MapField(keys) #2", 12 | "field Struct.MapField(keys) #2" 13 | ], 14 | "mapField[ÀYǎ3g成oɜH偩j0âȰ]": [ 15 | "field Struct.MapField[*] #1", 16 | "field Struct.MapField[*] #2" 17 | ], 18 | "mapField[岯Ȉ\u0026\u003c沲3]": [ 19 | "field Struct.MapField[*] #1", 20 | "field Struct.MapField[*] #2" 21 | ] 22 | } 23 | } -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/marker/external2/type.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package external2 18 | 19 | type String string 20 | -------------------------------------------------------------------------------- /cmd/register-gen/output_tests/simpletype/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:register-gen=simpletype 18 | 19 | package v1 20 | -------------------------------------------------------------------------------- /examples/apiserver/apis/core/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +groupName= 19 | 20 | package core 21 | -------------------------------------------------------------------------------- /examples/apiserver/listers/example2/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | -------------------------------------------------------------------------------- /cmd/deepcopy-gen/output_tests/wholepkg/b.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package wholepkg 18 | 19 | // Another type in another file. 20 | type StructB struct{} 21 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/empty/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:defaulter-gen=covers 18 | 19 | // This is a test package. 20 | package empty 21 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/maps/map_of_primitive/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*mapofprimitive.Struct": { 3 | "": [ 4 | "type Struct" 5 | ], 6 | "mapField": [ 7 | "field Struct.MapField" 8 | ], 9 | "mapField[ÀYǎ3g成oɜH偩j0âȰ]": [ 10 | "field Struct.MapField[*]" 11 | ], 12 | "mapField[岯Ȉ\u0026\u003c沲3]": [ 13 | "field Struct.MapField[*]" 14 | ], 15 | "mapTypedefField": [ 16 | "field Struct.MapTypedefField" 17 | ], 18 | "mapTypedefField[V噘¢\u003eóDz岋笨Gń條ģ]": [ 19 | "field Struct.MapTypedefField[*]", 20 | "type StringType" 21 | ], 22 | "mapTypedefField[þƿ髈儱Ŀ蒫÷K鬣壈]": [ 23 | "field Struct.MapTypedefField[*]", 24 | "type StringType" 25 | ] 26 | } 27 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | Do not open pull requests directly against this repository, they will be ignored. Instead, please open pull requests against [kubernetes/kubernetes](https://git.k8s.io/kubernetes/). Please follow the same [contributing guide](https://git.k8s.io/kubernetes/CONTRIBUTING.md) you would follow for any other pull request made to kubernetes/kubernetes. 4 | 5 | This repository is published from [kubernetes/kubernetes/staging/src/k8s.io/code-generator](https://git.k8s.io/kubernetes/staging/src/k8s.io/code-generator) by the [kubernetes publishing-bot](https://git.k8s.io/publishing-bot). 6 | 7 | Please see [Staging Directory and Publishing](https://git.k8s.io/community/contributors/devel/sig-architecture/staging.md) for more information 8 | -------------------------------------------------------------------------------- /cmd/deepcopy-gen/output_tests/wholepkg/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | 19 | // This is a test package. 20 | package wholepkg 21 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/marker/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:defaulter-gen=TypeMeta 18 | 19 | // This is a test package. 20 | package marker 21 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/pointer/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:defaulter-gen=TypeMeta 18 | 19 | // This is a test package. 20 | package pointer 21 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/slices/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:defaulter-gen=TypeMeta 18 | 19 | // This is a test package. 20 | package slices 21 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/wholepkg/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:defaulter-gen=TypeMeta 18 | 19 | // This is a test package. 20 | package wholepkg 21 | -------------------------------------------------------------------------------- /cmd/deepcopy-gen/output_tests/wholepkg/interfaces.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package wholepkg 18 | 19 | type Selector interface { 20 | DeepCopySelector() Selector 21 | } 22 | -------------------------------------------------------------------------------- /examples/apiserver/apis/example/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +groupName=example.apiserver.code-generator.k8s.io 19 | 20 | package example 21 | -------------------------------------------------------------------------------- /examples/single/api/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +k8s:defaulter-gen=TypeMeta 19 | // +groupName=example.crd.code-generator.k8s.io 20 | 21 | package v1 22 | -------------------------------------------------------------------------------- /examples/MixedCase/apis/example/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +k8s:defaulter-gen=TypeMeta 19 | // +groupName=example.crd.code-generator.k8s.io 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/crd/apis/example/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +k8s:defaulter-gen=TypeMeta 19 | // +groupName=example.crd.code-generator.k8s.io 20 | 21 | package v1 22 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/maps/map_of_struct/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*mapofstruct.Struct": { 3 | "": [ 4 | "type Struct" 5 | ], 6 | "mapField": [ 7 | "field Struct.MapField" 8 | ], 9 | "mapField[岯Ȉ\u0026\u003c沲3]": [ 10 | "field Struct.MapField[*]", 11 | "type OtherStruct" 12 | ], 13 | "mapField[铃]3g!fȺ苬ĥəƣ]": [ 14 | "field Struct.MapField[*]", 15 | "type OtherStruct" 16 | ], 17 | "mapTypedefField": [ 18 | "field Struct.MapTypedefField" 19 | ], 20 | "mapTypedefField[]": [ 21 | "field Struct.MapTypedefField[*]", 22 | "type OtherTypedefStruct" 23 | ], 24 | "mapTypedefField[x飖Ǒp!ǪŰ]": [ 25 | "field Struct.MapTypedefField[*]", 26 | "type OtherTypedefStruct" 27 | ] 28 | } 29 | } -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated fake clientset. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/single/clientset/versioned/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated fake clientset. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/HyphenGroup/clientset/versioned/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated fake clientset. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/MixedCase/clientset/versioned/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated fake clientset. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated fake clientset. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/core/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type TestTypeExpansion interface{} 22 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/conflicting/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type TestTypeExpansion interface{} 22 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/example2/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type TestTypeExpansion interface{} 22 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/extensions/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type TestTypeExpansion interface{} 22 | -------------------------------------------------------------------------------- /examples/single/clientset/versioned/typed/api/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/marker/external/constant.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package external 18 | 19 | // Used for test with multiple packages of the same name 20 | const AConstant string = "AConstantString" 21 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/primitives/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*primitives.T1": { 3 | "anothert2.b": [ 4 | "field T2.B" 5 | ], 6 | "anothert2.f": [ 7 | "field T2.F" 8 | ], 9 | "anothert2.i": [ 10 | "field T2.I" 11 | ], 12 | "anothert2.s": [ 13 | "field T2.S" 14 | ], 15 | "b": [ 16 | "field T1.B" 17 | ], 18 | "f": [ 19 | "field T1.F" 20 | ], 21 | "i": [ 22 | "field T1.I" 23 | ], 24 | "s": [ 25 | "field T1.S" 26 | ], 27 | "t2": [ 28 | "field T1.T2" 29 | ], 30 | "t2.b": [ 31 | "field T2.B" 32 | ], 33 | "t2.f": [ 34 | "field T2.F" 35 | ], 36 | "t2.i": [ 37 | "field T2.I" 38 | ], 39 | "t2.s": [ 40 | "field T2.S" 41 | ] 42 | } 43 | } -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/core/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/core/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/example/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type TestTypeExpansion interface{} 22 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/example2/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type TestTypeExpansion interface{} 22 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/example3.io/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type TestTypeExpansion interface{} 22 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/conflicting/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/example/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/example/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/example2/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/example2/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/extensions/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/extensions/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/single/clientset/versioned/typed/api/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/HyphenGroup/clientset/versioned/typed/example/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/HyphenGroup/clientset/versioned/typed/example/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/MixedCase/clientset/versioned/typed/example/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/MixedCase/clientset/versioned/typed/example/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/apiserver/apis/example2/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +groupName=example.test.apiserver.code-generator.k8s.io 19 | // +groupGoName=SecondExample 20 | 21 | package example2 22 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/example/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/example/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/example2/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/example2/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/scheme/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package contains the scheme of the automatically generated clientset. 20 | package scheme 21 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/conflicting/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/apiserver/apis/example3.io/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +groupName=example.dots.apiserver.code-generator.k8s.io 19 | // +groupGoName=ThirdExample 20 | 21 | package example3 22 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/example3.io/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/example3.io/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/single/clientset/versioned/scheme/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package contains the scheme of the automatically generated clientset. 20 | package scheme 21 | -------------------------------------------------------------------------------- /examples/HyphenGroup/clientset/versioned/scheme/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package contains the scheme of the automatically generated clientset. 20 | package scheme 21 | -------------------------------------------------------------------------------- /examples/MixedCase/clientset/versioned/scheme/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package contains the scheme of the automatically generated clientset. 20 | package scheme 21 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/scheme/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package contains the scheme of the automatically generated clientset. 20 | package scheme 21 | -------------------------------------------------------------------------------- /generate-groups.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2017 The Kubernetes Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | echo "ERROR: $(basename "$0") has been removed." 18 | echo "ERROR: Please use k8s.io/code-generator/kube_codegen.sh instead." 19 | echo 20 | exit 1 21 | -------------------------------------------------------------------------------- /cmd/deepcopy-gen/output_tests/otherpkg/interfaces.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package otherpkg 18 | 19 | type Object interface { 20 | DeepCopyObject() Object 21 | } 22 | 23 | type List interface { 24 | DeepCopyList() List 25 | } 26 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/marker/external/external/constant.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package external 18 | 19 | // Used for test with multiple packages of the same name 20 | const AnotherConstant string = "AnotherConstantString" 21 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/marker/external3/constant.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package external3 18 | 19 | import "k8s.io/code-generator/cmd/defaulter-gen/output_tests/marker/external2" 20 | 21 | type StringPointer *external2.String 22 | -------------------------------------------------------------------------------- /examples/crd/apis/example2/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +k8s:defaulter-gen=TypeMeta 19 | // +groupName=example.test.crd.code-generator.k8s.io 20 | // +groupGoName=SecondExample 21 | 22 | package v1 23 | -------------------------------------------------------------------------------- /generate-internal-groups.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2017 The Kubernetes Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | echo "ERROR: $(basename "$0") has been removed." 18 | echo "ERROR: Please use k8s.io/code-generator/kube_codegen.sh instead." 19 | echo 20 | exit 1 21 | -------------------------------------------------------------------------------- /examples/HyphenGroup/apis/example/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +k8s:defaulter-gen=TypeMeta 19 | // +groupName=example-group.hyphens.code-generator.k8s.io 20 | // +groupGoName=ExampleGroup 21 | package v1 22 | -------------------------------------------------------------------------------- /cmd/register-gen/output_tests/simpletype/v1/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | ) 22 | 23 | type SimpleType struct { 24 | metav1.TypeMeta `json:",inline"` 25 | } 26 | -------------------------------------------------------------------------------- /examples/crd/apis/extensions/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +k8s:defaulter-gen=TypeMeta 19 | // +groupName=extensions.test.crd.code-generator.k8s.io 20 | // +groupGoName=ExtensionsExample 21 | 22 | package v1 23 | -------------------------------------------------------------------------------- /examples/crd/apis/conflicting/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +k8s:defaulter-gen=TypeMeta 19 | // +groupName=conflicting.test.crd.code-generator.k8s.io 20 | // +groupGoName=ConflictingExample 21 | 22 | package v1 23 | -------------------------------------------------------------------------------- /examples/crd/clientset/versioned/typed/example/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type ClusterTestTypeExpansion interface{} 22 | 23 | type TestTypeExpansion interface{} 24 | -------------------------------------------------------------------------------- /examples/single/clientset/versioned/typed/api/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type ClusterTestTypeExpansion interface{} 22 | 23 | type TestTypeExpansion interface{} 24 | -------------------------------------------------------------------------------- /examples/MixedCase/clientset/versioned/typed/example/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type ClusterTestTypeExpansion interface{} 22 | 23 | type TestTypeExpansion interface{} 24 | -------------------------------------------------------------------------------- /examples/HyphenGroup/clientset/versioned/typed/example/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type ClusterTestTypeExpansion interface{} 22 | 23 | type TestTypeExpansion interface{} 24 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/empty/type.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package empty 18 | 19 | // Only test 20 | type Ttest struct { 21 | BoolField bool 22 | IntField int 23 | StringField string 24 | FloatField float64 25 | } 26 | 27 | type TypeMeta struct { 28 | Fortest bool 29 | } 30 | -------------------------------------------------------------------------------- /cmd/deepcopy-gen/output_tests/generate.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run k8s.io/code-generator/cmd/deepcopy-gen --output-file zz_generated.deepcopy.go --go-header-file=../../../examples/hack/boilerplate.go.txt k8s.io/code-generator/cmd/deepcopy-gen/output_tests/... 18 | package outputtests 19 | -------------------------------------------------------------------------------- /examples/crd/apis/gateway-api/v1/shared_types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | // Copied from Gateway API as a minimal reproducer for #131533 20 | 21 | type ParentReference struct { 22 | } 23 | 24 | func (in *ParentReference) DeepCopyInto(out *ParentReference) { 25 | *out = *in 26 | } 27 | -------------------------------------------------------------------------------- /cmd/deepcopy-gen/output_tests/interfaces/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | 19 | // This is a test package. 20 | package interfaces 21 | 22 | type Inner interface { 23 | Function() float64 24 | DeepCopyInner() Inner 25 | } 26 | 27 | type Ttest struct { 28 | I []Inner 29 | } 30 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/slices/typedef_to_slice/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*typedeftoslice.Struct": { 3 | "": [ 4 | "type Struct" 5 | ], 6 | "listField": [ 7 | "field Struct.ListField", 8 | "type ListType" 9 | ], 10 | "listField[0]": [ 11 | "field Struct.ListField[*]", 12 | "type ListType[*]" 13 | ], 14 | "listField[1]": [ 15 | "field Struct.ListField[*]", 16 | "type ListType[*]" 17 | ], 18 | "listTypedefField": [ 19 | "field Struct.ListTypedefField", 20 | "type ListTypedefType" 21 | ], 22 | "listTypedefField[0]": [ 23 | "field Struct.ListTypedefField[*]", 24 | "type ListTypedefType[*]", 25 | "type StringType" 26 | ], 27 | "listTypedefField[1]": [ 28 | "field Struct.ListTypedefField[*]", 29 | "type ListTypedefType[*]", 30 | "type StringType" 31 | ] 32 | } 33 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/maps/typedef_to_map/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*typedeftomap.Struct": { 3 | "": [ 4 | "type Struct" 5 | ], 6 | "mapField": [ 7 | "field Struct.MapField", 8 | "type MapType" 9 | ], 10 | "mapField[ÀYǎ3g成oɜH偩j0âȰ]": [ 11 | "field Struct.MapField[*]", 12 | "type MapType[*]" 13 | ], 14 | "mapField[岯Ȉ\u0026\u003c沲3]": [ 15 | "field Struct.MapField[*]", 16 | "type MapType[*]" 17 | ], 18 | "mapTypedefField": [ 19 | "field Struct.MapTypedefField", 20 | "type MapTypedefType" 21 | ], 22 | "mapTypedefField[V噘¢\u003eóDz岋笨Gń條ģ]": [ 23 | "field Struct.MapTypedefField[*]", 24 | "type MapTypedefType[*]", 25 | "type StringType" 26 | ], 27 | "mapTypedefField[þƿ髈儱Ŀ蒫÷K鬣壈]": [ 28 | "field Struct.MapTypedefField[*]", 29 | "type MapTypedefType[*]", 30 | "type StringType" 31 | ] 32 | } 33 | } -------------------------------------------------------------------------------- /cmd/register-gen/output_tests/generate.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | /* 4 | Copyright 2025 The Kubernetes Authors. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | //go:generate go run k8s.io/code-generator/cmd/register-gen --output-file zz_generated.register.go --go-header-file=../../../examples/hack/boilerplate.go.txt k8s.io/code-generator/cmd/register-gen/output_tests/... 20 | package outputtests 21 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/slices/slice_of_struct/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*sliceofstruct.Struct": { 3 | "": [ 4 | "type Struct" 5 | ], 6 | "UnvalidatedListField[0]": [ 7 | "type OtherStruct" 8 | ], 9 | "UnvalidatedListField[1]": [ 10 | "type OtherStruct" 11 | ], 12 | "listField": [ 13 | "field Struct.ListField" 14 | ], 15 | "listField[0]": [ 16 | "field Struct.ListField[*]", 17 | "type OtherStruct" 18 | ], 19 | "listField[1]": [ 20 | "field Struct.ListField[*]", 21 | "type OtherStruct" 22 | ], 23 | "listTypedefField": [ 24 | "field Struct.ListTypedefField" 25 | ], 26 | "listTypedefField[0]": [ 27 | "field Struct.ListTypedefField[*]", 28 | "type OtherTypedefStruct" 29 | ], 30 | "listTypedefField[1]": [ 31 | "field Struct.ListTypedefField[*]", 32 | "type OtherTypedefStruct" 33 | ] 34 | } 35 | } -------------------------------------------------------------------------------- /examples/apiserver/apis/core/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:openapi-gen=true 18 | // +k8s:deepcopy-gen=package 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +k8s:conversion-gen=k8s.io/code-generator/examples/apiserver/apis/core 21 | // +groupName= 22 | // +k8s:openapi-model-package=io.k8s.code-generator.examples.apiserver.apis.core.v1 23 | 24 | package v1 25 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/pointer/type.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package pointer 18 | 19 | import ( 20 | "k8s.io/code-generator/cmd/defaulter-gen/output_tests/empty" 21 | ) 22 | 23 | type Tpointer struct { 24 | empty.TypeMeta 25 | BoolField *bool 26 | } 27 | 28 | // Only test 29 | type Ttest struct { 30 | empty.TypeMeta 31 | NTP Tpointer 32 | Tp *Tpointer 33 | } 34 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/generate.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | /* 4 | Copyright 2024 The Kubernetes Authors. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | // Ignore this file to prevent zz_generated for this package 20 | 21 | //go:generate go run k8s.io/code-generator/cmd/validation-gen --output-file zz_generated.validations.go --go-header-file=../../../examples/hack/boilerplate.go.txt ./... 22 | package outputtests 23 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/ordering/structs/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*structs.T00": { 3 | "pt.os": [ 4 | "Tother, no flags" 5 | ], 6 | "t.os": [ 7 | "Tother, no flags" 8 | ] 9 | }, 10 | "*structs.T01": { 11 | "": [ 12 | "T01, no flags" 13 | ], 14 | "ps": [ 15 | "T01.PS, no flags" 16 | ], 17 | "pt": [ 18 | "T01.PT, no flags" 19 | ], 20 | "pt.os": [ 21 | "Tother, no flags" 22 | ], 23 | "s": [ 24 | "T01.S, no flags" 25 | ], 26 | "t": [ 27 | "T01.T, no flags" 28 | ], 29 | "t.os": [ 30 | "Tother, no flags" 31 | ] 32 | }, 33 | "*structs.T02": { 34 | "": [ 35 | "T02, ShortCircuit" 36 | ] 37 | }, 38 | "*structs.T03": { 39 | "": [ 40 | "T03, ShortCircuit" 41 | ] 42 | }, 43 | "*structs.TMultiple": { 44 | "": [ 45 | "TMultiple, ShortCircuit 1", 46 | "TMultiple, ShortCircuit 2" 47 | ] 48 | } 49 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/validate_true/doc_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package validatetrue 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Test(t *testing.T) { 24 | st := localSchemeBuilder.Test(t) 25 | 26 | st.Value(&Struct{ 27 | // All zero-values. 28 | }).ExpectValid() 29 | 30 | st.Value(&Struct{ 31 | StringField: "abc", 32 | }).ExpectValid() 33 | } 34 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/cohorts/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package cohorts 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/embedded/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package embedded 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/maps/keys/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package keys 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/pointers/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package pointers 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/typedefs/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package typedefs 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/cross_pkg/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package crosspkg 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/primitives/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package primitives 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/recursive/maps/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package maps 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/type_args/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package typeargs 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/multiple_tags/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package multipletags 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/no_types_match/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package notypesmatch 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/ordering/structs/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package structs 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/ordering/typedefs/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package typedefs 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/recursive/pointers/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package pointers 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/recursive/slices/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package slices 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/deepcopy-gen/output_tests/pointer/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | 19 | // This is a test package. 20 | package pointer 21 | 22 | type Ttest struct { 23 | Builtin *string 24 | Ptr **string 25 | Map *map[string]string 26 | Slice *[]string 27 | MapPtr **map[string]string 28 | SlicePtr **[]string 29 | Struct *Ttest 30 | StructPtr **Ttest 31 | } 32 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/all_types_match/trivial/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package trivial 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/maps/map_of_struct/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package mapofstruct 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/maps/typedef_to_map/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package typedeftomap 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/public_private/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package publicprivate 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/update_validations/lists/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package lists 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/update_validations/maps/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package maps 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /examples/apiserver/apis/example/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:openapi-gen=true 18 | // +k8s:deepcopy-gen=package 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +k8s:conversion-gen=k8s.io/code-generator/examples/apiserver/apis/example 21 | // +groupName=example.apiserver.code-generator.k8s.io 22 | // +k8s:openapi-model-package=io.k8s.code-generator.examples.apiserver.apis.example.v1 23 | 24 | package v1 25 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/maps/map_of_primitive/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package mapofprimitive 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/slices/slice_of_struct/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package sliceofstruct 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/elide_no_validations/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package elidenovalidations 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/slices/slice_of_primitive/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package sliceofprimitive 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/slices/typedef_to_slice/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package typedeftoslice 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/maps/multiple_validations/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package multiplevalidations 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/slices/multiple_validations/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package multiplevalidations 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/all_types_match/with_type_validations/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package withtypevalidations 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/one_type_match/with_type_validations/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package withtypevalidations 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/marker/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package marker 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | //nolint:unused 24 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 25 | return RegisterDefaults(scheme) 26 | } 27 | 28 | func SetDefaults_DefaultedWithFunction(obj *DefaultedWithFunction) { 29 | if obj.S1 == "" { 30 | obj.S1 = "default_function" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/slices/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package slices 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | //nolint:unused 24 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 25 | return RegisterDefaults(scheme) 26 | } 27 | 28 | func SetDefaults_Ttest(obj *Ttest) { 29 | if obj.BoolField == nil { 30 | obj.BoolField = new(bool) 31 | *obj.BoolField = true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/all_types_match/with_field_validations/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package withfieldvalidations 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/one_type_match/with_field_validations/zz_generated.validations_test.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package withfieldvalidations 23 | 24 | import ( 25 | "testing" 26 | ) 27 | 28 | func TestValidation(t *testing.T) { 29 | localSchemeBuilder.Test(t).ValidateFixtures() 30 | } 31 | -------------------------------------------------------------------------------- /cmd/client-gen/generators/util/gvpackages.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package util 18 | 19 | import "strings" 20 | 21 | func ParsePathGroupVersion(pgvString string) (gvPath string, gvString string) { 22 | subs := strings.Split(pgvString, "/") 23 | length := len(subs) 24 | switch length { 25 | case 0, 1, 2: 26 | return "", pgvString 27 | default: 28 | return strings.Join(subs[:length-2], "/"), strings.Join(subs[length-2:], "/") 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/pointer/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package pointer 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | //nolint:unused 24 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 25 | return RegisterDefaults(scheme) 26 | } 27 | 28 | func SetDefaults_Tpointer(obj *Tpointer) { 29 | if obj.BoolField == nil { 30 | obj.BoolField = new(bool) 31 | *obj.BoolField = true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/slices/type.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package slices 18 | 19 | import ( 20 | "k8s.io/code-generator/cmd/defaulter-gen/output_tests/empty" 21 | ) 22 | 23 | // Only test 24 | type Ttest struct { 25 | empty.TypeMeta 26 | BoolField *bool 27 | } 28 | 29 | type TtestList struct { 30 | empty.TypeMeta 31 | Items []Ttest 32 | } 33 | 34 | type TtestPointerList struct { 35 | empty.TypeMeta 36 | Items []*Ttest 37 | } 38 | -------------------------------------------------------------------------------- /examples/apiserver/apis/example2/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:openapi-gen=true 18 | // +k8s:deepcopy-gen=package 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +groupName=example.test.apiserver.code-generator.k8s.io 21 | // +k8s:conversion-gen=k8s.io/code-generator/examples/apiserver/apis/example2 22 | // +groupGoName=SecondExample 23 | // +k8s:openapi-model-package=io.k8s.code-generator.examples.apiserver.apis.example2.v1 24 | 25 | package v1 26 | -------------------------------------------------------------------------------- /examples/crd/listers/example2/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // TestTypeListerExpansion allows custom methods to be added to 22 | // TestTypeLister. 23 | type TestTypeListerExpansion interface{} 24 | 25 | // TestTypeNamespaceListerExpansion allows custom methods to be added to 26 | // TestTypeNamespaceLister. 27 | type TestTypeNamespaceListerExpansion interface{} 28 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/subfield/nonincluded/doc_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package nonincluded 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func TestSubfieldObjectMetaValidationWithValidateFalse(t *testing.T) { 24 | st := localSchemeBuilder.Test(t) 25 | 26 | st.Value(&Struct{}).ExpectValidateFalseByPath(map[string][]string{ 27 | "other.StructType.stringField": {"subfield Struct.(other.StructType).StringField"}, 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /examples/apiserver/listers/core/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // TestTypeListerExpansion allows custom methods to be added to 22 | // TestTypeLister. 23 | type TestTypeListerExpansion interface{} 24 | 25 | // TestTypeNamespaceListerExpansion allows custom methods to be added to 26 | // TestTypeNamespaceLister. 27 | type TestTypeNamespaceListerExpansion interface{} 28 | -------------------------------------------------------------------------------- /examples/apiserver/listers/example/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // TestTypeListerExpansion allows custom methods to be added to 22 | // TestTypeLister. 23 | type TestTypeListerExpansion interface{} 24 | 25 | // TestTypeNamespaceListerExpansion allows custom methods to be added to 26 | // TestTypeNamespaceLister. 27 | type TestTypeNamespaceListerExpansion interface{} 28 | -------------------------------------------------------------------------------- /examples/crd/listers/conflicting/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // TestTypeListerExpansion allows custom methods to be added to 22 | // TestTypeLister. 23 | type TestTypeListerExpansion interface{} 24 | 25 | // TestTypeNamespaceListerExpansion allows custom methods to be added to 26 | // TestTypeNamespaceLister. 27 | type TestTypeNamespaceListerExpansion interface{} 28 | -------------------------------------------------------------------------------- /examples/crd/listers/extensions/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // TestTypeListerExpansion allows custom methods to be added to 22 | // TestTypeLister. 23 | type TestTypeListerExpansion interface{} 24 | 25 | // TestTypeNamespaceListerExpansion allows custom methods to be added to 26 | // TestTypeNamespaceLister. 27 | type TestTypeNamespaceListerExpansion interface{} 28 | -------------------------------------------------------------------------------- /examples/apiserver/apis/example3.io/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:openapi-gen=true 18 | // +k8s:deepcopy-gen=package 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +groupName=example.dots.apiserver.code-generator.k8s.io 21 | // +k8s:conversion-gen=k8s.io/code-generator/examples/apiserver/apis/example3.io 22 | // +groupGoName=ThirdExample 23 | // +k8s:openapi-model-package=io.k8s.code-generator.examples.apiserver.apis.example3.io.v1 24 | 25 | package v1 26 | -------------------------------------------------------------------------------- /examples/apiserver/listers/example3.io/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // TestTypeListerExpansion allows custom methods to be added to 22 | // TestTypeLister. 23 | type TestTypeListerExpansion interface{} 24 | 25 | // TestTypeNamespaceListerExpansion allows custom methods to be added to 26 | // TestTypeNamespaceLister. 27 | type TestTypeNamespaceListerExpansion interface{} 28 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/wholepkg/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package wholepkg 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | //nolint:unused 24 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 25 | return RegisterDefaults(scheme) 26 | } 27 | 28 | func SetDefaults_StructPrimitives(obj *StructPrimitives) { 29 | if obj.BoolField == nil { 30 | obj.BoolField = new(bool) 31 | *obj.BoolField = true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/union/union/discriminated/empty/doc_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package empty 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func Test(t *testing.T) { 24 | st := localSchemeBuilder.Test(t) 25 | 26 | // Unions discriminators may be optional. 27 | st.Value(&Struct{D: D("")}).ExpectValid() 28 | 29 | // Unions discriminators Should be validated for valid values. 30 | st.Value(&Struct{D: D("Unknown")}).ExpectValid() 31 | } 32 | -------------------------------------------------------------------------------- /cmd/deepcopy-gen/output_tests/builtins/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | 19 | // This is a test package. 20 | package builtins 21 | 22 | type Ttest struct { 23 | Byte byte 24 | // Int8 int8 // TODO: int8 becomes byte in SnippetWriter 25 | Int16 int16 26 | Int32 int32 27 | Int64 int64 28 | Uint8 uint8 29 | Uint16 uint16 30 | Uint32 uint32 31 | Uint64 uint64 32 | Float32 float32 33 | Float64 float64 34 | String string 35 | } 36 | -------------------------------------------------------------------------------- /cmd/validation-gen/lint_rules.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | var ruleOptionalAndRequired = conflictingTagsRule( 20 | "fields cannot be both optional and required", 21 | "+k8s:optional", "+k8s:required") 22 | 23 | var ruleRequiredAndDefault = conflictingTagsRule( 24 | "fields with default values are always optional", 25 | "+k8s:required", "+default") 26 | 27 | var defaultLintRules = []lintRule{ 28 | ruleOptionalAndRequired, 29 | ruleRequiredAndDefault, 30 | } 31 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/one_type_match/trivial/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=TypeMeta 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | 20 | // This is a test package. 21 | package trivial 22 | 23 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 24 | 25 | var localSchemeBuilder = testscheme.New() 26 | 27 | type T1 struct { 28 | TypeMeta int 29 | } 30 | 31 | type T2 struct{} 32 | 33 | type E1 string 34 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/typedefs/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*typedefs.T1": { 3 | "": [ 4 | "type T1" 5 | ], 6 | "e1": [ 7 | "field T1.E1", 8 | "type E1" 9 | ], 10 | "e2": [ 11 | "field T1.E2", 12 | "type E2" 13 | ], 14 | "e3": [ 15 | "field T1.E3", 16 | "type E3" 17 | ], 18 | "e4": [ 19 | "field T1.E4", 20 | "type E4" 21 | ], 22 | "e4.s": [ 23 | "field T2.S" 24 | ], 25 | "pe1": [ 26 | "field T1.PE1", 27 | "type E1" 28 | ], 29 | "pe2": [ 30 | "field T1.PE2", 31 | "type E2" 32 | ], 33 | "pe3": [ 34 | "field T1.PE3", 35 | "type E3" 36 | ], 37 | "pe4": [ 38 | "field T1.PE4", 39 | "type E4" 40 | ], 41 | "pe4.s": [ 42 | "field T2.S" 43 | ], 44 | "pt2": [ 45 | "field T1.PT2", 46 | "type T2" 47 | ], 48 | "pt2.s": [ 49 | "field T2.S" 50 | ], 51 | "t2": [ 52 | "field T1.T2", 53 | "type T2" 54 | ], 55 | "t2.s": [ 56 | "field T2.S" 57 | ] 58 | } 59 | } -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/generate.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | /* 4 | Copyright 2024 The Kubernetes Authors. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | // Ignore this file to prevent zz_generated for this package 20 | 21 | //go:generate go run k8s.io/code-generator/cmd/defaulter-gen --output-file zz_generated.defaults.go --go-header-file=../../../examples/hack/boilerplate.go.txt k8s.io/code-generator/cmd/defaulter-gen/output_tests/... 22 | package outputtests 23 | 24 | import ( 25 | // For go-generate 26 | _ "k8s.io/code-generator/cmd/defaulter-gen/generators" 27 | ) 28 | -------------------------------------------------------------------------------- /cmd/client-gen/types/helpers_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package types 18 | 19 | import ( 20 | "reflect" 21 | "sort" 22 | "testing" 23 | ) 24 | 25 | func TestVersionSort(t *testing.T) { 26 | unsortedVersions := []string{"v4beta1", "v2beta1", "v2alpha1", "v3", "v1"} 27 | expected := []string{"v2alpha1", "v2beta1", "v4beta1", "v1", "v3"} 28 | sort.Sort(sortableSliceOfVersions(unsortedVersions)) 29 | if !reflect.DeepEqual(unsortedVersions, expected) { 30 | t.Errorf("expected %#v\ngot %#v", expected, unsortedVersions) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cmd/go-to-protobuf/protobuf/tags.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package protobuf 18 | 19 | import ( 20 | "k8s.io/gengo/v2" 21 | "k8s.io/klog/v2" 22 | ) 23 | 24 | // extractBoolTagOrDie gets the comment-tags for the key and asserts that, if 25 | // it exists, the value is boolean. If the tag did not exist, it returns 26 | // false. 27 | func extractBoolTagOrDie(key string, lines []string) bool { 28 | val, err := gengo.ExtractSingleBoolCommentTag("+", key, false, lines) 29 | if err != nil { 30 | klog.Fatal(err) 31 | } 32 | return val 33 | } 34 | -------------------------------------------------------------------------------- /cmd/deepcopy-gen/output_tests/structs/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | 19 | // This is a test package. 20 | package structs 21 | 22 | type Inner struct { 23 | Byte byte 24 | // Int8 int8 //TODO: int8 becomes byte in SnippetWriter 25 | Int16 int16 26 | Int32 int32 27 | Int64 int64 28 | Uint8 uint8 29 | Uint16 uint16 30 | Uint32 uint32 31 | Uint64 uint64 32 | Float32 float32 33 | Float64 float64 34 | String string 35 | } 36 | 37 | type Ttest struct { 38 | Inner1 Inner 39 | Inner2 Inner 40 | } 41 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/validate_true/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=TypeMeta 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | 20 | // This is a test package. 21 | package validatetrue 22 | 23 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 24 | 25 | var localSchemeBuilder = testscheme.New() 26 | 27 | type Struct struct { 28 | TypeMeta int 29 | 30 | // +k8s:validateTrue="field Struct.StringField" 31 | StringField string `json:"stringField"` 32 | } 33 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/validate_false/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=TypeMeta 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | 20 | // This is a test package. 21 | package validatefalse 22 | 23 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 24 | 25 | var localSchemeBuilder = testscheme.New() 26 | 27 | type Struct struct { 28 | TypeMeta int 29 | 30 | // +k8s:validateFalse="field Struct.StringField" 31 | StringField string `json:"stringField"` 32 | } 33 | -------------------------------------------------------------------------------- /examples/apiserver/listers/example2/v1/testtype_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | // TestTypeListerExpansion allows custom methods to be added to 20 | // TestTypeLister. 21 | type TestTypeListerExpansion interface { 22 | CheckExpansionSupport() 23 | } 24 | 25 | // TestTypeNamespaceListerExpansion allows custom methods to be added to 26 | // TestTypeNamespaceLister. 27 | type TestTypeNamespaceListerExpansion interface{} 28 | 29 | func (*testTypeLister) CheckExpansionSupport() { 30 | // This checks that lister-gen correctly supports expansions 31 | } 32 | -------------------------------------------------------------------------------- /examples/single/api/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/union/union/discriminated/empty/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=TypeMeta 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | 20 | // This is a test package. 21 | package empty 22 | 23 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 24 | 25 | var localSchemeBuilder = testscheme.New() 26 | 27 | // Empty discriminated union 28 | type Struct struct { 29 | TypeMeta int 30 | 31 | // +k8s:unionDiscriminator 32 | D D `json:"d"` 33 | } 34 | 35 | type D string 36 | -------------------------------------------------------------------------------- /examples/crd/apis/example/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /examples/crd/apis/example2/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /examples/MixedCase/apis/example/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /examples/apiserver/apis/core/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /examples/apiserver/apis/example/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /examples/apiserver/apis/example2/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /examples/crd/apis/conflicting/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /examples/crd/apis/extensions/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /cmd/defaulter-gen/output_tests/empty/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package empty 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /examples/HyphenGroup/apis/example/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /examples/apiserver/apis/example3.io/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/all_types_match/trivial/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Note: this selects all types in the package. 18 | // +k8s:validation-gen=* 19 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 20 | // +k8s:validation-gen-test-fixture=validateFalse 21 | 22 | // This is a test package. 23 | package trivial 24 | 25 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 26 | 27 | var localSchemeBuilder = testscheme.New() 28 | 29 | type T1 struct{} 30 | 31 | type T2 struct{} 32 | 33 | type E1 string 34 | 35 | type E2 string 36 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/update_validations/lists/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=* 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | // +k8s:validation-gen-test-fixture=validateFalse 20 | 21 | // This is a test package. 22 | package lists 23 | 24 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 25 | 26 | var localSchemeBuilder = testscheme.New() 27 | 28 | type T1 struct { 29 | LM1 []M1 `json:"lm1"` 30 | } 31 | 32 | type M1 struct { 33 | // +k8s:validateFalse="M1.S" 34 | S string `json:"s"` 35 | } 36 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/update_validations/maps/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=* 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | // +k8s:validation-gen-test-fixture=validateFalse 20 | 21 | // This is a test package. 22 | package maps 23 | 24 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 25 | 26 | var localSchemeBuilder = testscheme.New() 27 | 28 | type T1 struct { 29 | MSM1 map[string]M1 `json:"msm1"` 30 | } 31 | 32 | type M1 struct { 33 | // +k8s:validateFalse="M1.S" 34 | S string `json:"s"` 35 | } 36 | -------------------------------------------------------------------------------- /examples/crd/listers/example/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // ClusterTestTypeListerExpansion allows custom methods to be added to 22 | // ClusterTestTypeLister. 23 | type ClusterTestTypeListerExpansion interface{} 24 | 25 | // TestTypeListerExpansion allows custom methods to be added to 26 | // TestTypeLister. 27 | type TestTypeListerExpansion interface{} 28 | 29 | // TestTypeNamespaceListerExpansion allows custom methods to be added to 30 | // TestTypeNamespaceLister. 31 | type TestTypeNamespaceListerExpansion interface{} 32 | -------------------------------------------------------------------------------- /examples/single/listers/api/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // ClusterTestTypeListerExpansion allows custom methods to be added to 22 | // ClusterTestTypeLister. 23 | type ClusterTestTypeListerExpansion interface{} 24 | 25 | // TestTypeListerExpansion allows custom methods to be added to 26 | // TestTypeLister. 27 | type TestTypeListerExpansion interface{} 28 | 29 | // TestTypeNamespaceListerExpansion allows custom methods to be added to 30 | // TestTypeNamespaceLister. 31 | type TestTypeNamespaceListerExpansion interface{} 32 | -------------------------------------------------------------------------------- /examples/MixedCase/listers/example/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // ClusterTestTypeListerExpansion allows custom methods to be added to 22 | // ClusterTestTypeLister. 23 | type ClusterTestTypeListerExpansion interface{} 24 | 25 | // TestTypeListerExpansion allows custom methods to be added to 26 | // TestTypeLister. 27 | type TestTypeListerExpansion interface{} 28 | 29 | // TestTypeNamespaceListerExpansion allows custom methods to be added to 30 | // TestTypeNamespaceLister. 31 | type TestTypeNamespaceListerExpansion interface{} 32 | -------------------------------------------------------------------------------- /examples/HyphenGroup/listers/example/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // ClusterTestTypeListerExpansion allows custom methods to be added to 22 | // ClusterTestTypeLister. 23 | type ClusterTestTypeListerExpansion interface{} 24 | 25 | // TestTypeListerExpansion allows custom methods to be added to 26 | // TestTypeLister. 27 | type TestTypeListerExpansion interface{} 28 | 29 | // TestTypeNamespaceListerExpansion allows custom methods to be added to 30 | // TestTypeNamespaceLister. 31 | type TestTypeNamespaceListerExpansion interface{} 32 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/maps/keys/testdata/validate-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "*keys.Struct": { 3 | "": [ 4 | "type Struct" 5 | ], 6 | "mapField": [ 7 | "field Struct.MapField", 8 | "field Struct.MapField(keys)", 9 | "field Struct.MapField(keys)" 10 | ], 11 | "mapTypeField": [ 12 | "field Struct.MapTypeField", 13 | "field Struct.MapTypeField(keys)", 14 | "field Struct.MapTypeField(keys)" 15 | ], 16 | "mapTypedefField": [ 17 | "field Struct.MapTypedefField", 18 | "field Struct.MapTypedefField(keys)", 19 | "field Struct.MapTypedefField(keys)" 20 | ], 21 | "mapValidatedTypedefField": [ 22 | "ValidatedStringType", 23 | "ValidatedStringType", 24 | "field Struct.MapValidatedTypedefField", 25 | "field Struct.MapValidatedTypedefField(keys)", 26 | "field Struct.MapValidatedTypedefField(keys)" 27 | ], 28 | "validatedMapTypeField": [ 29 | "ValidatedMapType", 30 | "field Struct.ValidatedMapTypeField", 31 | "field Struct.ValidatedMapTypeField(keys)", 32 | "field Struct.ValidatedMapTypeField(keys)", 33 | "type ValidatedMapType(keys)", 34 | "type ValidatedMapType(keys)" 35 | ] 36 | } 37 | } -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/update_validations/primitives/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=* 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | 20 | // This is a test package. 21 | package primitives 22 | 23 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 24 | 25 | var localSchemeBuilder = testscheme.New() 26 | 27 | type Struct struct { 28 | // +k8s:immutable 29 | S string `json:"s"` 30 | // +k8s:immutable 31 | I int `json:"i"` 32 | // +k8s:immutable 33 | B bool `json:"b"` 34 | // +k8s:immutable 35 | F float64 `json:"f"` 36 | } 37 | -------------------------------------------------------------------------------- /cmd/validation-gen/validators/common.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package validators 18 | 19 | import ( 20 | "k8s.io/gengo/v2/types" 21 | ) 22 | 23 | const ( 24 | // libValidationPkg is the pkgpath to our "standard library" of validation 25 | // functions. 26 | libValidationPkg = "k8s.io/apimachinery/pkg/api/validate" 27 | ) 28 | 29 | // rootTypeString returns a string representation of the relationship between 30 | // src and dst types, for use in error messages. 31 | func rootTypeString(src, dst *types.Type) string { 32 | if src == dst { 33 | return src.String() 34 | } 35 | return src.String() + " -> " + dst.String() 36 | } 37 | -------------------------------------------------------------------------------- /cmd/go-to-protobuf/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // go-to-protobuf generates a Protobuf IDL from a Go struct, respecting any 18 | // existing IDL tags on the Go struct. 19 | package main 20 | 21 | import ( 22 | goflag "flag" 23 | 24 | flag "github.com/spf13/pflag" 25 | "k8s.io/code-generator/cmd/go-to-protobuf/protobuf" 26 | "k8s.io/klog/v2" 27 | ) 28 | 29 | var g = protobuf.New() 30 | 31 | func init() { 32 | klog.InitFlags(nil) 33 | g.BindFlags(flag.CommandLine) 34 | goflag.Set("logtostderr", "true") 35 | flag.CommandLine.AddGoFlagSet(goflag.CommandLine) 36 | } 37 | 38 | func main() { 39 | flag.Parse() 40 | protobuf.Run(g) 41 | } 42 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/no_types_match/zz_generated.validations.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package notypesmatch 23 | 24 | import ( 25 | testscheme "k8s.io/code-generator/cmd/validation-gen/testscheme" 26 | ) 27 | 28 | func init() { localSchemeBuilder.Register(RegisterValidations) } 29 | 30 | // RegisterValidations adds validation functions to the given scheme. 31 | // Public to allow building arbitrary schemes. 32 | func RegisterValidations(scheme *testscheme.Scheme) error { 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/one_type_match/trivial/zz_generated.validations.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package trivial 23 | 24 | import ( 25 | testscheme "k8s.io/code-generator/cmd/validation-gen/testscheme" 26 | ) 27 | 28 | func init() { localSchemeBuilder.Register(RegisterValidations) } 29 | 30 | // RegisterValidations adds validation functions to the given scheme. 31 | // Public to allow building arbitrary schemes. 32 | func RegisterValidations(scheme *testscheme.Scheme) error { 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/all_types_match/trivial/zz_generated.validations.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by validation-gen. DO NOT EDIT. 21 | 22 | package trivial 23 | 24 | import ( 25 | testscheme "k8s.io/code-generator/cmd/validation-gen/testscheme" 26 | ) 27 | 28 | func init() { localSchemeBuilder.Register(RegisterValidations) } 29 | 30 | // RegisterValidations adds validation functions to the given scheme. 31 | // Public to allow building arbitrary schemes. 32 | func RegisterValidations(scheme *testscheme.Scheme) error { 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/supported_resources/issubresource/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Note: this selects all types in the package. 18 | // +k8s:validation-gen=* 19 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 20 | 21 | // This is a test package. 22 | package issubresource 23 | 24 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 25 | 26 | var localSchemeBuilder = testscheme.New() 27 | 28 | // Root resource is supported by default 29 | 30 | // +k8s:isSubresource=/scale 31 | 32 | // T1 is a test type 33 | type T1 struct { 34 | // +k8s:validateTrue="field T1.S" 35 | S string `json:"s"` 36 | } 37 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/one_type_match/with_type_validations/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=TypeMeta 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | // +k8s:validation-gen-test-fixture=validateFalse 20 | 21 | // This is a test package. 22 | package withtypevalidations 23 | 24 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 25 | 26 | var localSchemeBuilder = testscheme.New() 27 | 28 | // +k8s:validateFalse="type T1" 29 | type T1 struct { 30 | TypeMeta int 31 | } 32 | 33 | // Note: this has no validations. 34 | type T2 struct{} 35 | 36 | // +k8s:validateFalse="type E1" 37 | type E1 string 38 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/no_generation/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Note: validation generation is not enabled. 18 | 19 | // Package nogeneration is a test package. 20 | // 21 | //nolint:unused 22 | package nogeneration 23 | 24 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 25 | 26 | var localSchemeBuilder = testscheme.New() 27 | 28 | type T1 struct { 29 | // +k8s:validateFalse="from field T1.S" 30 | S string 31 | // +k8s:validateFalse="from field T1.T2" 32 | T2 T2 33 | } 34 | 35 | type T2 struct { 36 | // +k8s:validateFalse="from field T2.S" 37 | S string 38 | } 39 | 40 | type private struct { 41 | // +k8s:validateFalse="from field private.S" 42 | S string 43 | } 44 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/update_validations/primitive_pointers/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=* 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | 20 | // Package primitivepointers is a test package. 21 | // 22 | //nolint:unused 23 | package primitivepointers 24 | 25 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 26 | 27 | var localSchemeBuilder = testscheme.New() 28 | 29 | type Struct struct { 30 | // +k8s:immutable 31 | SP *string `json:"sp"` 32 | // +k8s:immutable 33 | IP *int `json:"ip"` 34 | // +k8s:immutable 35 | BP *bool `json:"bp"` 36 | // +k8s:immutable 37 | FP *float64 `json:"fp"` 38 | } 39 | -------------------------------------------------------------------------------- /cmd/deepcopy-gen/output_tests/builtins/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by deepcopy-gen. DO NOT EDIT. 21 | 22 | package builtins 23 | 24 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 25 | func (in *Ttest) DeepCopyInto(out *Ttest) { 26 | *out = *in 27 | return 28 | } 29 | 30 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Ttest. 31 | func (in *Ttest) DeepCopy() *Ttest { 32 | if in == nil { 33 | return nil 34 | } 35 | out := new(Ttest) 36 | in.DeepCopyInto(out) 37 | return out 38 | } 39 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/no_types_match/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Note: no types match this. 18 | // +k8s:validation-gen=TypeMeta 19 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 20 | // +k8s:validation-gen-test-fixture=validateFalse 21 | 22 | // This is a test package. 23 | package notypesmatch 24 | 25 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 26 | 27 | var localSchemeBuilder = testscheme.New() 28 | 29 | type T1 struct { 30 | // +k8s:validateFalse="from field T1.S" 31 | S string 32 | // +k8s:validateFalse="from field T1.T2" 33 | T2 T2 34 | } 35 | 36 | type T2 struct { 37 | // +k8s:validateFalse="from field T2.S" 38 | S string 39 | } 40 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/subfield/nonincluded/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=* 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | 20 | // Package nonincluded contains test types for testing subfield field validation tags. 21 | package nonincluded 22 | 23 | import ( 24 | "k8s.io/code-generator/cmd/validation-gen/output_tests/_codegenignore/other" 25 | "k8s.io/code-generator/cmd/validation-gen/testscheme" 26 | ) 27 | 28 | var localSchemeBuilder = testscheme.New() 29 | 30 | type Struct struct { 31 | // +k8s:subfield(stringField)=+k8s:validateFalse="subfield Struct.(other.StructType).StringField" 32 | // +k8s:opaqueType 33 | other.StructType 34 | } 35 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/neq/neqbool/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=TypeMeta 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | 20 | // This is a test package. 21 | package neqbool 22 | 23 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 24 | 25 | var localSchemeBuilder = testscheme.New() 26 | 27 | type Struct struct { 28 | TypeMeta int 29 | 30 | // +k8s:neq=true 31 | NeqTrueField bool `json:"neqTrueField"` 32 | 33 | // +k8s:neq=false 34 | NeqFalsePtrField *bool `json:"neqFalsePtrField"` 35 | 36 | ValidatedTypedefField ValidatedBoolType `json:"validatedTypedefField"` 37 | } 38 | 39 | // +k8s:neq=true 40 | type ValidatedBoolType bool 41 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/supported_resources/subresource/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Note: this selects all types in the package. 18 | // +k8s:validation-gen=* 19 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 20 | 21 | // This is a test package. 22 | package subresource 23 | 24 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 25 | 26 | var localSchemeBuilder = testscheme.New() 27 | 28 | // Root resource is supported by default 29 | 30 | // +k8s:supportsSubresource=/status 31 | // +k8s:supportsSubresource=/scale 32 | // +k8s:supportsSubresource=/x/y 33 | 34 | // T1 is a test type 35 | type T1 struct { 36 | // +k8s:validateTrue="field T1.S" 37 | S string `json:"s"` 38 | } 39 | -------------------------------------------------------------------------------- /examples/apiserver/apis/core/install/install.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package install installs the experimental API group, making it available as 18 | // an option to all of the API encoding/decoding machinery. 19 | package install 20 | 21 | import ( 22 | "k8s.io/apimachinery/pkg/runtime" 23 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 24 | "k8s.io/code-generator/examples/apiserver/apis/core" 25 | "k8s.io/code-generator/examples/apiserver/apis/core/v1" 26 | ) 27 | 28 | // Install registers the API group and adds types to a scheme 29 | func Install(scheme *runtime.Scheme) { 30 | utilruntime.Must(core.AddToScheme(scheme)) 31 | utilruntime.Must(v1.AddToScheme(scheme)) 32 | utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion)) 33 | } 34 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/eachval/slice_of_primitive/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=TypeMeta 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | 20 | // This is a test package. 21 | package sliceofprimitive 22 | 23 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 24 | 25 | var localSchemeBuilder = testscheme.New() 26 | 27 | type Struct struct { 28 | TypeMeta int 29 | 30 | // +k8s:eachVal=+k8s:validateFalse="field Struct.ListField[*]" 31 | ListField []string `json:"listField"` 32 | 33 | // +k8s:eachVal=+k8s:validateFalse="field Struct.ListTypedefField[*]" 34 | ListTypedefField []StringType `json:"listTypedefField"` 35 | } 36 | 37 | type StringType string 38 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/eachval/map_of_primitive/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=TypeMeta 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | 20 | // This is a test package. 21 | package mapofprimitive 22 | 23 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 24 | 25 | var localSchemeBuilder = testscheme.New() 26 | 27 | type Struct struct { 28 | TypeMeta int 29 | 30 | // +k8s:eachVal=+k8s:validateFalse="field Struct.MapField[*]" 31 | MapField map[string]string `json:"mapField"` 32 | 33 | // +k8s:eachVal=+k8s:validateFalse="field Struct.MapTypedefField[*]" 34 | MapTypedefField map[string]StringType `json:"mapTypedefField"` 35 | } 36 | 37 | type StringType string 38 | -------------------------------------------------------------------------------- /examples/apiserver/apis/example/install/install.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package install installs the experimental API group, making it available as 18 | // an option to all of the API encoding/decoding machinery. 19 | package install 20 | 21 | import ( 22 | "k8s.io/apimachinery/pkg/runtime" 23 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 24 | "k8s.io/code-generator/examples/apiserver/apis/example" 25 | "k8s.io/code-generator/examples/apiserver/apis/example/v1" 26 | ) 27 | 28 | // Install registers the API group and adds types to a scheme 29 | func Install(scheme *runtime.Scheme) { 30 | utilruntime.Must(example.AddToScheme(scheme)) 31 | utilruntime.Must(v1.AddToScheme(scheme)) 32 | utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion)) 33 | } 34 | -------------------------------------------------------------------------------- /examples/apiserver/apis/example2/install/install.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package install installs the experimental API group, making it available as 18 | // an option to all of the API encoding/decoding machinery. 19 | package install 20 | 21 | import ( 22 | "k8s.io/apimachinery/pkg/runtime" 23 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 24 | "k8s.io/code-generator/examples/apiserver/apis/example2" 25 | "k8s.io/code-generator/examples/apiserver/apis/example2/v1" 26 | ) 27 | 28 | // Install registers the API group and adds types to a scheme 29 | func Install(scheme *runtime.Scheme) { 30 | utilruntime.Must(example2.AddToScheme(scheme)) 31 | utilruntime.Must(v1.AddToScheme(scheme)) 32 | utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion)) 33 | } 34 | -------------------------------------------------------------------------------- /cmd/validation-gen/output_tests/tags/item/union/simple/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:validation-gen=TypeMeta 18 | // +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme 19 | 20 | // This is a test package. 21 | package unionsimple 22 | 23 | import "k8s.io/code-generator/cmd/validation-gen/testscheme" 24 | 25 | var localSchemeBuilder = testscheme.New() 26 | 27 | type Struct struct { 28 | TypeMeta int `json:"typeMeta"` 29 | 30 | // +k8s:listType=map 31 | // +k8s:listMapKey=name 32 | // +k8s:item(name: "succeeded")=+k8s:unionMember 33 | // +k8s:item(name: "failed")=+k8s:unionMember 34 | Tasks []Task `json:"tasks"` 35 | } 36 | 37 | type Task struct { 38 | Name string `json:"name"` 39 | State string `json:"state"` 40 | } 41 | -------------------------------------------------------------------------------- /examples/apiserver/clientset/versioned/typed/core/v1/fake/fake_core_client.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | rest "k8s.io/client-go/rest" 23 | testing "k8s.io/client-go/testing" 24 | v1 "k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/core/v1" 25 | ) 26 | 27 | type FakeCoreV1 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeCoreV1) TestTypes(namespace string) v1.TestTypeInterface { 32 | return newFakeTestTypes(c, namespace) 33 | } 34 | 35 | // RESTClient returns a RESTClient that is used to communicate 36 | // with API server by this client implementation. 37 | func (c *FakeCoreV1) RESTClient() rest.Interface { 38 | var ret *rest.RESTClient 39 | return ret 40 | } 41 | --------------------------------------------------------------------------------