add common codes for sources client (#514)

This commit is contained in:
Ying Chun Guo 2019-11-27 16:50:21 +08:00 committed by Knative Prow Robot
parent e07b5a98b5
commit 37d27782a5
11 changed files with 640 additions and 4 deletions

View File

@ -18,6 +18,13 @@ import (
client_v1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" client_v1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1"
) )
// KnSourcesClient to Eventing Sources. All methods are relative to the
// namespace specified during construction
type KnSourcesClient interface {
// Namespace in which this client is operating for
Namespace() string
}
// knSourcesClient is a combination of Sources client interface and namespace // knSourcesClient is a combination of Sources client interface and namespace
// Temporarily help to add sources dependencies // Temporarily help to add sources dependencies
// May be changed when adding real sources features // May be changed when adding real sources features
@ -25,3 +32,16 @@ type knSourcesClient struct {
client client_v1alpha1.SourcesV1alpha1Interface client client_v1alpha1.SourcesV1alpha1Interface
namespace string namespace string
} }
// NewKnSourcesClient is to invoke Eventing Sources Client API to create object
func NewKnSourcesClient(client client_v1alpha1.SourcesV1alpha1Interface, namespace string) KnSourcesClient {
return &knSourcesClient{
namespace: namespace,
client: client,
}
}
// Return the client's namespace
func (c *knSourcesClient) Namespace() string {
return c.namespace
}

View File

@ -29,6 +29,9 @@ import (
"knative.dev/client/pkg/serving/v1alpha1" "knative.dev/client/pkg/serving/v1alpha1"
"knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake" "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake"
sources_client "knative.dev/client/pkg/eventing/sources/v1alpha1"
sources_fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake"
) )
const FakeNamespace = "current" const FakeNamespace = "current"
@ -54,6 +57,19 @@ func CreateTestKnCommand(cmd *cobra.Command, knParams *KnParams) (*cobra.Command
return knCommand, fakeServing, buf return knCommand, fakeServing, buf
} }
// CreateSourcesTestKnCommand helper for creating test commands
func CreateSourcesTestKnCommand(cmd *cobra.Command, knParams *KnParams) (*cobra.Command, *sources_fake.FakeSourcesV1alpha1, *bytes.Buffer) {
buf := new(bytes.Buffer)
fakeEventing := &sources_fake.FakeSourcesV1alpha1{&client_testing.Fake{}}
knParams.Output = buf
knParams.NewSourcesClient = func(namespace string) (sources_client.KnSourcesClient, error) {
return sources_client.NewKnSourcesClient(fakeEventing, FakeNamespace), nil
}
knParams.fixedCurrentNamespace = FakeNamespace
knCommand := NewKnTestCommand(cmd, knParams)
return knCommand, fakeEventing, buf
}
// CaptureStdout collects the current content of os.Stdout // CaptureStdout collects the current content of os.Stdout
func CaptureStdout(t *testing.T) { func CaptureStdout(t *testing.T) {
oldStdout = os.Stdout oldStdout = os.Stdout

View File

@ -21,6 +21,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gotest.tools/assert" "gotest.tools/assert"
sources_fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake"
"knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake" "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake"
) )
@ -54,3 +55,34 @@ func TestCreateTestKnCommand(t *testing.T) {
assert.Assert(t, knCmd.SilenceErrors == true) assert.Assert(t, knCmd.SilenceErrors == true)
}) })
} }
func TestCreateSourcesTestKnCommand(t *testing.T) {
var (
knCmd *cobra.Command
serving *sources_fake.FakeSourcesV1alpha1
buffer *bytes.Buffer
)
setup := func(t *testing.T) {
knParams := &KnParams{}
knCmd, serving, buffer = CreateSourcesTestKnCommand(&cobra.Command{Use: "fake"}, knParams)
assert.Assert(t, knCmd != nil)
assert.Assert(t, len(knCmd.Commands()) == 1)
assert.Assert(t, knCmd.Commands()[0].Use == "fake")
assert.Assert(t, serving != nil)
assert.Assert(t, buffer != nil)
}
t.Run("creates a new kn cobra.Command", func(t *testing.T) {
setup(t)
assert.Assert(t, knCmd != nil)
assert.Assert(t, knCmd.Use == "kn")
assert.Assert(t, knCmd.Short == "Knative client")
assert.Assert(t, strings.Contains(knCmd.Long, "Manage your Knative building blocks:"))
assert.Assert(t, knCmd.RunE == nil)
assert.Assert(t, knCmd.DisableAutoGenTag == true)
assert.Assert(t, knCmd.SilenceUsage == true)
assert.Assert(t, knCmd.SilenceErrors == true)
})
}

