Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2bbe72d4
Commit
2bbe72d4
authored
Jul 06, 2017
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deepcopy: misc fixes for static deepcopy compilation
- port direct calls to deepcopy funcs - apimachinery: fix types in unstructured converter test - federation: fix deepcopy registration
parent
39d95b9b
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
69 deletions
+18
-69
eventsink.go
...ion/pkg/federation-controller/util/eventsink/eventsink.go
+4
-1
crd_finalizer.go
...sions-apiserver/pkg/controller/finalizer/crd_finalizer.go
+3
-16
naming_controller.go
...ions-apiserver/pkg/controller/status/naming_controller.go
+1
-5
converter_test.go
...pimachinery/pkg/conversion/unstructured/converter_test.go
+6
-26
webhook.go
.../src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go
+1
-7
autoregister_controller.go
...r/pkg/controllers/autoregister/autoregister_controller.go
+2
-10
available_controller.go
...aggregator/pkg/controllers/status/available_controller.go
+1
-4
No files found.
federation/pkg/federation-controller/util/eventsink/eventsink.go
View file @
2bbe72d4
...
@@ -61,7 +61,10 @@ func init() {
...
@@ -61,7 +61,10 @@ func init() {
}
}
if
err
:=
scheme
.
AddGeneratedDeepCopyFuncs
(
if
err
:=
scheme
.
AddGeneratedDeepCopyFuncs
(
conversion
.
GeneratedDeepCopyFunc
{
conversion
.
GeneratedDeepCopyFunc
{
Fn
:
metav1
.
DeepCopy_v1_Time
,
Fn
:
func
(
in
,
out
interface
{},
c
*
conversion
.
Cloner
)
error
{
in
.
(
*
metav1
.
Time
)
.
DeepCopyInto
(
out
.
(
*
metav1
.
Time
))
return
nil
},
InType
:
reflect
.
TypeOf
(
&
metav1
.
Time
{}),
InType
:
reflect
.
TypeOf
(
&
metav1
.
Time
{}),
},
},
);
err
!=
nil
{
);
err
!=
nil
{
...
...
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/finalizer/crd_finalizer.go
View file @
2bbe72d4
...
@@ -109,10 +109,7 @@ func (c *CRDFinalizer) sync(key string) error {
...
@@ -109,10 +109,7 @@ func (c *CRDFinalizer) sync(key string) error {
return
nil
return
nil
}
}
crd
:=
&
apiextensions
.
CustomResourceDefinition
{}
crd
:=
cachedCRD
.
DeepCopy
()
if
err
:=
apiextensions
.
DeepCopy_apiextensions_CustomResourceDefinition
(
cachedCRD
,
crd
,
cloner
);
err
!=
nil
{
return
err
}
// update the status condition. This cleanup could take a while.
// update the status condition. This cleanup could take a while.
apiextensions
.
SetCRDCondition
(
crd
,
apiextensions
.
CustomResourceDefinitionCondition
{
apiextensions
.
SetCRDCondition
(
crd
,
apiextensions
.
CustomResourceDefinitionCondition
{
...
@@ -320,18 +317,8 @@ func (c *CRDFinalizer) updateCustomResourceDefinition(oldObj, newObj interface{}
...
@@ -320,18 +317,8 @@ func (c *CRDFinalizer) updateCustomResourceDefinition(oldObj, newObj interface{}
// is likely to be the originator, so requeuing would hot-loop us. Failures are requeued by the workqueue directly.
// is likely to be the originator, so requeuing would hot-loop us. Failures are requeued by the workqueue directly.
// This is a low traffic and scale resource, so the copy is terrible. It's not good, so better ideas
// This is a low traffic and scale resource, so the copy is terrible. It's not good, so better ideas
// are welcome.
// are welcome.
oldCopy
:=
&
apiextensions
.
CustomResourceDefinition
{}
oldCopy
:=
oldCRD
.
DeepCopy
()
if
err
:=
apiextensions
.
DeepCopy_apiextensions_CustomResourceDefinition
(
oldCRD
,
oldCopy
,
cloner
);
err
!=
nil
{
newCopy
:=
newCRD
.
DeepCopy
()
utilruntime
.
HandleError
(
err
)
c
.
enqueue
(
newCRD
)
return
}
newCopy
:=
&
apiextensions
.
CustomResourceDefinition
{}
if
err
:=
apiextensions
.
DeepCopy_apiextensions_CustomResourceDefinition
(
newCRD
,
newCopy
,
cloner
);
err
!=
nil
{
utilruntime
.
HandleError
(
err
)
c
.
enqueue
(
newCRD
)
return
}
oldCopy
.
ResourceVersion
=
""
oldCopy
.
ResourceVersion
=
""
newCopy
.
ResourceVersion
=
""
newCopy
.
ResourceVersion
=
""
apiextensions
.
RemoveCRDCondition
(
oldCopy
,
apiextensions
.
Terminating
)
apiextensions
.
RemoveCRDCondition
(
oldCopy
,
apiextensions
.
Terminating
)
...
...
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller.go
View file @
2bbe72d4
...
@@ -251,11 +251,7 @@ func (c *NamingConditionController) sync(key string) error {
...
@@ -251,11 +251,7 @@ func (c *NamingConditionController) sync(key string) error {
return
nil
return
nil
}
}
crd
:=
&
apiextensions
.
CustomResourceDefinition
{}
crd
:=
inCustomResourceDefinition
.
DeepCopy
()
if
err
:=
apiextensions
.
DeepCopy_apiextensions_CustomResourceDefinition
(
inCustomResourceDefinition
,
crd
,
cloner
);
err
!=
nil
{
return
err
}
crd
.
Status
.
AcceptedNames
=
acceptedNames
crd
.
Status
.
AcceptedNames
=
acceptedNames
apiextensions
.
SetCRDCondition
(
crd
,
namingCondition
)
apiextensions
.
SetCRDCondition
(
crd
,
namingCondition
)
apiextensions
.
SetCRDCondition
(
crd
,
establishedCondition
)
apiextensions
.
SetCRDCondition
(
crd
,
establishedCondition
)
...
...
staging/src/k8s.io/apimachinery/pkg/conversion/unstructured/converter_test.go
View file @
2bbe72d4
...
@@ -21,8 +21,6 @@ import (
...
@@ -21,8 +21,6 @@ import (
"reflect"
"reflect"
"testing"
"testing"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/apimachinery/pkg/util/json"
)
)
...
@@ -73,25 +71,7 @@ type F struct {
...
@@ -73,25 +71,7 @@ type F struct {
I
[]
float32
`json:"fi"`
I
[]
float32
`json:"fi"`
}
}
// Implement runtime.Object to make types usable for tests.
func
doRoundTrip
(
t
*
testing
.
T
,
item
interface
{})
{
func
(
c
*
C
)
GetObjectKind
()
schema
.
ObjectKind
{
return
schema
.
EmptyObjectKind
}
func
(
d
*
D
)
GetObjectKind
()
schema
.
ObjectKind
{
return
schema
.
EmptyObjectKind
}
func
(
e
*
E
)
GetObjectKind
()
schema
.
ObjectKind
{
return
schema
.
EmptyObjectKind
}
func
(
f
*
F
)
GetObjectKind
()
schema
.
ObjectKind
{
return
schema
.
EmptyObjectKind
}
func
doRoundTrip
(
t
*
testing
.
T
,
item
runtime
.
Object
)
{
data
,
err
:=
json
.
Marshal
(
item
)
data
,
err
:=
json
.
Marshal
(
item
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Error when marshaling object: %v"
,
err
)
t
.
Errorf
(
"Error when marshaling object: %v"
,
err
)
...
@@ -127,7 +107,7 @@ func doRoundTrip(t *testing.T, item runtime.Object) {
...
@@ -127,7 +107,7 @@ func doRoundTrip(t *testing.T, item runtime.Object) {
return
return
}
}
newObj
:=
reflect
.
New
(
reflect
.
TypeOf
(
item
)
.
Elem
())
.
Interface
()
.
(
runtime
.
Object
)
newObj
:=
reflect
.
New
(
reflect
.
TypeOf
(
item
)
.
Elem
())
.
Interface
()
err
=
DefaultConverter
.
FromUnstructured
(
newUnstr
,
newObj
)
err
=
DefaultConverter
.
FromUnstructured
(
newUnstr
,
newObj
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"FromUnstructured failed: %v"
,
err
)
t
.
Errorf
(
"FromUnstructured failed: %v"
,
err
)
...
@@ -142,7 +122,7 @@ func doRoundTrip(t *testing.T, item runtime.Object) {
...
@@ -142,7 +122,7 @@ func doRoundTrip(t *testing.T, item runtime.Object) {
func
TestRoundTrip
(
t
*
testing
.
T
)
{
func
TestRoundTrip
(
t
*
testing
.
T
)
{
intVal
:=
int64
(
42
)
intVal
:=
int64
(
42
)
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
obj
runtime
.
Object
obj
interface
{}
}{
}{
{
{
// This (among others) tests nil map, slice and pointer.
// This (among others) tests nil map, slice and pointer.
...
@@ -223,7 +203,7 @@ func TestRoundTrip(t *testing.T) {
...
@@ -223,7 +203,7 @@ func TestRoundTrip(t *testing.T) {
// 1) serialized json -> object
// 1) serialized json -> object
// 2) serialized json -> map[string]interface{} -> object
// 2) serialized json -> map[string]interface{} -> object
// produces the same object.
// produces the same object.
func
doUnrecognized
(
t
*
testing
.
T
,
jsonData
string
,
item
runtime
.
Object
,
expectedErr
error
)
{
func
doUnrecognized
(
t
*
testing
.
T
,
jsonData
string
,
item
interface
{}
,
expectedErr
error
)
{
unmarshalledObj
:=
reflect
.
New
(
reflect
.
TypeOf
(
item
)
.
Elem
())
.
Interface
()
unmarshalledObj
:=
reflect
.
New
(
reflect
.
TypeOf
(
item
)
.
Elem
())
.
Interface
()
err
:=
json
.
Unmarshal
([]
byte
(
jsonData
),
&
unmarshalledObj
)
err
:=
json
.
Unmarshal
([]
byte
(
jsonData
),
&
unmarshalledObj
)
if
(
err
!=
nil
)
!=
(
expectedErr
!=
nil
)
{
if
(
err
!=
nil
)
!=
(
expectedErr
!=
nil
)
{
...
@@ -237,7 +217,7 @@ func doUnrecognized(t *testing.T, jsonData string, item runtime.Object, expected
...
@@ -237,7 +217,7 @@ func doUnrecognized(t *testing.T, jsonData string, item runtime.Object, expected
t
.
Errorf
(
"Error when unmarshaling to unstructured: %v"
,
err
)
t
.
Errorf
(
"Error when unmarshaling to unstructured: %v"
,
err
)
return
return
}
}
newObj
:=
reflect
.
New
(
reflect
.
TypeOf
(
item
)
.
Elem
())
.
Interface
()
.
(
runtime
.
Object
)
newObj
:=
reflect
.
New
(
reflect
.
TypeOf
(
item
)
.
Elem
())
.
Interface
()
err
=
DefaultConverter
.
FromUnstructured
(
unstr
,
newObj
)
err
=
DefaultConverter
.
FromUnstructured
(
unstr
,
newObj
)
if
(
err
!=
nil
)
!=
(
expectedErr
!=
nil
)
{
if
(
err
!=
nil
)
!=
(
expectedErr
!=
nil
)
{
t
.
Errorf
(
"Unexpected error in FromUnstructured: %v, expected: %v"
,
err
,
expectedErr
)
t
.
Errorf
(
"Unexpected error in FromUnstructured: %v, expected: %v"
,
err
,
expectedErr
)
...
@@ -251,7 +231,7 @@ func doUnrecognized(t *testing.T, jsonData string, item runtime.Object, expected
...
@@ -251,7 +231,7 @@ func doUnrecognized(t *testing.T, jsonData string, item runtime.Object, expected
func
TestUnrecognized
(
t
*
testing
.
T
)
{
func
TestUnrecognized
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
data
string
data
string
obj
runtime
.
Object
obj
interface
{}
err
error
err
error
}{
}{
{
{
...
...
staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go
View file @
2bbe72d4
...
@@ -22,8 +22,6 @@ import (
...
@@ -22,8 +22,6 @@ import (
"strings"
"strings"
"time"
"time"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/registered"
"k8s.io/apimachinery/pkg/apimachinery/registered"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -260,11 +258,7 @@ func (b *batchBackend) ProcessEvents(ev ...*auditinternal.Event) {
...
@@ -260,11 +258,7 @@ func (b *batchBackend) ProcessEvents(ev ...*auditinternal.Event) {
for
i
,
e
:=
range
ev
{
for
i
,
e
:=
range
ev
{
// Per the audit.Backend interface these events are reused after being
// Per the audit.Backend interface these events are reused after being
// sent to the Sink. Deep copy and send the copy to the queue.
// sent to the Sink. Deep copy and send the copy to the queue.
event
:=
new
(
auditinternal
.
Event
)
event
:=
e
.
DeepCopy
()
if
err
:=
auditinternal
.
DeepCopy_audit_Event
(
e
,
event
,
b
.
cloner
);
err
!=
nil
{
glog
.
Errorf
(
"failed to clone audit event: %v: %#v"
,
err
,
e
)
return
}
select
{
select
{
case
b
.
buffer
<-
event
:
case
b
.
buffer
<-
event
:
...
...
staging/src/k8s.io/kube-aggregator/pkg/controllers/autoregister/autoregister_controller.go
View file @
2bbe72d4
...
@@ -206,10 +206,7 @@ func (c *autoRegisterController) checkAPIService(name string) error {
...
@@ -206,10 +206,7 @@ func (c *autoRegisterController) checkAPIService(name string) error {
}
}
// we have an entry and we have a desired, now we deconflict. Only a few fields matter.
// we have an entry and we have a desired, now we deconflict. Only a few fields matter.
apiService
:=
&
apiregistration
.
APIService
{}
apiService
:=
curr
.
DeepCopy
()
if
err
:=
apiregistration
.
DeepCopy_apiregistration_APIService
(
curr
,
apiService
,
cloner
);
err
!=
nil
{
return
err
}
apiService
.
Spec
=
desired
.
Spec
apiService
.
Spec
=
desired
.
Spec
_
,
err
=
c
.
apiServiceClient
.
APIServices
()
.
Update
(
apiService
)
_
,
err
=
c
.
apiServiceClient
.
APIServices
()
.
Update
(
apiService
)
return
err
return
err
...
@@ -226,12 +223,7 @@ func (c *autoRegisterController) AddAPIServiceToSync(in *apiregistration.APIServ
...
@@ -226,12 +223,7 @@ func (c *autoRegisterController) AddAPIServiceToSync(in *apiregistration.APIServ
c
.
apiServicesToSyncLock
.
Lock
()
c
.
apiServicesToSyncLock
.
Lock
()
defer
c
.
apiServicesToSyncLock
.
Unlock
()
defer
c
.
apiServicesToSyncLock
.
Unlock
()
apiService
:=
&
apiregistration
.
APIService
{}
apiService
:=
in
.
DeepCopy
()
if
err
:=
apiregistration
.
DeepCopy_apiregistration_APIService
(
in
,
apiService
,
cloner
);
err
!=
nil
{
// this shouldn't happen
utilruntime
.
HandleError
(
err
)
return
}
if
apiService
.
Labels
==
nil
{
if
apiService
.
Labels
==
nil
{
apiService
.
Labels
=
map
[
string
]
string
{}
apiService
.
Labels
=
map
[
string
]
string
{}
}
}
...
...
staging/src/k8s.io/kube-aggregator/pkg/controllers/status/available_controller.go
View file @
2bbe72d4
...
@@ -113,10 +113,7 @@ func (c *AvailableConditionController) sync(key string) error {
...
@@ -113,10 +113,7 @@ func (c *AvailableConditionController) sync(key string) error {
return
err
return
err
}
}
apiService
:=
&
apiregistration
.
APIService
{}
apiService
:=
inAPIService
.
DeepCopy
()
if
err
:=
apiregistration
.
DeepCopy_apiregistration_APIService
(
inAPIService
,
apiService
,
cloner
);
err
!=
nil
{
return
err
}
availableCondition
:=
apiregistration
.
APIServiceCondition
{
availableCondition
:=
apiregistration
.
APIServiceCondition
{
Type
:
apiregistration
.
Available
,
Type
:
apiregistration
.
Available
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment