Commit Graph

276 Commits (4db004972ad943b7f2db36e6039a3166b5e925df)

Author SHA1 Message Date
deads2k 32920b5617 add subjectaccessreviews resource 2016-08-05 11:20:56 -04:00
Tim St. Clair f4ce5583c2
Adjust verbosity levels of go2idl logging 2016-08-04 22:01:35 -07:00
deads2k d50506345c fix String protobuf generator 2016-08-03 08:37:45 -04:00
deads2k 60dd4a5d26 interesting changes to add tokenreviews endpoint to implement webhook 2016-08-03 08:37:45 -04:00
Chao Xu 81858d755e add validateListType to pkg/api/meta/schema_test.go 2016-08-02 15:47:24 -07:00
jianhuiz 41b409b24e support included-types-overrides without version provided (group/type) 2016-07-21 14:00:35 -07:00
Wojciech Tyczynski 4d0d115690 Revert "add tokenreviews endpoint to implement webhook" 2016-07-21 09:40:35 +02:00
deads2k 2256c6e619 fix String protobuf generator 2016-07-20 15:11:57 -04:00
deads2k 2c4a9f2e8d interesting changes to add tokenreviews endpoint to implement webhook 2016-07-20 15:11:56 -04:00
k8s-merge-robot a3ce4513ad Merge pull request #28934 from smarterclayton/optional_slice
Automatic merge from submit-queue

Unable to have optional message slice

When making a message slice optional, we need to handle one more
conditional case in the rewriter.

@wojtek-t
2016-07-19 12:55:19 -07:00
Davanum Srinivas 2b0ed014b7 Use Go canonical import paths
Add canonical imports only in existing doc.go files.
https://golang.org/doc/go1.4#canonicalimports

Fixes #29014
2016-07-16 13:48:21 -04:00
k8s-merge-robot 5844145795 Merge pull request #28815 from smarterclayton/fix_stringer
Automatic merge from submit-queue

Generate a better Stringer method for proto types

This replaces the bad string output generated by golang/proto with gogo/protobuf stringer generation. Makes the output similar to %#v and more debuggable. We have to have a String() method to implement proto.Message, so this is strictly better.

@wojtek-t, @thockin for after your PR merges

Fixes #28756
2016-07-15 05:49:40 -07:00
k8s-merge-robot ff998ab566 Merge pull request #28810 from smarterclayton/keep_proto_name
Automatic merge from submit-queue

Allow proto tag to define field name

When we introduce a new field for backwards compatibility, we may want
to specify a different protobuf field name (one that matches JSON) than
the automatic transformation applied to the struct field. This allows an
API field to define the name of its protobuf tag.

@wojtek-t hit this while adding protobuf to OpenShift - we have fields we
keep for backward compatibility that need to be assigned a field by name.
Has no impact on existing (already tagged) fields.
2016-07-15 03:17:33 -07:00
Clayton Coleman 8c17b48824
Generate gogo stringer instead of proto stringer
Similar to %#v.
2016-07-14 12:43:33 -04:00
k8s-merge-robot bea382c124 Merge pull request #28932 from smarterclayton/fix_protobuf_error
Automatic merge from submit-queue

Fail correctly in go-to-protobuf

We need to return earlier.

@wojtek-t
2016-07-14 09:09:42 -07:00
Clayton Coleman 0d26c2efd4
Unable to have optional message slice
When making a message slice optional, we need to handle one more
conditional case in the rewriter.
2016-07-13 23:10:44 -04:00
Clayton Coleman c55f47c4c9
Fail correctly in go-to-protobuf
We need to return earlier.
2016-07-13 23:02:45 -04:00
Clayton Coleman f5975afc06
genconversion=false should skip fields during conversion generation
Currently it only skips if the fields don't match, but that leaves no
way for callers to say "no really, ignore this field".
2016-07-13 22:20:40 -04:00
k8s-merge-robot 6b6141f812 Merge pull request #28820 from caesarxuchao/patch-subresource
Automatic merge from submit-queue

[client-gen] Allow passing subresources in Patch method

Expand the Patch() method from:
```
Patch(name string, pt api.PatchType, data []byte)
```
to
```
Patch(name string, pt api.PatchType, data []byte, subresources ...string)
```

