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
bbb94e42
Commit
bbb94e42
authored
Apr 29, 2017
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove registry from testing/fixture.go; update client-gen to not use
registry in the generated clients
parent
ca520e34
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
56 additions
and
41 deletions
+56
-41
fake_client_generator.go
...o2idl/client-gen/generators/fake/fake_client_generator.go
+5
-6
generator_fake_for_clientset.go
...lient-gen/generators/fake/generator_fake_for_clientset.go
+2
-2
generator_fake_for_type.go
...idl/client-gen/generators/fake/generator_fake_for_type.go
+10
-4
fake_event_expansion.go
...ated/clientset/typed/core/v1/fake/fake_event_expansion.go
+2
-2
fake_event_expansion.go
...t/typed/core/internalversion/fake/fake_event_expansion.go
+2
-2
factory_object_mapping_test.go
pkg/kubectl/cmd/util/factory_object_mapping_test.go
+7
-6
actions.go
staging/src/k8s.io/client-go/testing/actions.go
+9
-2
fixture.go
staging/src/k8s.io/client-go/testing/fixture.go
+0
-0
clientset_generated.go
...clientset_generated/clientset/fake/clientset_generated.go
+2
-2
fake_nodemetrics.go
...clientset/typed/metrics/v1alpha1/fake/fake_nodemetrics.go
+3
-1
fake_podmetrics.go
.../clientset/typed/metrics/v1alpha1/fake/fake_podmetrics.go
+3
-1
fake_client.go
....io/metrics/pkg/client/custom_metrics/fake/fake_client.go
+11
-13
No files found.
cmd/libs/go2idl/client-gen/generators/fake/fake_client_generator.go
View file @
bbb94e42
...
@@ -123,12 +123,11 @@ func PackageForClientset(customArgs clientgenargs.Args, fakeClientsetPackage str
...
@@ -123,12 +123,11 @@ func PackageForClientset(customArgs clientgenargs.Args, fakeClientsetPackage str
DefaultGen
:
generator
.
DefaultGen
{
DefaultGen
:
generator
.
DefaultGen
{
OptionalName
:
"register"
,
OptionalName
:
"register"
,
},
},
InputPackages
:
customArgs
.
GroupVersionToInputPath
,
InputPackages
:
customArgs
.
GroupVersionToInputPath
,
OutputPackage
:
fakeClientsetPackage
,
OutputPackage
:
fakeClientsetPackage
,
Groups
:
customArgs
.
Groups
,
Groups
:
customArgs
.
Groups
,
ImportTracker
:
generator
.
NewImportTracker
(),
ImportTracker
:
generator
.
NewImportTracker
(),
PrivateScheme
:
true
,
PrivateScheme
:
true
,
CreateRegistry
:
true
,
// needed to know about root resources and for RESTMapper
},
},
}
}
return
generators
return
generators
...
...
cmd/libs/go2idl/client-gen/generators/fake/generator_fake_for_clientset.go
View file @
bbb94e42
...
@@ -108,7 +108,7 @@ var common = `
...
@@ -108,7 +108,7 @@ var common = `
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
// for a real clientset and is mostly useful in simple unit tests.
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
o := testing.NewObjectTracker(
registry,
scheme, codecs.UniversalDecoder())
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
for _, obj := range objects {
for _, obj := range objects {
if err := o.Add(obj); err != nil {
if err := o.Add(obj); err != nil {
panic(err)
panic(err)
...
@@ -116,7 +116,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
...
@@ -116,7 +116,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
}
}
fakePtr := testing.Fake{}
fakePtr := testing.Fake{}
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o
, registry.RESTMapper()
))
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o))
fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil))
fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil))
...
...
cmd/libs/go2idl/client-gen/generators/fake/generator_fake_for_type.go
View file @
bbb94e42
...
@@ -120,6 +120,7 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
...
@@ -120,6 +120,7 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
"GetOptions"
:
c
.
Universe
.
Type
(
types
.
Name
{
Package
:
"k8s.io/apimachinery/pkg/apis/meta/v1"
,
Name
:
"GetOptions"
}),
"GetOptions"
:
c
.
Universe
.
Type
(
types
.
Name
{
Package
:
"k8s.io/apimachinery/pkg/apis/meta/v1"
,
Name
:
"GetOptions"
}),
"Everything"
:
c
.
Universe
.
Function
(
types
.
Name
{
Package
:
"k8s.io/apimachinery/pkg/labels"
,
Name
:
"Everything"
}),
"Everything"
:
c
.
Universe
.
Function
(
types
.
Name
{
Package
:
"k8s.io/apimachinery/pkg/labels"
,
Name
:
"Everything"
}),
"GroupVersionResource"
:
c
.
Universe
.
Type
(
types
.
Name
{
Package
:
"k8s.io/apimachinery/pkg/runtime/schema"
,
Name
:
"GroupVersionResource"
}),
"GroupVersionResource"
:
c
.
Universe
.
Type
(
types
.
Name
{
Package
:
"k8s.io/apimachinery/pkg/runtime/schema"
,
Name
:
"GroupVersionResource"
}),
"GroupVersionKind"
:
c
.
Universe
.
Type
(
types
.
Name
{
Package
:
"k8s.io/apimachinery/pkg/runtime/schema"
,
Name
:
"GroupVersionKind"
}),
"PatchType"
:
c
.
Universe
.
Type
(
types
.
Name
{
Package
:
"k8s.io/apimachinery/pkg/types"
,
Name
:
"PatchType"
}),
"PatchType"
:
c
.
Universe
.
Type
(
types
.
Name
{
Package
:
"k8s.io/apimachinery/pkg/types"
,
Name
:
"PatchType"
}),
"watchInterface"
:
c
.
Universe
.
Type
(
types
.
Name
{
Package
:
"k8s.io/apimachinery/pkg/watch"
,
Name
:
"Interface"
}),
"watchInterface"
:
c
.
Universe
.
Type
(
types
.
Name
{
Package
:
"k8s.io/apimachinery/pkg/watch"
,
Name
:
"Interface"
}),
...
@@ -156,6 +157,7 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
...
@@ -156,6 +157,7 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
if
!
noMethods
{
if
!
noMethods
{
sw
.
Do
(
resource
,
m
)
sw
.
Do
(
resource
,
m
)
sw
.
Do
(
kind
,
m
)
sw
.
Do
(
createTemplate
,
m
)
sw
.
Do
(
createTemplate
,
m
)
sw
.
Do
(
updateTemplate
,
m
)
sw
.
Do
(
updateTemplate
,
m
)
// Generate the UpdateStatus method if the type has a status
// Generate the UpdateStatus method if the type has a status
...
@@ -198,11 +200,15 @@ var resource = `
...
@@ -198,11 +200,15 @@ var resource = `
var $.type|allLowercasePlural$Resource = $.GroupVersionResource|raw${Group: "$.groupName$", Version: "$.version$", Resource: "$.type|allLowercasePlural$"}
var $.type|allLowercasePlural$Resource = $.GroupVersionResource|raw${Group: "$.groupName$", Version: "$.version$", Resource: "$.type|allLowercasePlural$"}
`
`
var
kind
=
`
var $.type|allLowercasePlural$Kind = $.GroupVersionKind|raw${Group: "$.groupName$", Version: "$.version$", Kind: "$.type|public$"}
`
var
listTemplate
=
`
var
listTemplate
=
`
func (c *Fake$.type|publicPlural$) List(opts $.ListOptions|raw$) (result *$.type|raw$List, err error) {
func (c *Fake$.type|publicPlural$) List(opts $.ListOptions|raw$) (result *$.type|raw$List, err error) {
obj, err := c.Fake.
obj, err := c.Fake.
$if .namespaced$Invokes($.NewListAction|raw$($.type|allLowercasePlural$Resource, c.ns, opts), &$.type|raw$List{})
$if .namespaced$Invokes($.NewListAction|raw$($.type|allLowercasePlural$Resource,
$.type|allLowercasePlural$Kind,
c.ns, opts), &$.type|raw$List{})
$else$Invokes($.NewRootListAction|raw$($.type|allLowercasePlural$Resource, opts), &$.type|raw$List{})$end$
$else$Invokes($.NewRootListAction|raw$($.type|allLowercasePlural$Resource,
$.type|allLowercasePlural$Kind,
opts), &$.type|raw$List{})$end$
if obj == nil {
if obj == nil {
return nil, err
return nil, err
}
}
...
@@ -213,8 +219,8 @@ func (c *Fake$.type|publicPlural$) List(opts $.ListOptions|raw$) (result *$.type
...
@@ -213,8 +219,8 @@ func (c *Fake$.type|publicPlural$) List(opts $.ListOptions|raw$) (result *$.type
var
listUsingOptionsTemplate
=
`
var
listUsingOptionsTemplate
=
`
func (c *Fake$.type|publicPlural$) List(opts $.ListOptions|raw$) (result *$.type|raw$List, err error) {
func (c *Fake$.type|publicPlural$) List(opts $.ListOptions|raw$) (result *$.type|raw$List, err error) {
obj, err := c.Fake.
obj, err := c.Fake.
$if .namespaced$Invokes($.NewListAction|raw$($.type|allLowercasePlural$Resource, c.ns, opts), &$.type|raw$List{})
$if .namespaced$Invokes($.NewListAction|raw$($.type|allLowercasePlural$Resource,
$.type|allLowercasePlural$Kind,
c.ns, opts), &$.type|raw$List{})
$else$Invokes($.NewRootListAction|raw$($.type|allLowercasePlural$Resource, opts), &$.type|raw$List{})$end$
$else$Invokes($.NewRootListAction|raw$($.type|allLowercasePlural$Resource,
$.type|allLowercasePlural$Kind,
opts), &$.type|raw$List{})$end$
if obj == nil {
if obj == nil {
return nil, err
return nil, err
}
}
...
...
pkg/client/clientset_generated/clientset/typed/core/v1/fake/fake_event_expansion.go
View file @
bbb94e42
...
@@ -67,9 +67,9 @@ func (c *FakeEvents) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.
...
@@ -67,9 +67,9 @@ func (c *FakeEvents) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.
// Search returns a list of events matching the specified object.
// Search returns a list of events matching the specified object.
func
(
c
*
FakeEvents
)
Search
(
scheme
*
runtime
.
Scheme
,
objOrRef
runtime
.
Object
)
(
*
v1
.
EventList
,
error
)
{
func
(
c
*
FakeEvents
)
Search
(
scheme
*
runtime
.
Scheme
,
objOrRef
runtime
.
Object
)
(
*
v1
.
EventList
,
error
)
{
action
:=
core
.
NewRootListAction
(
eventsResource
,
metav1
.
ListOptions
{})
action
:=
core
.
NewRootListAction
(
eventsResource
,
eventsKind
,
metav1
.
ListOptions
{})
if
c
.
ns
!=
""
{
if
c
.
ns
!=
""
{
action
=
core
.
NewListAction
(
eventsResource
,
c
.
ns
,
metav1
.
ListOptions
{})
action
=
core
.
NewListAction
(
eventsResource
,
eventsKind
,
c
.
ns
,
metav1
.
ListOptions
{})
}
}
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
&
v1
.
EventList
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
&
v1
.
EventList
{})
if
obj
==
nil
{
if
obj
==
nil
{
...
...
pkg/client/clientset_generated/internalclientset/typed/core/internalversion/fake/fake_event_expansion.go
View file @
bbb94e42
...
@@ -67,9 +67,9 @@ func (c *FakeEvents) PatchWithEventNamespace(event *api.Event, data []byte) (*ap
...
@@ -67,9 +67,9 @@ func (c *FakeEvents) PatchWithEventNamespace(event *api.Event, data []byte) (*ap
// Search returns a list of events matching the specified object.
// Search returns a list of events matching the specified object.
func
(
c
*
FakeEvents
)
Search
(
scheme
*
runtime
.
Scheme
,
objOrRef
runtime
.
Object
)
(
*
api
.
EventList
,
error
)
{
func
(
c
*
FakeEvents
)
Search
(
scheme
*
runtime
.
Scheme
,
objOrRef
runtime
.
Object
)
(
*
api
.
EventList
,
error
)
{
action
:=
core
.
NewRootListAction
(
eventsResource
,
metav1
.
ListOptions
{})
action
:=
core
.
NewRootListAction
(
eventsResource
,
eventsKind
,
metav1
.
ListOptions
{})
if
c
.
ns
!=
""
{
if
c
.
ns
!=
""
{
action
=
core
.
NewListAction
(
eventsResource
,
c
.
ns
,
metav1
.
ListOptions
{})
action
=
core
.
NewListAction
(
eventsResource
,
eventsKind
,
c
.
ns
,
metav1
.
ListOptions
{})
}
}
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
&
api
.
EventList
{})
obj
,
err
:=
c
.
Fake
.
Invokes
(
action
,
&
api
.
EventList
{})
if
obj
==
nil
{
if
obj
==
nil
{
...
...
pkg/kubectl/cmd/util/factory_object_mapping_test.go
View file @
bbb94e42
...
@@ -19,6 +19,7 @@ package util
...
@@ -19,6 +19,7 @@ package util
import
(
import
(
"reflect"
"reflect"
"testing"
"testing"
"time"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
...
@@ -31,7 +32,6 @@ import (
...
@@ -31,7 +32,6 @@ import (
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
"time"
)
)
type
fakeClientAccessFactory
struct
{
type
fakeClientAccessFactory
struct
{
...
@@ -52,6 +52,7 @@ func newFakeClientAccessFactory(objs []runtime.Object) *fakeClientAccessFactory
...
@@ -52,6 +52,7 @@ func newFakeClientAccessFactory(objs []runtime.Object) *fakeClientAccessFactory
var
(
var
(
podsResource
=
schema
.
GroupVersionResource
{
Resource
:
"pods"
}
podsResource
=
schema
.
GroupVersionResource
{
Resource
:
"pods"
}
podsKind
=
schema
.
GroupVersionKind
{
Kind
:
"Pod"
}
)
)
func
TestLogsForObject
(
t
*
testing
.
T
)
{
func
TestLogsForObject
(
t
*
testing
.
T
)
{
...
@@ -82,7 +83,7 @@ func TestLogsForObject(t *testing.T) {
...
@@ -82,7 +83,7 @@ func TestLogsForObject(t *testing.T) {
},
},
pods
:
[]
runtime
.
Object
{
testPod
()},
pods
:
[]
runtime
.
Object
{
testPod
()},
actions
:
[]
testclient
.
Action
{
actions
:
[]
testclient
.
Action
{
testclient
.
NewListAction
(
podsResource
,
"test"
,
metav1
.
ListOptions
{
LabelSelector
:
"foo=bar"
}),
testclient
.
NewListAction
(
podsResource
,
podsKind
,
"test"
,
metav1
.
ListOptions
{
LabelSelector
:
"foo=bar"
}),
getLogsAction
(
"test"
,
nil
),
getLogsAction
(
"test"
,
nil
),
},
},
},
},
...
@@ -96,7 +97,7 @@ func TestLogsForObject(t *testing.T) {
...
@@ -96,7 +97,7 @@ func TestLogsForObject(t *testing.T) {
},
},
pods
:
[]
runtime
.
Object
{
testPod
()},
pods
:
[]
runtime
.
Object
{
testPod
()},
actions
:
[]
testclient
.
Action
{
actions
:
[]
testclient
.
Action
{
testclient
.
NewListAction
(
podsResource
,
"test"
,
metav1
.
ListOptions
{
LabelSelector
:
"foo=bar"
}),
testclient
.
NewListAction
(
podsResource
,
podsKind
,
"test"
,
metav1
.
ListOptions
{
LabelSelector
:
"foo=bar"
}),
getLogsAction
(
"test"
,
nil
),
getLogsAction
(
"test"
,
nil
),
},
},
},
},
...
@@ -110,7 +111,7 @@ func TestLogsForObject(t *testing.T) {
...
@@ -110,7 +111,7 @@ func TestLogsForObject(t *testing.T) {
},
},
pods
:
[]
runtime
.
Object
{
testPod
()},
pods
:
[]
runtime
.
Object
{
testPod
()},
actions
:
[]
testclient
.
Action
{
actions
:
[]
testclient
.
Action
{
testclient
.
NewListAction
(
podsResource
,
"test"
,
metav1
.
ListOptions
{
LabelSelector
:
"foo=bar"
}),
testclient
.
NewListAction
(
podsResource
,
podsKind
,
"test"
,
metav1
.
ListOptions
{
LabelSelector
:
"foo=bar"
}),
getLogsAction
(
"test"
,
nil
),
getLogsAction
(
"test"
,
nil
),
},
},
},
},
...
@@ -124,7 +125,7 @@ func TestLogsForObject(t *testing.T) {
...
@@ -124,7 +125,7 @@ func TestLogsForObject(t *testing.T) {
},
},
pods
:
[]
runtime
.
Object
{
testPod
()},
pods
:
[]
runtime
.
Object
{
testPod
()},
actions
:
[]
testclient
.
Action
{
actions
:
[]
testclient
.
Action
{
testclient
.
NewListAction
(
podsResource
,
"test"
,
metav1
.
ListOptions
{
LabelSelector
:
"foo=bar"
}),
testclient
.
NewListAction
(
podsResource
,
podsKind
,
"test"
,
metav1
.
ListOptions
{
LabelSelector
:
"foo=bar"
}),
getLogsAction
(
"test"
,
nil
),
getLogsAction
(
"test"
,
nil
),
},
},
},
},
...
@@ -138,7 +139,7 @@ func TestLogsForObject(t *testing.T) {
...
@@ -138,7 +139,7 @@ func TestLogsForObject(t *testing.T) {
},
},
pods
:
[]
runtime
.
Object
{
testPod
()},
pods
:
[]
runtime
.
Object
{
testPod
()},
actions
:
[]
testclient
.
Action
{
actions
:
[]
testclient
.
Action
{
testclient
.
NewListAction
(
podsResource
,
"test"
,
metav1
.
ListOptions
{
LabelSelector
:
"foo=bar"
}),
testclient
.
NewListAction
(
podsResource
,
podsKind
,
"test"
,
metav1
.
ListOptions
{
LabelSelector
:
"foo=bar"
}),
getLogsAction
(
"test"
,
nil
),
getLogsAction
(
"test"
,
nil
),
},
},
},
},
...
...
staging/src/k8s.io/client-go/testing/actions.go
View file @
bbb94e42
...
@@ -47,20 +47,22 @@ func NewGetAction(resource schema.GroupVersionResource, namespace, name string)
...
@@ -47,20 +47,22 @@ func NewGetAction(resource schema.GroupVersionResource, namespace, name string)
return
action
return
action
}
}
func
NewRootListAction
(
resource
schema
.
GroupVersionResource
,
opts
interface
{})
ListActionImpl
{
func
NewRootListAction
(
resource
schema
.
GroupVersionResource
,
kind
schema
.
GroupVersionKind
,
opts
interface
{})
ListActionImpl
{
action
:=
ListActionImpl
{}
action
:=
ListActionImpl
{}
action
.
Verb
=
"list"
action
.
Verb
=
"list"
action
.
Resource
=
resource
action
.
Resource
=
resource
action
.
Kind
=
kind
labelSelector
,
fieldSelector
,
_
:=
ExtractFromListOptions
(
opts
)
labelSelector
,
fieldSelector
,
_
:=
ExtractFromListOptions
(
opts
)
action
.
ListRestrictions
=
ListRestrictions
{
labelSelector
,
fieldSelector
}
action
.
ListRestrictions
=
ListRestrictions
{
labelSelector
,
fieldSelector
}
return
action
return
action
}
}
func
NewListAction
(
resource
schema
.
GroupVersionResource
,
namespace
string
,
opts
interface
{})
ListActionImpl
{
func
NewListAction
(
resource
schema
.
GroupVersionResource
,
kind
schema
.
GroupVersionKind
,
namespace
string
,
opts
interface
{})
ListActionImpl
{
action
:=
ListActionImpl
{}
action
:=
ListActionImpl
{}
action
.
Verb
=
"list"
action
.
Verb
=
"list"
action
.
Resource
=
resource
action
.
Resource
=
resource
action
.
Kind
=
kind
action
.
Namespace
=
namespace
action
.
Namespace
=
namespace
labelSelector
,
fieldSelector
,
_
:=
ExtractFromListOptions
(
opts
)
labelSelector
,
fieldSelector
,
_
:=
ExtractFromListOptions
(
opts
)
action
.
ListRestrictions
=
ListRestrictions
{
labelSelector
,
fieldSelector
}
action
.
ListRestrictions
=
ListRestrictions
{
labelSelector
,
fieldSelector
}
...
@@ -375,9 +377,14 @@ func (a GetActionImpl) GetName() string {
...
@@ -375,9 +377,14 @@ func (a GetActionImpl) GetName() string {
type
ListActionImpl
struct
{
type
ListActionImpl
struct
{
ActionImpl
ActionImpl
Kind
schema
.
GroupVersionKind
ListRestrictions
ListRestrictions
ListRestrictions
ListRestrictions
}
}
func
(
a
ListActionImpl
)
GetKind
()
schema
.
GroupVersionKind
{
return
a
.
Kind
}
func
(
a
ListActionImpl
)
GetListRestrictions
()
ListRestrictions
{
func
(
a
ListActionImpl
)
GetListRestrictions
()
ListRestrictions
{
return
a
.
ListRestrictions
return
a
.
ListRestrictions
}
}
...
...
staging/src/k8s.io/client-go/testing/fixture.go
View file @
bbb94e42
This diff is collapsed.
Click to expand it.
staging/src/k8s.io/metrics/pkg/client/clientset_generated/clientset/fake/clientset_generated.go
View file @
bbb94e42
...
@@ -33,7 +33,7 @@ import (
...
@@ -33,7 +33,7 @@ import (
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
// for a real clientset and is mostly useful in simple unit tests.
func
NewSimpleClientset
(
objects
...
runtime
.
Object
)
*
Clientset
{
func
NewSimpleClientset
(
objects
...
runtime
.
Object
)
*
Clientset
{
o
:=
testing
.
NewObjectTracker
(
api
.
Registry
,
api
.
Scheme
,
api
.
Codecs
.
UniversalDecoder
())
o
:=
testing
.
NewObjectTracker
(
api
.
Scheme
,
api
.
Codecs
.
UniversalDecoder
())
for
_
,
obj
:=
range
objects
{
for
_
,
obj
:=
range
objects
{
if
err
:=
o
.
Add
(
obj
);
err
!=
nil
{
if
err
:=
o
.
Add
(
obj
);
err
!=
nil
{
panic
(
err
)
panic
(
err
)
...
@@ -41,7 +41,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
...
@@ -41,7 +41,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
}
}
fakePtr
:=
testing
.
Fake
{}
fakePtr
:=
testing
.
Fake
{}
fakePtr
.
AddReactor
(
"*"
,
"*"
,
testing
.
ObjectReaction
(
o
,
api
.
Registry
.
RESTMapper
()
))
fakePtr
.
AddReactor
(
"*"
,
"*"
,
testing
.
ObjectReaction
(
o
))
fakePtr
.
AddWatchReactor
(
"*"
,
testing
.
DefaultWatchReactor
(
watch
.
NewFake
(),
nil
))
fakePtr
.
AddWatchReactor
(
"*"
,
testing
.
DefaultWatchReactor
(
watch
.
NewFake
(),
nil
))
...
...
staging/src/k8s.io/metrics/pkg/client/clientset_generated/clientset/typed/metrics/v1alpha1/fake/fake_nodemetrics.go
View file @
bbb94e42
...
@@ -32,6 +32,8 @@ type FakeNodeMetricses struct {
...
@@ -32,6 +32,8 @@ type FakeNodeMetricses struct {
var
nodemetricsesResource
=
schema
.
GroupVersionResource
{
Group
:
"metrics"
,
Version
:
"v1alpha1"
,
Resource
:
"nodemetricses"
}
var
nodemetricsesResource
=
schema
.
GroupVersionResource
{
Group
:
"metrics"
,
Version
:
"v1alpha1"
,
Resource
:
"nodemetricses"
}
var
nodemetricsesKind
=
schema
.
GroupVersionKind
{
Group
:
"metrics"
,
Version
:
"v1alpha1"
,
Kind
:
"NodeMetrics"
}
func
(
c
*
FakeNodeMetricses
)
Get
(
name
string
,
options
v1
.
GetOptions
)
(
result
*
v1alpha1
.
NodeMetrics
,
err
error
)
{
func
(
c
*
FakeNodeMetricses
)
Get
(
name
string
,
options
v1
.
GetOptions
)
(
result
*
v1alpha1
.
NodeMetrics
,
err
error
)
{
obj
,
err
:=
c
.
Fake
.
obj
,
err
:=
c
.
Fake
.
Invokes
(
testing
.
NewRootGetAction
(
nodemetricsesResource
,
name
),
&
v1alpha1
.
NodeMetrics
{})
Invokes
(
testing
.
NewRootGetAction
(
nodemetricsesResource
,
name
),
&
v1alpha1
.
NodeMetrics
{})
...
@@ -43,7 +45,7 @@ func (c *FakeNodeMetricses) Get(name string, options v1.GetOptions) (result *v1a
...
@@ -43,7 +45,7 @@ func (c *FakeNodeMetricses) Get(name string, options v1.GetOptions) (result *v1a
func
(
c
*
FakeNodeMetricses
)
List
(
opts
v1
.
ListOptions
)
(
result
*
v1alpha1
.
NodeMetricsList
,
err
error
)
{
func
(
c
*
FakeNodeMetricses
)
List
(
opts
v1
.
ListOptions
)
(
result
*
v1alpha1
.
NodeMetricsList
,
err
error
)
{
obj
,
err
:=
c
.
Fake
.
obj
,
err
:=
c
.
Fake
.
Invokes
(
testing
.
NewRootListAction
(
nodemetricsesResource
,
opts
),
&
v1alpha1
.
NodeMetricsList
{})
Invokes
(
testing
.
NewRootListAction
(
nodemetricsesResource
,
nodemetricsesKind
,
opts
),
&
v1alpha1
.
NodeMetricsList
{})
if
obj
==
nil
{
if
obj
==
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
staging/src/k8s.io/metrics/pkg/client/clientset_generated/clientset/typed/metrics/v1alpha1/fake/fake_podmetrics.go
View file @
bbb94e42
...
@@ -33,6 +33,8 @@ type FakePodMetricses struct {
...
@@ -33,6 +33,8 @@ type FakePodMetricses struct {
var
podmetricsesResource
=
schema
.
GroupVersionResource
{
Group
:
"metrics"
,
Version
:
"v1alpha1"
,
Resource
:
"podmetricses"
}
var
podmetricsesResource
=
schema
.
GroupVersionResource
{
Group
:
"metrics"
,
Version
:
"v1alpha1"
,
Resource
:
"podmetricses"
}
var
podmetricsesKind
=
schema
.
GroupVersionKind
{
Group
:
"metrics"
,
Version
:
"v1alpha1"
,
Kind
:
"PodMetrics"
}
func
(
c
*
FakePodMetricses
)
Get
(
name
string
,
options
v1
.
GetOptions
)
(
result
*
v1alpha1
.
PodMetrics
,
err
error
)
{
func
(
c
*
FakePodMetricses
)
Get
(
name
string
,
options
v1
.
GetOptions
)
(
result
*
v1alpha1
.
PodMetrics
,
err
error
)
{
obj
,
err
:=
c
.
Fake
.
obj
,
err
:=
c
.
Fake
.
Invokes
(
testing
.
NewGetAction
(
podmetricsesResource
,
c
.
ns
,
name
),
&
v1alpha1
.
PodMetrics
{})
Invokes
(
testing
.
NewGetAction
(
podmetricsesResource
,
c
.
ns
,
name
),
&
v1alpha1
.
PodMetrics
{})
...
@@ -45,7 +47,7 @@ func (c *FakePodMetricses) Get(name string, options v1.GetOptions) (result *v1al
...
@@ -45,7 +47,7 @@ func (c *FakePodMetricses) Get(name string, options v1.GetOptions) (result *v1al
func
(
c
*
FakePodMetricses
)
List
(
opts
v1
.
ListOptions
)
(
result
*
v1alpha1
.
PodMetricsList
,
err
error
)
{
func
(
c
*
FakePodMetricses
)
List
(
opts
v1
.
ListOptions
)
(
result
*
v1alpha1
.
PodMetricsList
,
err
error
)
{
obj
,
err
:=
c
.
Fake
.
obj
,
err
:=
c
.
Fake
.
Invokes
(
testing
.
NewListAction
(
podmetricsesResource
,
c
.
ns
,
opts
),
&
v1alpha1
.
PodMetricsList
{})
Invokes
(
testing
.
NewListAction
(
podmetricsesResource
,
podmetricsesKind
,
c
.
ns
,
opts
),
&
v1alpha1
.
PodMetricsList
{})
if
obj
==
nil
{
if
obj
==
nil
{
return
nil
,
err
return
nil
,
err
...
...
staging/src/k8s.io/metrics/pkg/client/custom_metrics/fake/fake_client.go
View file @
bbb94e42
...
@@ -19,9 +19,9 @@ package fake
...
@@ -19,9 +19,9 @@ package fake
import
(
import
(
"fmt"
"fmt"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/testing"
"k8s.io/client-go/testing"
"k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1"
"k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1"
cmclient
"k8s.io/metrics/pkg/client/custom_metrics"
cmclient
"k8s.io/metrics/pkg/client/custom_metrics"
...
@@ -52,13 +52,12 @@ func (i GetForActionImpl) GetSubresource() string {
...
@@ -52,13 +52,12 @@ func (i GetForActionImpl) GetSubresource() string {
}
}
func
NewGetForAction
(
groupKind
schema
.
GroupKind
,
namespace
,
name
string
,
metricName
string
,
labelSelector
labels
.
Selector
)
GetForActionImpl
{
func
NewGetForAction
(
groupKind
schema
.
GroupKind
,
namespace
,
name
string
,
metricName
string
,
labelSelector
labels
.
Selector
)
GetForActionImpl
{
mapping
,
err
:=
api
.
Registry
.
RESTMapper
()
.
RESTMapping
(
groupKind
)
// the version doesn't matter
if
err
!=
nil
{
gvk
:=
groupKind
.
WithVersion
(
""
)
panic
(
fmt
.
Sprintf
(
"unable to get REST mapping for groupKind %s while building GetFor action: %v"
,
groupKind
.
String
,
err
))
gvr
,
_
:=
meta
.
UnsafeGuessKindToResource
(
gvk
)
}
groupResourceForKind
:=
schema
.
GroupResource
{
groupResourceForKind
:=
schema
.
GroupResource
{
Group
:
mapping
.
GroupVersionKind
.
Group
,
Group
:
gvr
.
Group
,
Resource
:
mapping
.
Resource
,
Resource
:
gvr
.
Resource
,
}
}
resource
:=
schema
.
GroupResource
{
resource
:=
schema
.
GroupResource
{
Group
:
v1alpha1
.
SchemeGroupVersion
.
Group
,
Group
:
v1alpha1
.
SchemeGroupVersion
.
Group
,
...
@@ -72,13 +71,12 @@ func NewGetForAction(groupKind schema.GroupKind, namespace, name string, metricN
...
@@ -72,13 +71,12 @@ func NewGetForAction(groupKind schema.GroupKind, namespace, name string, metricN
}
}
func
NewRootGetForAction
(
groupKind
schema
.
GroupKind
,
name
string
,
metricName
string
,
labelSelector
labels
.
Selector
)
GetForActionImpl
{
func
NewRootGetForAction
(
groupKind
schema
.
GroupKind
,
name
string
,
metricName
string
,
labelSelector
labels
.
Selector
)
GetForActionImpl
{
mapping
,
err
:=
api
.
Registry
.
RESTMapper
()
.
RESTMapping
(
groupKind
)
// the version doesn't matter
if
err
!=
nil
{
gvk
:=
groupKind
.
WithVersion
(
""
)
panic
(
fmt
.
Sprintf
(
"unable to get REST mapping for groupKind %s while building GetFor action: %v"
,
groupKind
.
String
,
err
))
gvr
,
_
:=
meta
.
UnsafeGuessKindToResource
(
gvk
)
}
groupResourceForKind
:=
schema
.
GroupResource
{
groupResourceForKind
:=
schema
.
GroupResource
{
Group
:
mapping
.
GroupVersionKind
.
Group
,
Group
:
gvr
.
Group
,
Resource
:
mapping
.
Resource
,
Resource
:
gvr
.
Resource
,
}
}
resource
:=
schema
.
GroupResource
{
resource
:=
schema
.
GroupResource
{
Group
:
v1alpha1
.
SchemeGroupVersion
.
Group
,
Group
:
v1alpha1
.
SchemeGroupVersion
.
Group
,
...
...
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