testing

package
v0.30.0-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 40 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InternalGV = schema.GroupVersion{Group: "apitest", Version: runtime.APIVersionInternal}

InternalGV is the internal group version object

View Source
var UnlikelyGV = schema.GroupVersion{Group: "apitest", Version: "unlikelyversion"}

UnlikelyGV is a group version object for unrecognised version

View Source
var ValidVersion = "v1"

ValidVersion of API

View Source
var ValidVersionGV = schema.GroupVersion{Group: "apitest", Version: ValidVersion}

ValidVersionGV is the valid group version object

Functions

func AddToScheme

func AddToScheme(scheme *runtime.Scheme) (meta.RESTMapper, runtime.Codec)

AddToScheme adds required objects into scheme

func BytesBody

func BytesBody(bodyBytes []byte) io.ReadCloser

func DefaultClientConfig

func DefaultClientConfig() *restclient.Config

func DefaultHeader

func DefaultHeader() http.Header

func EmptyTestData

EmptyTestData returns no pod, service, or replication controller

func GenResponseWithJsonEncodedBody

func GenResponseWithJsonEncodedBody(bodyStruct interface{}) (*http.Response, error)

func InitTestErrorHandler

func InitTestErrorHandler(t *testing.T)

func NewExternalScheme

func NewExternalScheme() (*runtime.Scheme, meta.RESTMapper, runtime.Codec)

NewExternalScheme returns required objects for ExternalScheme

func ObjBody

func ObjBody(codec runtime.Codec, obj runtime.Object) io.ReadCloser

func StringBody

func StringBody(body string) io.ReadCloser

func SubresourceTestData added in v0.24.0

func SubresourceTestData() *corev1.Pod

func WithAlphaEnvs added in v0.27.0

func WithAlphaEnvs(features []cmdutil.FeatureGate, t *testing.T, f func(*testing.T))

WithAlphaEnvs calls func f with the given env-var-based feature gates enabled, and then restores the original values of those variables.

func WithAlphaEnvsDisabled added in v0.29.0

func WithAlphaEnvsDisabled(features []cmdutil.FeatureGate, t *testing.T, f func(*testing.T))

WithAlphaEnvs calls func f with the given env-var-based feature gates disabled, and then restores the original values of those variables.

Types

type ExternalNamespacedType

type ExternalNamespacedType struct {
	Kind       string `json:"kind"`
	APIVersion string `json:"apiVersion"`

	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

ExternalNamespacedType schema for external namespaced types +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func (*ExternalNamespacedType) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalNamespacedType.

func (*ExternalNamespacedType) DeepCopyInto

func (in *ExternalNamespacedType) DeepCopyInto(out *ExternalNamespacedType)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ExternalNamespacedType) DeepCopyObject

func (in *ExternalNamespacedType) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*ExternalNamespacedType) GetObjectKind

func (obj *ExternalNamespacedType) GetObjectKind() schema.ObjectKind

GetObjectKind returns the ObjectKind schema

func (*ExternalNamespacedType) GroupVersionKind

func (obj *ExternalNamespacedType) GroupVersionKind() schema.GroupVersionKind

GroupVersionKind returns the GroupVersionKind schema

func (*ExternalNamespacedType) SetGroupVersionKind

func (obj *ExternalNamespacedType) SetGroupVersionKind(gvk schema.GroupVersionKind)

SetGroupVersionKind sets the API version and kind from schema

type ExternalNamespacedType2

type ExternalNamespacedType2 struct {
	Kind       string `json:"kind"`
	APIVersion string `json:"apiVersion"`

	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

ExternalNamespacedType2 schema for external namespaced types +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func (*ExternalNamespacedType2) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalNamespacedType2.

func (*ExternalNamespacedType2) DeepCopyInto

func (in *ExternalNamespacedType2) DeepCopyInto(out *ExternalNamespacedType2)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ExternalNamespacedType2) DeepCopyObject

func (in *ExternalNamespacedType2) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*ExternalNamespacedType2) GetObjectKind

func (obj *ExternalNamespacedType2) GetObjectKind() schema.ObjectKind

GetObjectKind returns the ObjectKind schema

func (*ExternalNamespacedType2) GroupVersionKind

func (obj *ExternalNamespacedType2) GroupVersionKind() schema.GroupVersionKind

GroupVersionKind returns the GroupVersionKind schema

func (*ExternalNamespacedType2) SetGroupVersionKind

func (obj *ExternalNamespacedType2) SetGroupVersionKind(gvk schema.GroupVersionKind)

SetGroupVersionKind sets the API version and kind from schema

type ExternalType

type ExternalType struct {
	Kind       string `json:"kind"`
	APIVersion string `json:"apiVersion"`

	Name string `json:"name"`
}

ExternalType is the schema for external type +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func (*ExternalType) DeepCopy