Continue on #27293. Fixes #26580.

cc @Random-Liu @lavalamp
2016-07-13 16:09:01 -07:00
Wojciech Tyczynski 16bf8c4008 Unify logging in generators and avoid annoying logs. 2016-07-13 15:06:44 +02:00
Tim Hockin 9dd337d119 s/deep_copy/deepcopy/
Just a naming nit that was too hard to fixup-and-rebase.
2016-07-12 21:52:54 -07:00
Tim Hockin 58441e8775 Don't check in generated deep-copy code
This mostly takes the previously checked in files and removes them, and moves
the generation to be on-demand instead of manual.  Manually verified no change
in generated output.
2016-07-12 21:52:54 -07:00
k8s-merge-robot 708e753c72 Merge pull request #28679 from sttts/sttts-deepcopy-pointer-in
Automatic merge from submit-queue

Deepcopy: avoid struct copies and reflection Call

- make signature of generated deepcopy methods symmetric with `in *type, out *type`, avoiding copies of big structs on the stack
- switch to `in interface{}, out interface{}` which allows us to call them with without `reflect.Call`

The first change reduces runtime of BenchmarkPodCopy-4 from `> 3500ns` to around `2300ns`.

The second change reduces runtime to around `1900ns`.
2016-07-12 21:45:43 -07:00
Chao Xu c2fb39102b generated changes 2016-07-12 11:09:28 -07:00
Chao Xu dc2e12d2f8 manual changes to patch subresource 2016-07-12 11:09:27 -07:00
Dr. Stefan Schimanski 61cde63622 Switch to typeless generated deepcopy functions for less reflection 2016-07-12 18:05:43 +02:00
Dr. Stefan Schimanski 6049623a13 Turn first deepcopy parameter into a pointer 2016-07-12 18:05:43 +02:00
Clayton Coleman 68bfba29b9
Allow proto tag to define field name
When we introduce a new field for backwards compatibility, we may want
to specify a different protobuf field name (one that matches JSON) than
the automatic transformation applied to the struct field. This allows an
API field to define the name of its protobuf tag.
2016-07-11 22:14:20 -04:00
Clayton Coleman 29046db6ff
Name check for go-to-protobuf in wrong spot 2016-07-08 11:31:39 -04:00
Tim Hockin 355794c303 Log errors or fail if conversion fail to generate
This fixes PodSpec to generate cleanly.  No other types only half-generate (so
now we Fatalf), though several fail to generate at all (only Errorf for now).
2016-07-07 22:09:08 -07:00
Tim Hockin f63f168b51 Comment and simplify a bit of conversion
There are ample opportunities to optimize and streamline here.  For example,
there's no reason to have a function to convert IntStr to IntStr. Removing the
function does generate the right assignment, but it is unclear whether the
registered function is needed or not.  I opted to leave it alone for now.
Another example is Convert_Slice_byte_To_Slice_byte, which just seems silly.
2016-07-07 22:09:08 -07:00
Tim Hockin 291b51ec50 Use file tags to generate conversions
This drives conversion generation from file tags like:
  // +conversion-gen=k8s.io/my/internal/version
.. rather than hardcoded lists of packages.

The only net change in generated code can be explained as correct.  Previously
it didn't know that conversion was available.
2016-07-07 22:09:08 -07:00
Tim Hockin 80490e0a55 go2idl: Allow generators to AddDir() at runtime
This is used subsequently to simplify the conversion generation, so each
package can declare what peer-packages it uses, and have those imported
dynamically, rather than having one mega list of packages to import and not
really being clear why, for any given list item.
2016-07-07 22:09:08 -07:00
Tim Hockin 7fa1e87d66 Simplify convertible check - same type is OK
This is to clarify the code.  No actual effect at the moment, but I manually
verified this in the case of identical types.
2016-07-07 22:09:08 -07:00
Tim Hockin ed59210f04 Renames for clarity in conversion-gen
This is to clarify the intent of the code for new readers (me).
2016-07-07 22:09:08 -07:00
Tim Hockin ab16ccc158 go2idl: don't mutate a map being iterated
This was causing us to process packages we didn't really want, which was only
visible when debugging was enabled.
2016-07-07 22:09:08 -07:00
Tim Hockin 96c0284e91 go2idl: clarify comments wrt get-or-create
This is just comment clarity.
2016-07-07 22:09:08 -07:00
Tim Hockin 82b2d2c87b Clarify copyable vs in-bounds
This make it clearer where "is copyable" is needed and where "is in bounds" is
needed.  No effect on generated code.
2016-07-07 16:49:46 -07:00
Tim Hockin 1ba6f5df9e go2idl: Allow ... pkg specs
This is closer to standard Go semantics and obsoletes our custom --recursive
flag.
2016-07-07 16:49:46 -07:00
Tim Hockin dc10f10e48 Recreate the opt-in/opt-out logic for deepcopy
This is the last piece of Clayton's #26179 to be implemented with file tags.
All diffs are accounted for.  Followup will use this to streamline some
packages.

