Skip to content

Commit 0e13e5c

Browse files
authored
Merge pull request kubernetes#86382 from wojtek-t/remove_default_convert
Remove DefaultConvert functions
2 parents 84198bf + bac2e9f commit 0e13e5c

File tree

5 files changed

+2
-34
lines changed

5 files changed

+2
-34
lines changed

api/openapi-spec/swagger.json

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

staging/src/k8s.io/api/rbac/v1alpha1/generated.proto

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

staging/src/k8s.io/api/rbac/v1alpha1/types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ type PolicyRule struct {
6262
ResourceNames []string `json:"resourceNames,omitempty" protobuf:"bytes,5,rep,name=resourceNames"`
6363

6464
// NonResourceURLs is a set of partial urls that a user should have access to. *s are allowed, but only as the full, final step in the path
65-
// This name is intentionally different than the internal type so that the DefaultConvert works nicely and because the ordering may be different.
6665
// Since non-resource URLs are not namespaced, this field is only applicable for ClusterRoles referenced from a ClusterRoleBinding.
6766
// Rules can either apply to API resources (such as "pods" or "secrets") or non-resource URL paths (such as "/api"), but not both.
6867
// +optional

staging/src/k8s.io/api/rbac/v1alpha1/types_swagger_doc_generated.go

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

staging/src/k8s.io/apimachinery/pkg/conversion/converter.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ type Scope interface {
138138
// parameters, you'll run out of stack space before anything useful happens.
139139
Convert(src, dest interface{}, flags FieldMatchingFlags) error
140140

141-
// DefaultConvert performs the default conversion, without calling a conversion func
142-
// on the current stack frame. This makes it safe to call from a conversion func.
143-
DefaultConvert(src, dest interface{}, flags FieldMatchingFlags) error
144-
145141
// SrcTags and DestTags contain the struct tags that src and dest had, respectively.
146142
// If the enclosing object was not a struct, then these will contain no tags, of course.
147143
SrcTag() reflect.StructTag
@@ -274,12 +270,6 @@ func (s *scope) Convert(src, dest interface{}, flags FieldMatchingFlags) error {
274270
return s.converter.Convert(src, dest, flags, s.meta)
275271
}
276272

277-
// DefaultConvert continues a conversion, performing a default conversion (no conversion func)
278-
// for the current stack frame.
279-
func (s *scope) DefaultConvert(src, dest interface{}, flags FieldMatchingFlags) error {
280-
return s.converter.DefaultConvert(src, dest, flags, s.meta)
281-
}
282-
283273
// SrcTag returns the tag of the struct containing the current source item, if any.
284274
func (s *scope) SrcTag() reflect.StructTag {
285275
return s.srcStack.top().tag
@@ -432,18 +422,6 @@ func (c *Converter) Convert(src, dest interface{}, flags FieldMatchingFlags, met
432422
return c.doConversion(src, dest, flags, meta, c.convert)
433423
}
434424

435-
// DefaultConvert will translate src to dest if it knows how. Both must be pointers.
436-
// No conversion func is used. If the default copying mechanism
437-
// doesn't work on this type pair, an error will be returned.
438-
// Read the comments on the various FieldMatchingFlags constants to understand
439-
// what the 'flags' parameter does.
440-
// 'meta' is given to allow you to pass information to conversion functions,
441-
// it is not used by DefaultConvert() other than storing it in the scope.
442-
// Not safe for objects with cyclic references!
443-
func (c *Converter) DefaultConvert(src, dest interface{}, flags FieldMatchingFlags, meta *Meta) error {
444-
return c.doConversion(src, dest, flags, meta, c.defaultConvert)
445-
}
446-
447425
type conversionFunc func(sv, dv reflect.Value, scope *scope) error
448426

449427
func (c *Converter) doConversion(src, dest interface{}, flags FieldMatchingFlags, meta *Meta, f conversionFunc) error {
@@ -523,14 +501,6 @@ func (c *Converter) convert(sv, dv reflect.Value, scope *scope) error {
523501
return c.callUntyped(sv, dv, f, scope)
524502
}
525503

526-
return c.defaultConvert(sv, dv, scope)
527-
}
528-
529-
// defaultConvert recursively copies sv into dv. no conversion function is called
530-
// for the current stack frame (but conversion functions may be called for nested objects)
531-
func (c *Converter) defaultConvert(sv, dv reflect.Value, scope *scope) error {
532-
dt, st := dv.Type(), sv.Type()
533-
534504
if !dv.CanSet() {
535505
return scope.errorf("Cannot set dest. (Tried to deep copy something with unexported fields?)")
536506
}

0 commit comments

Comments
 (0)