func (in *ExternalType) DeepCopy() *ExternalType

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalType.

func (*ExternalType) DeepCopyInto

func (in *ExternalType) DeepCopyInto(out *ExternalType)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ExternalType) DeepCopyObject

func (in *ExternalType) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*ExternalType) GetObjectKind

func (obj *ExternalType) GetObjectKind() schema.ObjectKind

GetObjectKind returns the ObjectKind schema

func (*ExternalType) GroupVersionKind

func (obj *ExternalType) GroupVersionKind() schema.GroupVersionKind

GroupVersionKind returns the GroupVersionKind schema

func (*ExternalType) SetGroupVersionKind

func (obj *ExternalType) SetGroupVersionKind(gvk schema.GroupVersionKind)

SetGroupVersionKind returns the GroupVersionKind schema

type ExternalType2

type ExternalType2 struct {
	Kind       string `json:"kind"`
	APIVersion string `json:"apiVersion"`

	Name string `json:"name"`
}

ExternalType2 is another schema for external type +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func (*ExternalType2) DeepCopy

func (in *ExternalType2) DeepCopy() *ExternalType2

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalType2.

func (*ExternalType2) DeepCopyInto

func (in *ExternalType2) DeepCopyInto(out *ExternalType2)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ExternalType2) DeepCopyObject

func (in *ExternalType2) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*ExternalType2) GetObjectKind

func (obj *ExternalType2) GetObjectKind() schema.ObjectKind

GetObjectKind returns the ObjectKind schema

func (*ExternalType2) GroupVersionKind

func (obj *ExternalType2) GroupVersionKind() schema.GroupVersionKind

GroupVersionKind returns the FromAPIVersionAndKind schema

func (*ExternalType2) SetGroupVersionKind

func (obj *ExternalType2) SetGroupVersionKind(gvk schema.GroupVersionKind)

SetGroupVersionKind sets the API version and obj kind from schema

type FakeCachedDiscoveryClient added in v0.25.0

type FakeCachedDiscoveryClient struct {
	discovery.DiscoveryInterface
	Groups             []*metav1.APIGroup
	Resources          []*metav1.APIResourceList
	PreferredResources []*metav1.APIResourceList
	Invalidations      int
}

func NewFakeCachedDiscoveryClient added in v0.25.0

func NewFakeCachedDiscoveryClient() *FakeCachedDiscoveryClient

func (*FakeCachedDiscoveryClient) Fresh added in v0.25.0

func (d *FakeCachedDiscoveryClient) Fresh() bool

func (*FakeCachedDiscoveryClient) Invalidate added in v0.25.0

func (d *FakeCachedDiscoveryClient) Invalidate()

func (*FakeCachedDiscoveryClient) ServerGroups added in v0.25.0

func (d *FakeCachedDiscoveryClient) ServerGroups() (*metav1.APIGroupList, error)

func (*FakeCachedDiscoveryClient) ServerGroupsAndResources added in v0.25.0

func (d *FakeCachedDiscoveryClient) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error)

func (*FakeCachedDiscoveryClient) ServerPreferredResources added in v0.25.0

func (d *FakeCachedDiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error)

type InternalNamespacedType

type InternalNamespacedType struct {
	Kind       string
	APIVersion string

	Name      string
	Namespace string
}

InternalNamespacedType schema for internal namespaced types +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func NewInternalNamespacedType

func NewInternalNamespacedType(kind, apiversion, name, namespace string) *InternalNamespacedType

NewInternalNamespacedType returns an initialized instance of InternalNamespacedType

func (*InternalNamespacedType) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InternalNamespacedType.

func (*InternalNamespacedType) DeepCopyInto

func (in *InternalNamespacedType) DeepCopyInto(out *InternalNamespacedType)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*InternalNamespacedType) DeepCopyObject

func (in *InternalNamespacedType) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*InternalNamespacedType) GetObjectKind

func (obj *InternalNamespacedType) GetObjectKind() schema.ObjectKind

GetObjectKind returns the ObjectKind schema

func (*InternalNamespacedType) GroupVersionKind

func (obj *InternalNamespacedType) GroupVersionKind() schema.GroupVersionKind

GroupVersionKind returns the GroupVersionKind schema

func (*InternalNamespacedType) SetGroupVersionKind

func (obj *InternalNamespacedType) SetGroupVersionKind(gvk schema.GroupVersionKind)

SetGroupVersionKind sets the API group and kind from schema

type InternalType

type InternalType struct {
	Kind       string
	APIVersion string

	Name string
}

InternalType is the schema for internal type +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func NewInternalType

func NewInternalType(kind, apiversion, name string) *InternalType

NewInternalType returns an initialized InternalType instance

func (*InternalType) DeepCopy

func (in *InternalType) DeepCopy() *InternalType

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InternalType.

func (*InternalType) DeepCopyInto

