Documentation ¶
Overview ¶
Copyright 2018 the Velero contributors.
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.
Copyright 2018 the Velero contributors.
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.
Index ¶
- func AssertDeepEqual(t *testing.T, expected, actual interface{}) bool
- func AssertErrorMatches(t *testing.T, expected string, actual error) bool
- func CompareActions(t *testing.T, expected, actual []core.Action)
- func CompareSlice(x, y []string) bool
- func GetAsMap(j string) (map[string]interface{}, error)
- func NewFakeControllerRuntimeClient(t *testing.T, initObjs ...runtime.Object) client.Client
- func NewFakeControllerRuntimeClientBuilder(t *testing.T) *k8sfake.ClientBuilder
- func NewLogger() logrus.FieldLogger
- func NewLoggerWithLevel(level logrus.Level) logrus.FieldLogger
- func NewSingleLogger(buffer *string) logrus.FieldLogger
- func TimesAreEqual(t1, t2 time.Time) bool
- func UnstructuredOrDie(data string) *unstructured.Unstructured
- func ValidatePatch(t *testing.T, action core.Action, expected interface{}, ...)
- type APIResource
- func Backups(items ...metav1.Object) *APIResource
- func CRDs(items ...metav1.Object) *APIResource
- func DataUploads(items ...metav1.Object) *APIResource
- func Deployments(items ...metav1.Object) *APIResource
- func ExtensionsDeployments(items ...metav1.Object) *APIResource
- func Namespaces(items ...metav1.Object) *APIResource
- func PVCs(items ...metav1.Object) *APIResource
- func PVs(items ...metav1.Object) *APIResource
- func Pods(items ...metav1.Object) *APIResource
- func Secrets(items ...metav1.Object) *APIResource
- func ServiceAccounts(items ...metav1.Object) *APIResource
- func Services(items ...metav1.Object) *APIResource
- func VSLs(items ...metav1.Object) *APIResource
- func VeleroDeployments(items ...metav1.Object) *APIResource
- type APIServer
- type DiscoveryClient
- type FakeDiscoveryHelper
- func (dh *FakeDiscoveryHelper) APIGroups() []metav1.APIGroup
- func (dh *FakeDiscoveryHelper) KindFor(input schema.GroupVersionKind) (schema.GroupVersionResource, metav1.APIResource, error)
- func (dh *FakeDiscoveryHelper) Refresh() error
- func (dh *FakeDiscoveryHelper) ResourceFor(input schema.GroupVersionResource) (schema.GroupVersionResource, metav1.APIResource, error)
- func (dh *FakeDiscoveryHelper) Resources() []*metav1.APIResourceList
- func (dh *FakeDiscoveryHelper) ServerVersion() *version.Info
- type FakeDynamicClient
- func (c *FakeDynamicClient) Create(obj *unstructured.Unstructured) (*unstructured.Unstructured, error)
- func (c *FakeDynamicClient) Delete(name string, opts metav1.DeleteOptions) error
- func (c *FakeDynamicClient) Get(name string, opts metav1.GetOptions) (*unstructured.Unstructured, error)
- func (c *FakeDynamicClient) List(options metav1.ListOptions) (*unstructured.UnstructuredList, error)
- func (c *FakeDynamicClient) Patch(name string, data []byte) (*unstructured.Unstructured, error)
- func (c *FakeDynamicClient) UpdateStatus(obj *unstructured.Unstructured, opts metav1.UpdateOptions) (*unstructured.Unstructured, error)
- func (c *FakeDynamicClient) Watch(options metav1.ListOptions) (watch.Interface, error)
- type FakeDynamicFactory
- type FakeFileSystem
- func (fs *FakeFileSystem) Create(name string) (io.WriteCloser, error)
- func (fs *FakeFileSystem) DirExists(path string) (bool, error)
- func (fs *FakeFileSystem) Glob(path string) ([]string, error)
- func (fs *FakeFileSystem) MkdirAll(path string, perm os.FileMode) error
- func (fs *FakeFileSystem) OpenFile(name string, flag int, perm os.FileMode) (io.WriteCloser, error)
- func (fs *FakeFileSystem) ReadDir(dirname string) ([]fs.FileInfo, error)
- func (fs *FakeFileSystem) ReadFile(filename string) ([]byte, error)
- func (fs *FakeFileSystem) RemoveAll(path string) error
- func (fs *FakeFileSystem) Stat(path string) (os.FileInfo, error)
- func (fs *FakeFileSystem) TempDir(dir, prefix string) (string, error)
- func (fs *FakeFileSystem) TempFile(dir, prefix string) (filesystem.NameWriteCloser, error)
- func (fs *FakeFileSystem) WithDirectories(path ...string) *FakeFileSystem
- func (fs *FakeFileSystem) WithDirectory(path string) *FakeFileSystem
- func (fs *FakeFileSystem) WithFile(path string, data []byte) *FakeFileSystem
- func (fs *FakeFileSystem) WithFileAndMode(path string, data []byte, mode os.FileMode) *FakeFileSystem
- type FakeMapper
- type FakeNamespaceClient
- func (c *FakeNamespaceClient) Apply(ctx context.Context, namespace *v1.NamespaceApplyConfiguration, ...) (result *corev1api.Namespace, err error)
- func (c *FakeNamespaceClient) ApplyStatus(ctx context.Context, namespace *v1.NamespaceApplyConfiguration, ...) (result *corev1api.Namespace, err error)
- func (c *FakeNamespaceClient) Create(ctx context.Context, obj *corev1api.Namespace, options metav1.CreateOptions) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
- func (c *FakeNamespaceClient) Finalize(ctx context.Context, item *corev1api.Namespace, options metav1.UpdateOptions) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) List(ctx context.Context, options metav1.ListOptions) (*corev1api.NamespaceList, error)
- func (c *FakeNamespaceClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, ...) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) Update(ctx context.Context, namespace *corev1api.Namespace, ...) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) UpdateStatus(ctx context.Context, namespace *corev1api.Namespace, ...) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) Watch(ctx context.Context, options metav1.ListOptions) (watch.Interface, error)
- type FakeServerResourcesInterface
- type FakeVolumeSnapshotter
- func (bs *FakeVolumeSnapshotter) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error)
- func (bs *FakeVolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (string, error)
- func (bs *FakeVolumeSnapshotter) DeleteSnapshot(snapshotID string) error
- func (bs *FakeVolumeSnapshotter) GetVolumeID(pv runtime.Unstructured) (string, error)
- func (bs *FakeVolumeSnapshotter) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error)
- func (bs *FakeVolumeSnapshotter) Init(config map[string]string) error
- func (bs *FakeVolumeSnapshotter) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error)
- type FileStore
- type MockPodCommandExecutor
- type TarWriter
- type VolumeBackupInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertDeepEqual ¶
AssertDeepEqual asserts the semantic equality of objects. This function exists in order to make sure time.Time and metav1.Time objects can be compared correctly. See https://github.com/stretchr/testify/issues/502.
func AssertErrorMatches ¶
AssertErrorMatches asserts that if expected is the empty string, actual is nil, otherwise, that actual's error string matches expected.
func CompareActions ¶
CompareActions checks slices of actual and expected Actions for equality (ignoring order). It checks that the lengths of the slices are the same, that each actual Action has a corresponding expected Action, and that each expected Action has a corresponding actual Action.
func CompareSlice ¶ added in v1.12.0
func NewFakeControllerRuntimeClient ¶ added in v1.6.0
func NewFakeControllerRuntimeClientBuilder ¶ added in v1.9.0
func NewFakeControllerRuntimeClientBuilder(t *testing.T) *k8sfake.ClientBuilder
func NewLogger ¶
func NewLogger() logrus.FieldLogger
func NewLoggerWithLevel ¶ added in v1.12.0
func NewLoggerWithLevel(level logrus.Level) logrus.FieldLogger
func NewSingleLogger ¶ added in v1.12.0
func NewSingleLogger(buffer *string) logrus.FieldLogger
func TimesAreEqual ¶
TimesAreEqual compares two times for equality. This function is used by equality.Semantic.DeepEqual to compare two time objects without having to call a method.
func UnstructuredOrDie ¶
func UnstructuredOrDie(data string) *unstructured.Unstructured
func ValidatePatch ¶
func ValidatePatch(t *testing.T, action core.Action, expected interface{}, decodeFunc func(*json.Decoder) (interface{}, error))
ValidatePatch tests the validity of an action. It checks that the action is a PatchAction, that the patch decodes from JSON with the provided decode func and has no extraneous fields, and that the decoded patch matches the expected.
Types ¶
type APIResource ¶
type APIResource struct { Group string Version string Name string ShortName string Namespaced bool Items []metav1.Object }
APIResource stores information about a specific Kubernetes API resource.
func Backups ¶ added in v1.11.0
func Backups(items ...metav1.Object) *APIResource
func CRDs ¶ added in v1.2.0
func CRDs(items ...metav1.Object) *APIResource
func DataUploads ¶ added in v1.12.0
func DataUploads(items ...metav1.Object) *APIResource
func Deployments ¶
func Deployments(items ...metav1.Object) *APIResource
func ExtensionsDeployments ¶
func ExtensionsDeployments(items ...metav1.Object) *APIResource
func Namespaces ¶
func Namespaces(items ...metav1.Object) *APIResource
func PVCs ¶
func PVCs(items ...metav1.Object) *APIResource
func PVs ¶
func PVs(items ...metav1.Object) *APIResource
func Pods ¶
func Pods(items ...metav1.Object) *APIResource
Pods returns an APIResource describing core/v1's Pods.
func Secrets ¶
func Secrets(items ...metav1.Object) *APIResource
func ServiceAccounts ¶
func ServiceAccounts(items ...metav1.Object) *APIResource
func Services ¶ added in v1.8.0
func Services(items ...metav1.Object) *APIResource
func VSLs ¶ added in v1.2.0
func VSLs(items ...metav1.Object) *APIResource
func VeleroDeployments ¶ added in v1.8.0
func VeleroDeployments(items ...metav1.Object) *APIResource
test CRD
func (*APIResource) GVR ¶
func (r *APIResource) GVR() schema.GroupVersionResource
GVR returns a GroupVersionResource representing the resource.
type APIServer ¶
type APIServer struct { VeleroClient *fake.Clientset KubeClient *kubefake.Clientset DynamicClient *dynamicfake.FakeDynamicClient DiscoveryClient *DiscoveryClient }
APIServer contains in-memory fakes for all of the relevant Kubernetes API server clients.
func NewAPIServer ¶
NewAPIServer constructs an APIServer with all of its clients initialized.
type DiscoveryClient ¶
type DiscoveryClient struct {
*discoveryfake.FakeDiscovery
}
DiscoveryClient is a wrapper for the client-go FakeDiscovery struct. It adds some extra functionality that's necessary/useful for Velero tests.
func (*DiscoveryClient) ServerPreferredResources ¶
func (c *DiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error)
func (*DiscoveryClient) WithAPIResource ¶
func (c *DiscoveryClient) WithAPIResource(resource *APIResource) *DiscoveryClient
WithAPIResource adds the API resource to the discovery client.
type FakeDiscoveryHelper ¶
type FakeDiscoveryHelper struct { ResourceList []*metav1.APIResourceList Mapper meta.RESTMapper AutoReturnResource bool APIGroupsList []metav1.APIGroup ServerVersionData *version.Info }
func NewFakeDiscoveryHelper ¶
func NewFakeDiscoveryHelper(autoReturnResource bool, resources map[schema.GroupVersionResource]schema.GroupVersionResource) *FakeDiscoveryHelper
func (*FakeDiscoveryHelper) APIGroups ¶
func (dh *FakeDiscoveryHelper) APIGroups() []metav1.APIGroup
func (*FakeDiscoveryHelper) KindFor ¶ added in v1.5.0
func (dh *FakeDiscoveryHelper) KindFor(input schema.GroupVersionKind) (schema.GroupVersionResource, metav1.APIResource, error)
func (*FakeDiscoveryHelper) Refresh ¶
func (dh *FakeDiscoveryHelper) Refresh() error
func (*FakeDiscoveryHelper) ResourceFor ¶
func (dh *FakeDiscoveryHelper) ResourceFor(input schema.GroupVersionResource) (schema.GroupVersionResource, metav1.APIResource, error)
func (*FakeDiscoveryHelper) Resources ¶
func (dh *FakeDiscoveryHelper) Resources() []*metav1.APIResourceList
func (*FakeDiscoveryHelper) ServerVersion ¶ added in v1.4.0
func (dh *FakeDiscoveryHelper) ServerVersion() *version.Info
type FakeDynamicClient ¶
func (*FakeDynamicClient) Create ¶
func (c *FakeDynamicClient) Create(obj *unstructured.Unstructured) (*unstructured.Unstructured, error)
func (*FakeDynamicClient) Delete ¶ added in v1.6.0
func (c *FakeDynamicClient) Delete(name string, opts metav1.DeleteOptions) error
func (*FakeDynamicClient) Get ¶
func (c *FakeDynamicClient) Get(name string, opts metav1.GetOptions) (*unstructured.Unstructured, error)
func (*FakeDynamicClient) List ¶
func (c *FakeDynamicClient) List(options metav1.ListOptions) (*unstructured.UnstructuredList, error)
func (*FakeDynamicClient) Patch ¶
func (c *FakeDynamicClient) Patch(name string, data []byte) (*unstructured.Unstructured, error)
func (*FakeDynamicClient) UpdateStatus ¶ added in v1.9.0
func (c *FakeDynamicClient) UpdateStatus(obj *unstructured.Unstructured, opts metav1.UpdateOptions) (*unstructured.Unstructured, error)
func (*FakeDynamicClient) Watch ¶
func (c *FakeDynamicClient) Watch(options metav1.ListOptions) (watch.Interface, error)
type FakeDynamicFactory ¶
func (*FakeDynamicFactory) ClientForGroupVersionResource ¶
func (df *FakeDynamicFactory) ClientForGroupVersionResource(gv schema.GroupVersion, resource metav1.APIResource, namespace string) (client.Dynamic, error)
func (*FakeDynamicFactory) DynamicSharedInformerFactoryForNamespace ¶ added in v1.12.1
func (df *FakeDynamicFactory) DynamicSharedInformerFactoryForNamespace(namespace string) dynamicinformer.DynamicSharedInformerFactory
type FakeFileSystem ¶
type FakeFileSystem struct { ReadDirCalls []string // contains filtered or unexported fields }
func NewFakeFileSystem ¶
func NewFakeFileSystem() *FakeFileSystem
func (*FakeFileSystem) Create ¶
func (fs *FakeFileSystem) Create(name string) (io.WriteCloser, error)
func (*FakeFileSystem) Glob ¶ added in v1.9.0
func (fs *FakeFileSystem) Glob(path string) ([]string, error)
func (*FakeFileSystem) MkdirAll ¶
func (fs *FakeFileSystem) MkdirAll(path string, perm os.FileMode) error
func (*FakeFileSystem) OpenFile ¶ added in v1.6.0
func (fs *FakeFileSystem) OpenFile(name string, flag int, perm os.FileMode) (io.WriteCloser, error)
func (*FakeFileSystem) ReadDir ¶
func (fs *FakeFileSystem) ReadDir(dirname string) ([]fs.FileInfo, error)
func (*FakeFileSystem) ReadFile ¶
func (fs *FakeFileSystem) ReadFile(filename string) ([]byte, error)
func (*FakeFileSystem) RemoveAll ¶
func (fs *FakeFileSystem) RemoveAll(path string) error
func (*FakeFileSystem) TempDir ¶
func (fs *FakeFileSystem) TempDir(dir, prefix string) (string, error)
func (*FakeFileSystem) TempFile ¶
func (fs *FakeFileSystem) TempFile(dir, prefix string) (filesystem.NameWriteCloser, error)
func (*FakeFileSystem) WithDirectories ¶
func (fs *FakeFileSystem) WithDirectories(path ...string) *FakeFileSystem
func (*FakeFileSystem) WithDirectory ¶
func (fs *FakeFileSystem) WithDirectory(path string) *FakeFileSystem
func (*FakeFileSystem) WithFile ¶
func (fs *FakeFileSystem) WithFile(path string, data []byte) *FakeFileSystem
func (*FakeFileSystem) WithFileAndMode ¶
func (fs *FakeFileSystem) WithFileAndMode(path string, data []byte, mode os.FileMode) *FakeFileSystem
type FakeMapper ¶
type FakeMapper struct { meta.RESTMapper AutoReturnResource bool Resources map[schema.GroupVersionResource]schema.GroupVersionResource KindToPluralResource map[schema.GroupVersionKind]schema.GroupVersionResource }
func (*FakeMapper) RESTMapping ¶ added in v1.12.0
func (m *FakeMapper) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error)
func (*FakeMapper) ResourceFor ¶
func (m *FakeMapper) ResourceFor(input schema.GroupVersionResource) (schema.GroupVersionResource, error)
type FakeNamespaceClient ¶
func (*FakeNamespaceClient) Apply ¶ added in v1.7.1
func (c *FakeNamespaceClient) Apply(ctx context.Context, namespace *v1.NamespaceApplyConfiguration, opts metav1.ApplyOptions) (result *corev1api.Namespace, err error)
func (*FakeNamespaceClient) ApplyStatus ¶ added in v1.7.1
func (c *FakeNamespaceClient) ApplyStatus(ctx context.Context, namespace *v1.NamespaceApplyConfiguration, opts metav1.ApplyOptions) (result *corev1api.Namespace, err error)
func (*FakeNamespaceClient) Create ¶
func (c *FakeNamespaceClient) Create(ctx context.Context, obj *corev1api.Namespace, options metav1.CreateOptions) (*corev1api.Namespace, error)
func (*FakeNamespaceClient) Delete ¶
func (c *FakeNamespaceClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
func (*FakeNamespaceClient) Finalize ¶
func (c *FakeNamespaceClient) Finalize(ctx context.Context, item *corev1api.Namespace, options metav1.UpdateOptions) (*corev1api.Namespace, error)
func (*FakeNamespaceClient) Get ¶
func (c *FakeNamespaceClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*corev1api.Namespace, error)
func (*FakeNamespaceClient) List ¶
func (c *FakeNamespaceClient) List(ctx context.Context, options metav1.ListOptions) (*corev1api.NamespaceList, error)
func (*FakeNamespaceClient) Update ¶
func (c *FakeNamespaceClient) Update(ctx context.Context, namespace *corev1api.Namespace, options metav1.UpdateOptions) (*corev1api.Namespace, error)
func (*FakeNamespaceClient) UpdateStatus ¶
func (c *FakeNamespaceClient) UpdateStatus(ctx context.Context, namespace *corev1api.Namespace, options metav1.UpdateOptions) (*corev1api.Namespace, error)
func (*FakeNamespaceClient) Watch ¶
func (c *FakeNamespaceClient) Watch(ctx context.Context, options metav1.ListOptions) (watch.Interface, error)
type FakeServerResourcesInterface ¶
type FakeServerResourcesInterface struct { ResourceList []*metav1.APIResourceList APIGroup []*metav1.APIGroup FailedGroups map[schema.GroupVersion]error ReturnError error }
func NewFakeServerResourcesInterface ¶
func NewFakeServerResourcesInterface(resourceList []*metav1.APIResourceList, apiGroup []*metav1.APIGroup, failedGroups map[schema.GroupVersion]error, returnError error) *FakeServerResourcesInterface
func (*FakeServerResourcesInterface) ServerGroupsAndResources ¶ added in v1.4.0
func (di *FakeServerResourcesInterface) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error)
func (*FakeServerResourcesInterface) ServerPreferredResources ¶
func (di *FakeServerResourcesInterface) ServerPreferredResources() ([]*metav1.APIResourceList, error)
type FakeVolumeSnapshotter ¶
type FakeVolumeSnapshotter struct { // SnapshotID->VolumeID SnapshotsTaken sets.String // VolumeID -> (SnapshotID, Type, Iops) SnapshottableVolumes map[string]VolumeBackupInfo // VolumeBackupInfo -> VolumeID RestorableVolumes map[VolumeBackupInfo]string VolumeID string VolumeIDSet string Error error }
func (*FakeVolumeSnapshotter) CreateSnapshot ¶
func (*FakeVolumeSnapshotter) CreateVolumeFromSnapshot ¶
func (bs *FakeVolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (string, error)
func (*FakeVolumeSnapshotter) DeleteSnapshot ¶
func (bs *FakeVolumeSnapshotter) DeleteSnapshot(snapshotID string) error
func (*FakeVolumeSnapshotter) GetVolumeID ¶
func (bs *FakeVolumeSnapshotter) GetVolumeID(pv runtime.Unstructured) (string, error)
func (*FakeVolumeSnapshotter) GetVolumeInfo ¶
func (bs *FakeVolumeSnapshotter) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error)
func (*FakeVolumeSnapshotter) Init ¶
func (bs *FakeVolumeSnapshotter) Init(config map[string]string) error
func (*FakeVolumeSnapshotter) SetVolumeID ¶
func (bs *FakeVolumeSnapshotter) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error)
type FileStore ¶ added in v1.6.0
type FileStore interface { // Path returns a path on disk where the secret key defined by // the given selector is serialized. Path(selector *corev1api.SecretKeySelector) (string, error) }
FileStore defines operations for interacting with credentials that are stored on a file system.
func NewFakeCredentialsFileStore ¶ added in v1.6.0
NewFakeCredentialFileStore creates a FileStore which will return the given path and error when Path is called.
type MockPodCommandExecutor ¶
func (*MockPodCommandExecutor) ExecutePodCommand ¶
func (e *MockPodCommandExecutor) ExecutePodCommand(log logrus.FieldLogger, item map[string]interface{}, namespace, name, hookName string, hook *v1.ExecHook) error
Source Files ¶
- api_server.go
- comparisons.go
- discovery_client.go
- fake_controller_runtime_client.go
- fake_credential_file_store.go
- fake_discovery_helper.go
- fake_dynamic.go
- fake_file_system.go
- fake_mapper.go
- fake_namespace.go
- fake_volume_snapshotter.go
- helpers.go
- mock_pod_command_executor.go
- resources.go
- tar_writer.go
- test_logger.go