Also add some V(5) debugging - it was helpful in diagnosing various issues, it
may be helpful again.
2016-07-07 16:49:46 -07:00
Tim Hockin 28af54138d Use file tags to generate deep-copies
This drives most of the logic of deep-copy generation from tags like:
  // +deepcopy-gen=package
..rather than hardcoded lists of packages.  This will make it possible to
subsequently generate code ONLY for packages that need it *right now*, rather
than all of them always.

Also remove pkgs that really do not need deep-copies (no symbols used
anywhere).
2016-07-07 16:49:46 -07:00
Tim Hockin 4c4c6fc40e go2idl: Add an 'output basename' option
This will be used when generated files are no longer checked in.  I include it
as a standalone commit for ease of review.
2016-07-07 16:49:46 -07:00
Tim Hockin ec79eee289 go2idl: remove comma-processing for comment-tags
It's simpler and clearer without them, and it leaves room for per-use-case
parsing of the tag lines.  If anything we should be splitting on whitespace.
2016-07-07 16:49:46 -07:00
Tim Hockin 052847f4ed go2idl: Track doc.go file-comments
Previously we just tracked comments on the 'package' declaration.  Treat all
file comments as one comment-block, for simplicity.  Can be revisited if
needed.
2016-07-07 16:49:46 -07:00
Tim Hockin 4a00a0fd6d go2idl: Allow multiple values for a comment-tag
This means that tags like:
  // +foo=bar
  // +foo=bat
..will produce []string{"bar", "bat"}.  This is needed for later commits which
will want to use this to make code generation more self contained.
2016-07-07 16:49:46 -07:00
Tim Hockin b01ac4726f go2idl: Consistently handle comments as []string
This makes subsequent comment-tag PRs more consistent.
2016-07-07 16:49:46 -07:00
Tim Hockin 57c3196914 Add support for manually defined DeepCopy methods
In bringing back Clayton's PR piece-by-piece this was almost as easy to
implement as his version, and is much more like what I think we should be
doing.

Specifically, any time which defines a .DeepCopy() method will have that method
called preferentially.  Otherwise we generate our own functions for
deep-copying.  This affected exactly one type - resource.Quantity.  In applying
this heuristic, several places in the generated code were simplified.

To achieve this I had to convert types.Type.Methods from a slice to a map,
which seems correct anyway (to do by-name lookups).
2016-07-07 16:49:46 -07:00
Tim Hockin be481060ea Re-add constraints to deep-copy
This re-institutes some of the rolled-back logic from previous commits. It
bounds the scope of what the deepcopy generator is willing to do with regards
to generating and calling generated functions.
2016-07-07 16:49:46 -07:00
Tim Hockin e18b2f3a2e Revert Clayton's #26179 so I can recreate it
His PR cam during the middle of this development cycle, and it was easier to
burn it down and recreate it than try to patch it into an existing series and
re-test every assumption.  This behavior will be re-introduced in subsequent
commits.
2016-07-07 16:49:46 -07:00
k8s-merge-robot 4da14c8a64 Merge pull request #28204 from thockin/cleanup-third_party
Automatic merge from submit-queue

Cleanup third party (pt 2)

Move forked-and-hacked golang code to the forked/ directory.  Remove ast/build/parse code that is now in stdlib.  Remove unused shell2junit
2016-07-07 12:13:14 -07:00