mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-25 12:17:52 +00:00
Create a new testclient package that can be backed by disk files
Standardize how our fakes are used so that a test case can use a simpler mechanism for providing large, complex data sets, as well as represent queries over time.
This commit is contained in:
@@ -20,103 +20,10 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||
)
|
||||
|
||||
type FakeAction struct {
|
||||
Action string
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
// Fake implements 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 Fake struct {
|
||||
Actions []FakeAction
|
||||
PodsList api.PodList
|
||||
CtrlList api.ReplicationControllerList
|
||||
Ctrl api.ReplicationController
|
||||
ServiceList api.ServiceList
|
||||
EndpointsList api.EndpointsList
|
||||
MinionsList api.NodeList
|
||||
EventsList api.EventList
|
||||
LimitRangesList api.LimitRangeList
|
||||
ResourceQuotaStatus api.ResourceQuota
|
||||
ResourceQuotasList api.ResourceQuotaList
|
||||
NamespacesList api.NamespaceList
|
||||
Namespace api.Namespace
|
||||
SecretList api.SecretList
|
||||
Secret api.Secret
|
||||
Err error
|
||||
Watch watch.Interface
|
||||
PersistentVolume api.PersistentVolume
|
||||
PersistentVolumesList api.PersistentVolumeList
|
||||
PersistentVolumeClaim api.PersistentVolumeClaim
|
||||
PersistentVolumeClaimList api.PersistentVolumeClaimList
|
||||
}
|
||||
|
||||
func (c *Fake) LimitRanges(namespace string) LimitRangeInterface {
|
||||
return &FakeLimitRanges{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
||||
func (c *Fake) ResourceQuotas(namespace string) ResourceQuotaInterface {
|
||||
return &FakeResourceQuotas{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
||||
func (c *Fake) ReplicationControllers(namespace string) ReplicationControllerInterface {
|
||||
return &FakeReplicationControllers{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
||||
func (c *Fake) Nodes() NodeInterface {
|
||||
return &FakeNodes{Fake: c}
|
||||
}
|
||||
|
||||
func (c *Fake) Events(namespace string) EventInterface {
|
||||
return &FakeEvents{Fake: c}
|
||||
}
|
||||
|
||||
func (c *Fake) Endpoints(namespace string) EndpointsInterface {
|
||||
return &FakeEndpoints{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
||||
func (c *Fake) Pods(namespace string) PodInterface {
|
||||
return &FakePods{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
||||
func (c *Fake) PersistentVolumes() PersistentVolumeInterface {
|
||||
return &FakePersistentVolumes{Fake: c}
|
||||
}
|
||||
|
||||
func (c *Fake) PersistentVolumeClaims(namespace string) PersistentVolumeClaimInterface {
|
||||
return &FakePersistentVolumeClaims{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
||||
func (c *Fake) Services(namespace string) ServiceInterface {
|
||||
return &FakeServices{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
||||
func (c *Fake) Secrets(namespace string) SecretsInterface {
|
||||
return &FakeSecrets{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
||||
func (c *Fake) Namespaces() NamespaceInterface {
|
||||
return &FakeNamespaces{Fake: c}
|
||||
}
|
||||
|
||||
func (c *Fake) ServerVersion() (*version.Info, error) {
|
||||
c.Actions = append(c.Actions, FakeAction{Action: "get-version", Value: nil})
|
||||
versionInfo := version.Get()
|
||||
return &versionInfo, nil
|
||||
}
|
||||
|
||||
func (c *Fake) ServerAPIVersions() (*api.APIVersions, error) {
|
||||
c.Actions = append(c.Actions, FakeAction{Action: "get-apiversions", Value: nil})
|
||||
return &api.APIVersions{Versions: []string{"v1beta1", "v1beta2"}}, nil
|
||||
}
|
||||
|
||||
type HTTPClientFunc func(*http.Request) (*http.Response, error)
|
||||
|
||||
func (f HTTPClientFunc) Do(req *http.Request) (*http.Response, error) {
|
||||
|
Reference in New Issue
Block a user