Commit Graph

43 Commits (940519993a5776abcfa229e4df1216e90df3c155)

Author SHA1 Message Date
Clayton Coleman 68a9983ec7
Add a new Default() method on Scheme
Allow defaulter functions to be registered with the scheme.
2016-10-18 21:07:32 -04:00
Clayton Coleman 12a5eeea17
Introduce GroupVersioner for capturing desired target version
Convert single GV and lists of GVs into an interface that can handle
more complex scenarios (everything internal, nothing supported). Pass
the interface down into conversion.
2016-08-18 14:45:00 -04:00
David McMahon ef0c9f0c5b Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
Clayton Coleman bffbc112f0
Remove src and dest version - they are not used (now)
We will probably readd these as an opaque object passed down to
conversions that lets the caller get access to more info (like
a negotiated serializer).
2016-05-12 10:10:35 -04:00
Clayton Coleman 236925be87
Avoid allocations and a reflect.Call in conversion
reflect.Call is fairly expensive, performing 8 allocations and having to
set up a call stack. Using a fairly straightforward to generate switch
statement, we can bypass that early in conversion (as long as the
function takes responsibility for invocation). We may also be able to
avoid an allocation for the conversion scope, but not positive yet.

```
benchmark                    old ns/op     new ns/op     delta
BenchmarkPodConversion-8     14713         12173         -17.26%

benchmark                    old allocs     new allocs     delta
BenchmarkPodConversion-8     80             72             -10.00%

benchmark                    old bytes     new bytes     delta
BenchmarkPodConversion-8     9133          8712          -4.61%
```
2016-04-26 16:42:12 -04:00
Clayton Coleman 2f59744d53 Default conversion for byte slices is incorrect
Nil slices are getting allocated, which is incorrect and changes
behavior in some cases.

   []byte(nil) -> []byte(nil)