View File

@ -21,8 +21,10 @@ import (
"path/filepath" "path/filepath"
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
sources_kn_v1alpha1 "knative.dev/client/pkg/eventing/sources/v1alpha1"
serving_kn_v1alpha1 "knative.dev/client/pkg/serving/v1alpha1" serving_kn_v1alpha1 "knative.dev/client/pkg/serving/v1alpha1"
"knative.dev/client/pkg/util" "knative.dev/client/pkg/util"
eventing_sources "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1"
serving_v1alpha1_client "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1" serving_v1alpha1_client "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1"
) )
@ -44,6 +46,7 @@ type KnParams struct {
KubeCfgPath string KubeCfgPath string
ClientConfig clientcmd.ClientConfig ClientConfig clientcmd.ClientConfig
NewClient func(namespace string) (serving_kn_v1alpha1.KnServingClient, error) NewClient func(namespace string) (serving_kn_v1alpha1.KnServingClient, error)
NewSourcesClient func(namespace string) (sources_kn_v1alpha1.KnSourcesClient, error)
// General global options // General global options
LogHTTP bool LogHTTP bool
@ -56,6 +59,9 @@ func (params *KnParams) Initialize() {
if params.NewClient == nil { if params.NewClient == nil {
params.NewClient = params.newClient params.NewClient = params.newClient
} }
if params.NewSourcesClient == nil {
params.NewSourcesClient = params.newSourcesClient
}
} }
func (params *KnParams) newClient(namespace string) (serving_kn_v1alpha1.KnServingClient, error) { func (params *KnParams) newClient(namespace string) (serving_kn_v1alpha1.KnServingClient, error) {
@ -66,6 +72,29 @@ func (params *KnParams) newClient(namespace string) (serving_kn_v1alpha1.KnServi
return serving_kn_v1alpha1.NewKnServingClient(client, namespace), nil return serving_kn_v1alpha1.NewKnServingClient(client, namespace), nil
} }
func (params *KnParams) newSourcesClient(namespace string) (sources_kn_v1alpha1.KnSourcesClient, error) {
var err error
if params.ClientConfig == nil {
params.ClientConfig, err = params.GetClientConfig()
if err != nil {
return nil, err
}
}
clientConfig, err := params.ClientConfig.ClientConfig()
if err != nil {
return nil, err
}
if params.LogHTTP {
// TODO: When we update to the newer version of client-go, replace with
// config.Wrap() for future compat.
clientConfig.WrapTransport = util.NewLoggingTransport
}
client, _ := eventing_sources.NewForConfig(clientConfig)
return sources_kn_v1alpha1.NewKnSourcesClient(client, namespace), nil
}
// GetConfig returns Serving Client // GetConfig returns Serving Client
func (params *KnParams) GetConfig() (serving_v1alpha1_client.ServingV1alpha1Interface, error) { func (params *KnParams) GetConfig() (serving_v1alpha1_client.ServingV1alpha1Interface, error) {
var err error var err error

View File

@ -141,3 +141,53 @@ func TestGetClientConfig(t *testing.T) {
} }
} }
} }
func TestNewSourcesClient(t *testing.T) {
basic, err := clientcmd.NewClientConfigFromBytes([]byte(BASIC_KUBECONFIG))
namespace := "test"
if err != nil {
t.Error(err)
}
for i, tc := range []getConfigTestCase{
{
clientcmd.NewDefaultClientConfig(clientcmdapi.Config{}, &clientcmd.ConfigOverrides{}),
"no configuration has been provided",
false,
},
{
basic,
"",
false,
},
{ // Test that the cast to wrap the http client in a logger works
basic,
"",
true,
},
} {
p := &KnParams{
ClientConfig: tc.clientConfig,
LogHTTP: tc.logHttp,
}
sourcesClient, err := p.newSourcesClient(namespace)
switch len(tc.expectedErrString) {
case 0:
if err != nil {
t.Errorf("%d: unexpected error: %s", i, err.Error())
}
default:
if err == nil {
t.Errorf("%d: wrong error detected: %s (expected) != %s (actual)", i, tc.expectedErrString, err)
}
if !strings.Contains(err.Error(), tc.expectedErrString) {
t.Errorf("%d: wrong error detected: %s (expected) != %s (actual)", i, tc.expectedErrString, err.Error())
}
}
if sourcesClient != nil {
assert.Assert(t, sourcesClient.Namespace() == namespace)
}
}
}

