2017-10-25 15:32:53 +00:00
|
|
|
/*
|
2019-03-20 19:32:48 +00:00
|
|
|
Copyright the Velero contributors.
|
2017-10-25 15:32:53 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2018-04-10 19:00:34 +00:00
|
|
|
|
|
|
|
// Code generated by client-gen. DO NOT EDIT.
|
|
|
|
|
2017-08-02 17:27:17 +00:00
|
|
|
package fake
|
|
|
|
|
|
|
|
import (
|
2019-09-30 21:26:56 +00:00
|
|
|
clientset "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
|
|
|
|
velerov1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1"
|
|
|
|
fakevelerov1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1/fake"
|
2017-08-02 17:27:17 +00:00
|
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
|
|
"k8s.io/apimachinery/pkg/watch"
|
|
|
|
"k8s.io/client-go/discovery"
|
|
|
|
fakediscovery "k8s.io/client-go/discovery/fake"
|
|
|
|
"k8s.io/client-go/testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewSimpleClientset returns a clientset that will respond with the provided objects.
|
|
|
|
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
|
|
|
|
// 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.
|
|
|
|
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
|
|
|
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
|
|
|
|
for _, obj := range objects {
|
|
|
|
if err := o.Add(obj); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-27 20:58:15 +00:00
|
|
|
cs := &Clientset{tracker: o}
|
2018-07-02 15:23:08 +00:00
|
|
|
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
|
|
|
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
|
|
|
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
2018-04-10 19:00:34 +00:00
|
|
|
gvr := action.GetResource()
|
|
|
|
ns := action.GetNamespace()
|
|
|
|
watch, err := o.Watch(gvr, ns)
|
|
|
|
if err != nil {
|
|
|
|
return false, nil, err
|
|
|
|
}
|
|
|
|
return true, watch, nil
|
|
|
|
})
|
2017-08-02 17:27:17 +00:00
|
|
|
|
2018-07-02 15:23:08 +00:00
|
|
|
return cs
|
2017-08-02 17:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clientset implements clientset.Interface. Meant to be embedded into a
|
|
|
|
// struct to get a default implementation. This makes faking out just the method
|
|
|
|
// you want to test easier.
|
|
|
|
type Clientset struct {
|
|
|
|
testing.Fake
|
2017-10-25 15:32:53 +00:00
|
|
|
discovery *fakediscovery.FakeDiscovery
|
2019-08-27 20:58:15 +00:00
|
|
|
tracker testing.ObjectTracker
|
2017-08-02 17:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
2017-10-25 15:32:53 +00:00
|
|
|
return c.discovery
|
2017-08-02 17:27:17 +00:00
|
|
|
}
|
|
|
|
|
2019-08-27 20:58:15 +00:00
|
|
|
func (c *Clientset) Tracker() testing.ObjectTracker {
|
|
|
|
return c.tracker
|
|
|
|
}
|
|
|
|
|
2021-11-18 14:25:37 +00:00
|
|
|
var (
|
|
|
|
_ clientset.Interface = &Clientset{}
|
|
|
|
_ testing.FakeClient = &Clientset{}
|
|
|
|
)
|
2017-08-02 17:27:17 +00:00
|
|
|
|
2019-01-25 03:33:07 +00:00
|
|
|
// VeleroV1 retrieves the VeleroV1Client
|
|
|
|
func (c *Clientset) VeleroV1() velerov1.VeleroV1Interface {
|
|
|
|
return &fakevelerov1.FakeVeleroV1{Fake: &c.Fake}
|
|
|
|
}
|