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
Hide 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() {
}
if
err
:=
scheme
.
AddGeneratedDeepCopyFuncs
(
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
{}),
},
);
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 {
return
nil
}
crd
:=
&
apiextensions
.
CustomResourceDefinition
{}
if
err
:=
apiextensions
.
DeepCopy_apiextensions_CustomResourceDefinition
(
cachedCRD
,
crd
,
cloner
);
err
!=
nil
{
return
err
}
crd
:=
cachedCRD
.
DeepCopy
()
// update the status condition. This cleanup could take a while.
apiextensions
.
SetCRDCondition
(
crd
,
apiextensions
.
CustomResourceDefinitionCondition
{
...
...
@@ -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.
// This is a low traffic and scale resource, so the copy is terrible. It's not good, so better ideas
// are welcome.
oldCopy
:=
&
apiextensions
.
CustomResourceDefinition
{}
if
err
:=
apiextensions
.
DeepCopy_apiextensions_CustomResourceDefinition
(
oldCRD
,
oldCopy
,
cloner
);
err
!=
nil
{
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
:=
oldCRD
.
DeepCopy
()
newCopy
:=
newCRD
.
DeepCopy
()
oldCopy
.
ResourceVersion
=
""
newCopy
.
ResourceVersion
=
""
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 {
return
nil
}
crd
:=
&
apiextensions
.
CustomResourceDefinition
{}
if
err
:=
apiextensions
.
DeepCopy_apiextensions_CustomResourceDefinition
(
inCustomResourceDefinition
,
crd
,
cloner
);
err
!=
nil
{
return
err
}
crd
:=
inCustomResourceDefinition
.
DeepCopy
()
crd
.
Status
.
AcceptedNames
=
acceptedNames
apiextensions
.
SetCRDCondition
(
crd
,
namingCondition
)
apiextensions
.
SetCRDCondition
(
crd
,
establishedCondition
)
...
...
staging/src/k8s.io/apimachinery/pkg/conversion/unstructured/converter_test.go
View file @
2bbe72d4
...
...
@@ -21,8 +21,6 @@ import (
"reflect"
"testing"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/json"
)
...
...
@@ -73,25 +71,7 @@ type F struct {
I
[]
float32
`json:"fi"`
}
// Implement runtime.Object to make types usable for tests.
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
)
{
func
doRoundTrip
(
t
*
testing
.
T
,
item
interface
{})
{
data
,
err
:=
json
.
Marshal
(
item
)
if
err
!=
nil
{
t
.
Errorf
(
"Error when marshaling object: %v"
,
err
)
...
...
@@ -127,7 +107,7 @@ func doRoundTrip(t *testing.T, item runtime.Object) {
return
}
newObj
:=
reflect
.
New
(
reflect
.
TypeOf
(
item
)
.
Elem
())
.
Interface
()
.
(
runtime
.
Object
)
newObj
:=
reflect
.
New
(
reflect
.
TypeOf
(
item
)
.
Elem
())
.
Interface
()
err
=
DefaultConverter
.
FromUnstructured
(
newUnstr
,
newObj
)
if
err
!=
nil
{
t
.
Errorf
(
"FromUnstructured failed: %v"
,
err
)
...
...
@@ -142,7 +122,7 @@ func doRoundTrip(t *testing.T, item runtime.Object) {
func
TestRoundTrip
(
t
*
testing
.
T
)
{
intVal
:=
int64
(
42
)
testCases
:=
[]
struct
{
obj
runtime
.
Object
obj
interface
{}
}{
{
// This (among others) tests nil map, slice and pointer.
...
...
@@ -223,7 +203,7 @@ func TestRoundTrip(t *testing.T) {
// 1) serialized json -> object
// 2) serialized json -> map[string]interface{} -> 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
()
err
:=
json
.
Unmarshal
([]
byte
(
jsonData
),
&
unmarshalledObj
)
if
(
err
!=
nil
)
!=
(
expectedErr
!=
nil
)
{
...
...
@@ -237,7 +217,7 @@ func doUnrecognized(t *testing.T, jsonData string, item runtime.Object, expected
t
.
Errorf
(
"Error when unmarshaling to unstructured: %v"
,
err
)
return
}
newObj
:=
reflect
.
New
(
reflect
.
TypeOf
(
item
)
.
Elem
())
.
Interface
()
.
(
runtime
.
Object
)
newObj
:=
reflect
.
New
(
reflect
.
TypeOf
(
item
)
.
Elem
())
.
Interface
()
err
=
DefaultConverter
.
FromUnstructured
(
unstr
,
newObj
)
if
(
err
!=
nil
)
!=
(
expectedErr
!=
nil
)
{
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
func
TestUnrecognized
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
data
string
obj
runtime
.
Object
obj
interface
{}
err
error
}{
{
...
...
staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go
View file @
2bbe72d4
...
...
@@ -22,8 +22,6 @@ import (
"strings"
"time"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/registered"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -260,11 +258,7 @@ func (b *batchBackend) ProcessEvents(ev ...*auditinternal.Event) {
for
i
,
e
:=
range
ev
{
// Per the audit.Backend interface these events are reused after being
// sent to the Sink. Deep copy and send the copy to the queue.
event
:=
new
(
auditinternal
.
Event
)
if
err
:=
auditinternal
.
DeepCopy_audit_Event
(
e
,
event
,
b
.
cloner
);
err
!=
nil
{
glog
.
Errorf
(
"failed to clone audit event: %v: %#v"
,
err
,
e
)
return
}
event
:=
e
.
DeepCopy
()
select
{
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 {
}
// we have an entry and we have a desired, now we deconflict. Only a few fields matter.
apiService
:=
&
apiregistration
.
APIService
{}
if
err
:=
apiregistration
.
DeepCopy_apiregistration_APIService
(
curr
,
apiService
,
cloner
);
err
!=
nil
{
return
err
}
apiService
:=
curr
.
DeepCopy
()
apiService
.
Spec
=
desired
.
Spec
_
,
err
=
c
.
apiServiceClient
.
APIServices
()
.
Update
(
apiService
)
return
err
...
...
@@ -226,12 +223,7 @@ func (c *autoRegisterController) AddAPIServiceToSync(in *apiregistration.APIServ
c
.
apiServicesToSyncLock
.
Lock
()
defer
c
.
apiServicesToSyncLock
.
Unlock
()
apiService
:=
&
apiregistration
.
APIService
{}
if
err
:=
apiregistration
.
DeepCopy_apiregistration_APIService
(
in
,
apiService
,
cloner
);
err
!=
nil
{
// this shouldn't happen
utilruntime
.
HandleError
(
err
)
return
}
apiService
:=
in
.
DeepCopy
()
if
apiService
.
Labels
==
nil
{
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 {
return
err
}
apiService
:=
&
apiregistration
.
APIService
{}
if
err
:=
apiregistration
.
DeepCopy_apiregistration_APIService
(
inAPIService
,
apiService
,
cloner
);
err
!=
nil
{
return
err
}
apiService
:=
inAPIService
.
DeepCopy
()
availableCondition
:=
apiregistration
.
APIServiceCondition
{
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