View File

@ -0,0 +1,20 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake

View File

@ -0,0 +1,140 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
)
// FakeApiServerSources implements ApiServerSourceInterface
type FakeApiServerSources struct {
Fake *FakeSourcesV1alpha1
ns string
}
var apiserversourcesResource = schema.GroupVersionResource{Group: "sources.eventing.knative.dev", Version: "v1alpha1", Resource: "apiserversources"}
var apiserversourcesKind = schema.GroupVersionKind{Group: "sources.eventing.knative.dev", Version: "v1alpha1", Kind: "ApiServerSource"}
// Get takes name of the apiServerSource, and returns the corresponding apiServerSource object, and an error if there is any.
func (c *FakeApiServerSources) Get(name string, options v1.GetOptions) (result *v1alpha1.ApiServerSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(apiserversourcesResource, c.ns, name), &v1alpha1.ApiServerSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ApiServerSource), err
}
// List takes label and field selectors, and returns the list of ApiServerSources that match those selectors.
func (c *FakeApiServerSources) List(opts v1.ListOptions) (result *v1alpha1.ApiServerSourceList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(apiserversourcesResource, apiserversourcesKind, c.ns, opts), &v1alpha1.ApiServerSourceList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.ApiServerSourceList{ListMeta: obj.(*v1alpha1.ApiServerSourceList).ListMeta}
for _, item := range obj.(*v1alpha1.ApiServerSourceList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested apiServerSources.
func (c *FakeApiServerSources) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(apiserversourcesResource, c.ns, opts))
}
// Create takes the representation of a apiServerSource and creates it. Returns the server's representation of the apiServerSource, and an error, if there is any.
func (c *FakeApiServerSources) Create(apiServerSource *v1alpha1.ApiServerSource) (result *v1alpha1.ApiServerSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(apiserversourcesResource, c.ns, apiServerSource), &v1alpha1.ApiServerSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ApiServerSource), err
}
// Update takes the representation of a apiServerSource and updates it. Returns the server's representation of the apiServerSource, and an error, if there is any.
func (c *FakeApiServerSources) Update(apiServerSource *v1alpha1.ApiServerSource) (result *v1alpha1.ApiServerSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(apiserversourcesResource, c.ns, apiServerSource), &v1alpha1.ApiServerSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ApiServerSource), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeApiServerSources) UpdateStatus(apiServerSource *v1alpha1.ApiServerSource) (*v1alpha1.ApiServerSource, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(apiserversourcesResource, "status", c.ns, apiServerSource), &v1alpha1.ApiServerSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ApiServerSource), err
}
// Delete takes name of the apiServerSource and deletes it. Returns an error if one occurs.
func (c *FakeApiServerSources) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(apiserversourcesResource, c.ns, name), &v1alpha1.ApiServerSource{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeApiServerSources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(apiserversourcesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v1alpha1.ApiServerSourceList{})
return err
}
// Patch applies the patch and returns the patched apiServerSource.
func (c *FakeApiServerSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ApiServerSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(apiserversourcesResource, c.ns, name, pt, data, subresources...), &v1alpha1.ApiServerSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ApiServerSource), err
}