2016-04-17 21:20:50 -04:00
Wojciech Tyczynski 49d3c3962c Small improvements in conversion generator 2016-04-05 02:10:23 +02:00
Clayton Coleman 60b66665e1 Move conversion.Scheme to runtime
There is only one type registry to rule them all
2016-01-30 14:12:40 -05:00
Clayton Coleman 6582b4c2ea Remove codec awareness from conversion
Allow convertors to be specialized, some cleanup to how conversion
functions are stored internally to allow better reuse.
2016-01-21 23:18:32 -05:00
Clayton Coleman 3c1451af91 Use public conversion methods to avoid reflection
Replace many of the remaining s.Convert() invocations with direct
execution, and make generated methods public. Removes 10% of the
allocations during decode of a pod and ~20-40% of the total CPU time.
2015-12-29 10:38:42 -05:00
feihujiang eac8d6a997 Cleanup the content of deprecated V1beta1 2015-11-06 13:42:51 +08:00
Clayton Coleman a02bcefa10 Allow []string to be converted to *int64
Not something we hit before
2015-09-21 12:02:03 -04:00
Kris Rousey 565189f5b8 Correcting all go vet errors 2015-08-11 13:55:37 -07:00
Veres Lajos 9f77e49109 typofix - https://github.com/vlajos/misspell_fixer 2015-08-08 22:31:48 +01:00
Rodolfo Carvalho b216d09a8d Fix typo 2015-06-04 11:44:10 +02:00
Wojciech Tyczynski 5173ee07e1 Chain conversion functions while generation 2015-05-07 09:27:58 +02:00
Wojciech Tyczynski d4b32a8371 Support both manual and generate conversions 2015-05-06 16:43:15 +02:00
Eric Paris 6b3a6e6b98 Make copyright ownership statement generic
Instead of saying "Google Inc." (which is not always correct) say "The
Kubernetes Authors", which is generic.
2015-05-01 17:49:56 -04:00
Daniel Smith f591873af7 Add DeepCopy! Also-- optimize conversion for []byte 2015-04-10 13:26:46 -07:00
Clayton Coleman ea32b89e5e Allow map[string][]string to be converted to an object
Will allow query parameters to be converted to versioned objects.
2015-03-24 17:25:45 -04:00
Yu-Ju Hong 4a72addaeb Factor out API defaulting from validation logic
Currently, the validation logic validates fields in an object and supply default
values wherever applies. This change factors out defaulting to a set of
defaulting callback functions for decoding (see #1502 for more discussion).

 * This change is based on pull request 2587.

 * Most defaulting has been migrated to defaults.go where the defaulting
   functions are added.

 * validation_test.go and converter_test.go have been adapted to not testing the
   default values.

 * Fixed all tests with that create invalid objects with the absence of
   defaulting logic.
2015-02-03 00:55:42 -08:00
Tim Hockin 1ddb68d8d7 Sketch: a third take on defaulting values 2015-02-02 22:35:58 -08:00
Daniel Smith 37f5a9df07 make conversion do deep copies 2015-01-15 12:02:22 -08:00
Clayton Coleman 8f65442c2f Client should not include ns/ for non-namespaced calls in v1beta3 2015-01-08 12:44:07 -05:00
Clayton Coleman 3b5c3ec786 Merge pull request #3220 from lavalamp/deepEqual
Add *useful* DeepEqual
2015-01-07 14:24:26 -05:00
Jordan Liggitt 2da1865fc2 Make default conversion behavior available to conversion funcs 2015-01-06 13:38:57 -05:00
Daniel Smith f0b7743402 Add useful DeepEqual 2015-01-05 10:37:50 -08:00
Daniel Smith f3148e9965 Fix taking addr() of map value/key 2014-12-12 15:26:17 -08:00
Daniel Smith 3c1d51b19d refactor to hide structs behind an interface 2014-12-08 17:12:40 -08:00
Daniel Smith 564c087062 produce more readable error messages 2014-12-08 17:12:38 -08:00
Daniel Smith 77521a33d3 Add stack of previous values to converter 2014-12-08 17:12:07 -08:00
Daniel Smith f1c21c8fdf add boilerplate reduction struct field copier 2014-11-24 12:57:34 -08:00
Tim Hockin ea960711ff Clean up error logs.
Use %v for errors, tidy some messages, make error messages start lowe-case
(as per go guidelines).  Just accumulated nits.
2014-11-21 09:45:26 +08:00
Vojtech Vitek (V-Teq) 90809c270d Use conversion.EnforcePtr() where appropriate
Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>
2014-10-28 16:36:09 +01:00
Vojtech Vitek (V-Teq) 755d4d441a Fix typos 2014-10-21 18:57:20 +02:00
Clayton Coleman 338ee1e458 Add additional debugging output on mistyped conversion 2014-10-07 14:09:01 -04:00
Daniel Smith b8c955ea17 Fixes:
* Fix kubecfg test, which was writing an internal object straight to yaml
* Address review comments
2014-09-15 13:15:46 -07:00
Daniel Smith 71e547124c Make needed changes in conversion package to support pluggability 2014-09-15 13:15:46 -07:00
Daniel Smith 2ba6503511 Add continuation to conversion routines 2014-09-07 22:19:24 -07:00
Vojtech Vitek (V-Teq) 59f58cd043 Unify Godoc formatting, fix various typos
Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>
2014-09-02 13:41:03 +02:00
Paul Morie c69160059b Change CreationTimestamp to a util.Time and set in each storage implementation
Because time.Time doesn't work correctly with our YAML package, it is necessary
to introduce a type, util.Time, which serializes correctly to JSON and YAML.

Eventually we would like timestamping to cut across storage implementations;
for now, we set it in each storage.
2014-08-14 16:26:29 -04:00
Daniel Smith 1cc7fce523 Add documentation and tests to conversion. 2014-08-01 14:26:36 -07:00
Daniel Smith a73e4f4623 Separate generic parts of api library into conversion package. 2014-08-01 14:25:42 -07:00