func (in *InternalType) DeepCopyInto(out *InternalType)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*InternalType) DeepCopyObject

func (in *InternalType) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*InternalType) GetObjectKind

func (obj *InternalType) GetObjectKind() schema.ObjectKind

GetObjectKind returns the ObjectKind schema

func (*InternalType) GroupVersionKind

func (obj *InternalType) GroupVersionKind() schema.GroupVersionKind

GroupVersionKind returns GroupVersionKind schema

func (*InternalType) SetGroupVersionKind

func (obj *InternalType) SetGroupVersionKind(gvk schema.GroupVersionKind)

SetGroupVersionKind sets the version and kind

type RESTClient

type RESTClient interface {
	Get() *client.Request
	Post() *client.Request
	Patch(types.PatchType) *client.Request
	Delete() *client.Request
	Put() *client.Request
}

RESTClient is a client helper for dealing with RESTful resources in a generic way.

type TestFactory

type TestFactory struct {
	cmdutil.Factory

	Client             RESTClient
	ScaleGetter        scaleclient.ScalesGetter
	UnstructuredClient RESTClient
	ClientConfigVal    *restclient.Config
	FakeDynamicClient  *fakedynamic.FakeDynamicClient

	UnstructuredClientForMappingFunc resource.FakeClientFunc
	OpenAPISchemaFunc                func() (openapi.Resources, error)
	OpenAPIV3ClientFunc              func() (openapiclient.Client, error)
	// contains filtered or unexported fields
}

TestFactory extends cmdutil.Factory

func NewTestFactory

func NewTestFactory() *TestFactory

NewTestFactory returns an initialized TestFactory instance

func (*TestFactory) Cleanup

func (f *TestFactory) Cleanup()

Cleanup cleans up TestFactory temp config file

func (*TestFactory) ClientForMapping

func (f *TestFactory) ClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error)

ClientForMapping is used to Client from a TestFactory

func (*TestFactory) DiscoveryClient

func (f *TestFactory) DiscoveryClient() (discovery.CachedDiscoveryInterface, error)

DiscoveryClient returns a discovery client from TestFactory

func (*TestFactory) DynamicClient

func (f *TestFactory) DynamicClient() (dynamic.Interface, error)

DynamicClient returns a dynamic client from TestFactory

func (*TestFactory) KubernetesClientSet

func (f *TestFactory) KubernetesClientSet() (*kubernetes.Clientset, error)

KubernetesClientSet initializes and returns the Clientset using TestFactory

func (*TestFactory) NewBuilder

func (f *TestFactory) NewBuilder() *resource.Builder

NewBuilder returns an initialized resource.Builder instance

func (*TestFactory) OpenAPISchema

func (f *TestFactory) OpenAPISchema() (openapi.Resources, error)

OpenAPISchema returns openapi resources

func (*TestFactory) OpenAPIV3Client added in v0.27.0

func (f *TestFactory) OpenAPIV3Client() (openapiclient.Client, error)

func (*TestFactory) PathOptions added in v0.20.0

func (f *TestFactory) PathOptions() *clientcmd.PathOptions

PathOptions returns a new PathOptions with a temp file

func (*TestFactory) PathOptionsWithConfig added in v0.20.0

func (f *TestFactory) PathOptionsWithConfig(config clientcmdapi.Config) (*clientcmd.PathOptions, error)

PathOptionsWithConfig writes a config to a temp file and returns PathOptions

func (*TestFactory) RESTClient

func (f *TestFactory) RESTClient() (*restclient.RESTClient, error)

RESTClient returns a REST client from TestFactory

func (*TestFactory) ScaleClient

func (f *TestFactory) ScaleClient() (scaleclient.ScalesGetter, error)

ScaleClient returns the ScalesGetter from a TestFactory

func (*TestFactory) ToRESTConfig

func (f *TestFactory) ToRESTConfig() (*restclient.Config, error)

ToRESTConfig is used to get ClientConfigVal from a TestFactory

func (*TestFactory) UnstructuredClientForMapping

func (f *TestFactory) UnstructuredClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error)

UnstructuredClientForMapping is used to get UnstructuredClient from a TestFactory

func (*TestFactory) Validator

func (f *TestFactory) Validator(validateDirective string) (validation.Schema, error)

Validator returns a validation schema

func (*TestFactory) WithClientConfig added in v0.24.0

func (f *TestFactory) WithClientConfig(clientConfig clientcmd.ClientConfig) *TestFactory

WithClientConfig sets the client config to use

func (*TestFactory) WithDiscoveryClient added in v0.25.0

func (f *TestFactory) WithDiscoveryClient(discoveryClient discovery.CachedDiscoveryInterface) *TestFactory

func (*TestFactory) WithNamespace

func (f *TestFactory) WithNamespace(ns string) *TestFactory

WithNamespace is used to mention namespace reactively

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL