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.
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 GetAsMap(j string) (map[string]interface{}, error)
- func NewLogger() 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 CRDs(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 VSLs(items ...metav1.Object) *APIResource
- type APIServer
- type DiscoveryClient
- type FakeDiscoveryHelper
- func (dh *FakeDiscoveryHelper) APIGroups() []metav1.APIGroup
- 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) 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) 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) MkdirAll(path string, perm os.FileMode) error
- func (fs *FakeFileSystem) ReadDir(dirname string) ([]os.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) Create(obj *corev1api.Namespace) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) Delete(name string, opts *metav1.DeleteOptions) error
- func (c *FakeNamespaceClient) Finalize(item *corev1api.Namespace) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) Get(name string, opts metav1.GetOptions) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) List(options metav1.ListOptions) (*corev1api.NamespaceList, error)
- func (c *FakeNamespaceClient) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) Update(namespace *corev1api.Namespace) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) UpdateStatus(namespace *corev1api.Namespace) (*corev1api.Namespace, error)
- func (c *FakeNamespaceClient) Watch(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 MockPodCommandExecutor
- 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 NewLogger ¶
func NewLogger() 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 CRDs ¶ added in v1.2.0
func CRDs(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 VSLs ¶ added in v1.2.0
func VSLs(items ...metav1.Object) *APIResource
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) 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) 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) 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)
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) MkdirAll ¶
func (fs *FakeFileSystem) MkdirAll(path string, perm os.FileMode) error
func (*FakeFileSystem) ReadDir ¶
func (fs *FakeFileSystem) ReadDir(dirname string) ([]os.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 }
func (*FakeMapper) ResourceFor ¶
func (m *FakeMapper) ResourceFor(input schema.GroupVersionResource) (schema.GroupVersionResource, error)
type FakeNamespaceClient ¶
func (*FakeNamespaceClient) Delete ¶
func (c *FakeNamespaceClient) Delete(name string, opts *metav1.DeleteOptions) error
func (*FakeNamespaceClient) Get ¶
func (c *FakeNamespaceClient) Get(name string, opts metav1.GetOptions) (*corev1api.Namespace, error)
func (*FakeNamespaceClient) List ¶
func (c *FakeNamespaceClient) List(options metav1.ListOptions) (*corev1api.NamespaceList, error)
func (*FakeNamespaceClient) UpdateStatus ¶
func (*FakeNamespaceClient) Watch ¶
func (c *FakeNamespaceClient) Watch(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 MockPodCommandExecutor ¶
func (*MockPodCommandExecutor) ExecutePodCommand ¶
func (e *MockPodCommandExecutor) ExecutePodCommand(log logrus.FieldLogger, item map[string]interface{}, namespace, name, hookName string, hook *v1.ExecHook) error