View File

@ -0,0 +1,140 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
)
// FakeContainerSources implements ContainerSourceInterface
type FakeContainerSources struct {
Fake *FakeSourcesV1alpha1
ns string
}
var containersourcesResource = schema.GroupVersionResource{Group: "sources.eventing.knative.dev", Version: "v1alpha1", Resource: "containersources"}
var containersourcesKind = schema.GroupVersionKind{Group: "sources.eventing.knative.dev", Version: "v1alpha1", Kind: "ContainerSource"}
// Get takes name of the containerSource, and returns the corresponding containerSource object, and an error if there is any.
func (c *FakeContainerSources) Get(name string, options v1.GetOptions) (result *v1alpha1.ContainerSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(containersourcesResource, c.ns, name), &v1alpha1.ContainerSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ContainerSource), err
}
// List takes label and field selectors, and returns the list of ContainerSources that match those selectors.
func (c *FakeContainerSources) List(opts v1.ListOptions) (result *v1alpha1.ContainerSourceList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(containersourcesResource, containersourcesKind, c.ns, opts), &v1alpha1.ContainerSourceList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.ContainerSourceList{ListMeta: obj.(*v1alpha1.ContainerSourceList).ListMeta}
for _, item := range obj.(*v1alpha1.ContainerSourceList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested containerSources.
func (c *FakeContainerSources) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(containersourcesResource, c.ns, opts))
}
// Create takes the representation of a containerSource and creates it. Returns the server's representation of the containerSource, and an error, if there is any.
func (c *FakeContainerSources) Create(containerSource *v1alpha1.ContainerSource) (result *v1alpha1.ContainerSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(containersourcesResource, c.ns, containerSource), &v1alpha1.ContainerSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ContainerSource), err
}
// Update takes the representation of a containerSource and updates it. Returns the server's representation of the containerSource, and an error, if there is any.
func (c *FakeContainerSources) Update(containerSource *v1alpha1.ContainerSource) (result *v1alpha1.ContainerSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(containersourcesResource, c.ns, containerSource), &v1alpha1.ContainerSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ContainerSource), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeContainerSources) UpdateStatus(containerSource *v1alpha1.ContainerSource) (*v1alpha1.ContainerSource, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(containersourcesResource, "status", c.ns, containerSource), &v1alpha1.ContainerSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ContainerSource), err
}
// Delete takes name of the containerSource and deletes it. Returns an error if one occurs.
func (c *FakeContainerSources) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(containersourcesResource, c.ns, name), &v1alpha1.ContainerSource{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeContainerSources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(containersourcesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v1alpha1.ContainerSourceList{})
return err
}
// Patch applies the patch and returns the patched containerSource.
func (c *FakeContainerSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ContainerSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(containersourcesResource, c.ns, name, pt, data, subresources...), &v1alpha1.ContainerSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ContainerSource), err
}

View File

@ -0,0 +1,140 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
)
// FakeCronJobSources implements CronJobSourceInterface
type FakeCronJobSources struct {
Fake *FakeSourcesV1alpha1
ns string
}
var cronjobsourcesResource = schema.GroupVersionResource{Group: "sources.eventing.knative.dev", Version: "v1alpha1", Resource: "cronjobsources"}
var cronjobsourcesKind = schema.GroupVersionKind{Group: "sources.eventing.knative.dev", Version: "v1alpha1", Kind: "CronJobSource"}
// Get takes name of the cronJobSource, and returns the corresponding cronJobSource object, and an error if there is any.
func (c *FakeCronJobSources) Get(name string, options v1.GetOptions) (result *v1alpha1.CronJobSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(cronjobsourcesResource, c.ns, name), &v1alpha1.CronJobSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.CronJobSource), err
}
// List takes label and field selectors, and returns the list of CronJobSources that match those selectors.
func (c *FakeCronJobSources) List(opts v1.ListOptions) (result *v1alpha1.CronJobSourceList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(cronjobsourcesResource, cronjobsourcesKind, c.ns, opts), &v1alpha1.CronJobSourceList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.CronJobSourceList{ListMeta: obj.(*v1alpha1.CronJobSourceList).ListMeta}
for _, item := range obj.(*v1alpha1.CronJobSourceList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested cronJobSources.
func (c *FakeCronJobSources) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(cronjobsourcesResource, c.ns, opts))
}
// Create takes the representation of a cronJobSource and creates it. Returns the server's representation of the cronJobSource, and an error, if there is any.
func (c *FakeCronJobSources) Create(cronJobSource *v1alpha1.CronJobSource) (result *v1alpha1.CronJobSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(cronjobsourcesResource, c.ns, cronJobSource), &v1alpha1.CronJobSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.CronJobSource), err
}
// Update takes the representation of a cronJobSource and updates it. Returns the server's representation of the cronJobSource, and an error, if there is any.
func (c *FakeCronJobSources) Update(cronJobSource *v1alpha1.CronJobSource) (result *v1alpha1.CronJobSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(cronjobsourcesResource, c.ns, cronJobSource), &v1alpha1.CronJobSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.CronJobSource), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeCronJobSources) UpdateStatus(cronJobSource *v1alpha1.CronJobSource) (*v1alpha1.CronJobSource, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(cronjobsourcesResource, "status", c.ns, cronJobSource), &v1alpha1.CronJobSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.CronJobSource), err
}
// Delete takes name of the cronJobSource and deletes it. Returns an error if one occurs.
func (c *FakeCronJobSources) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(cronjobsourcesResource, c.ns, name), &v1alpha1.CronJobSource{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeCronJobSources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(cronjobsourcesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v1alpha1.CronJobSourceList{})
return err
}
// Patch applies the patch and returns the patched cronJobSource.
func (c *FakeCronJobSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CronJobSource, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(cronjobsourcesResource, c.ns, name, pt, data, subresources...), &v1alpha1.CronJobSource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.CronJobSource), err
}

View File

@ -0,0 +1,48 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
v1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1"
)
type FakeSourcesV1alpha1 struct {
*testing.Fake
}
func (c *FakeSourcesV1alpha1) ApiServerSources(namespace string) v1alpha1.ApiServerSourceInterface {
return &FakeApiServerSources{c, namespace}
}
func (c *FakeSourcesV1alpha1) ContainerSources(namespace string) v1alpha1.ContainerSourceInterface {
return &FakeContainerSources{c, namespace}
}
func (c *FakeSourcesV1alpha1) CronJobSources(namespace string) v1alpha1.CronJobSourceInterface {
return &FakeCronJobSources{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeSourcesV1alpha1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

1
vendor/modules.txt vendored
View File

@ -622,6 +622,7 @@ k8s.io/utils/buffer
k8s.io/utils/trace k8s.io/utils/trace
# knative.dev/eventing v0.10.0 # knative.dev/eventing v0.10.0
knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1 knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1
knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake
knative.dev/eventing/pkg/apis/sources/v1alpha1 knative.dev/eventing/pkg/apis/sources/v1alpha1
knative.dev/eventing/pkg/client/clientset/versioned/scheme knative.dev/eventing/pkg/client/clientset/versioned/scheme
knative.dev/eventing/pkg/apis/duck knative.dev/eventing/pkg/apis/duck