|
| 1 | +// This file is part of MinIO Console Server |
| 2 | +// Copyright (c) 2023 MinIO, Inc. |
| 3 | +// |
| 4 | +// This program is free software: you can redistribute it and/or modify |
| 5 | +// it under the terms of the GNU Affero General Public License as published by |
| 6 | +// the Free Software Foundation, either version 3 of the License, or |
| 7 | +// (at your option) any later version. |
| 8 | +// |
| 9 | +// This program is distributed in the hope that it will be useful, |
| 10 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +// GNU Affero General Public License for more details. |
| 13 | +// |
| 14 | +// You should have received a copy of the GNU Affero General Public License |
| 15 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +package operatorapi |
| 18 | + |
| 19 | +import ( |
| 20 | + "context" |
| 21 | + |
| 22 | + corev1 "k8s.io/api/core/v1" |
| 23 | + v1 "k8s.io/api/core/v1" |
| 24 | + storagev1 "k8s.io/api/storage/v1" |
| 25 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 26 | +) |
| 27 | + |
| 28 | +type k8sClientMock struct{} |
| 29 | + |
| 30 | +var ( |
| 31 | + k8sClientGetResourceQuotaMock func(ctx context.Context, namespace, resource string, opts metav1.GetOptions) (*v1.ResourceQuota, error) |
| 32 | + k8sClientGetNameSpaceMock func(ctx context.Context, name string, opts metav1.GetOptions) (*v1.Namespace, error) |
| 33 | + k8sClientStorageClassesMock func(ctx context.Context, opts metav1.ListOptions) (*storagev1.StorageClassList, error) |
| 34 | + |
| 35 | + k8sClientGetConfigMapMock func(ctx context.Context, namespace, configMap string, opts metav1.GetOptions) (*corev1.ConfigMap, error) |
| 36 | + k8sClientCreateConfigMapMock func(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.CreateOptions) (*corev1.ConfigMap, error) |
| 37 | + k8sClientUpdateConfigMapMock func(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.UpdateOptions) (*corev1.ConfigMap, error) |
| 38 | + k8sClientDeleteConfigMapMock func(ctx context.Context, namespace string, name string, opts metav1.DeleteOptions) error |
| 39 | + |
| 40 | + k8sClientDeletePodCollectionMock func(ctx context.Context, namespace string, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error |
| 41 | + k8sClientDeleteSecretMock func(ctx context.Context, namespace string, name string, opts metav1.DeleteOptions) error |
| 42 | + k8sClientCreateSecretMock func(ctx context.Context, namespace string, secret *v1.Secret, opts metav1.CreateOptions) (*v1.Secret, error) |
| 43 | + k8sClientUpdateSecretMock func(ctx context.Context, namespace string, secret *v1.Secret, opts metav1.UpdateOptions) (*v1.Secret, error) |
| 44 | + k8sclientGetSecretMock func(ctx context.Context, namespace, secretName string, opts metav1.GetOptions) (*corev1.Secret, error) |
| 45 | + k8sclientGetServiceMock func(ctx context.Context, namespace, serviceName string, opts metav1.GetOptions) (*corev1.Service, error) |
| 46 | +) |
| 47 | + |
| 48 | +func (c k8sClientMock) getResourceQuota(ctx context.Context, namespace, resource string, opts metav1.GetOptions) (*v1.ResourceQuota, error) { |
| 49 | + return k8sClientGetResourceQuotaMock(ctx, namespace, resource, opts) |
| 50 | +} |
| 51 | + |
| 52 | +func (c k8sClientMock) getNamespace(ctx context.Context, name string, opts metav1.GetOptions) (*v1.Namespace, error) { |
| 53 | + return k8sClientGetNameSpaceMock(ctx, name, opts) |
| 54 | +} |
| 55 | + |
| 56 | +func (c k8sClientMock) getStorageClasses(ctx context.Context, opts metav1.ListOptions) (*storagev1.StorageClassList, error) { |
| 57 | + return k8sClientStorageClassesMock(ctx, opts) |
| 58 | +} |
| 59 | + |
| 60 | +func (c k8sClientMock) getConfigMap(ctx context.Context, namespace, configMap string, opts metav1.GetOptions) (*corev1.ConfigMap, error) { |
| 61 | + return k8sClientGetConfigMapMock(ctx, namespace, configMap, opts) |
| 62 | +} |
| 63 | + |
| 64 | +func (c k8sClientMock) createConfigMap(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.CreateOptions) (*corev1.ConfigMap, error) { |
| 65 | + return k8sClientCreateConfigMapMock(ctx, namespace, cm, opts) |
| 66 | +} |
| 67 | + |
| 68 | +func (c k8sClientMock) updateConfigMap(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.UpdateOptions) (*corev1.ConfigMap, error) { |
| 69 | + return k8sClientUpdateConfigMapMock(ctx, namespace, cm, opts) |
| 70 | +} |
| 71 | + |
| 72 | +func (c k8sClientMock) deleteConfigMap(ctx context.Context, namespace string, name string, opts metav1.DeleteOptions) error { |
| 73 | + return k8sClientDeleteConfigMapMock(ctx, namespace, name, opts) |
| 74 | +} |
| 75 | + |
| 76 | +func (c k8sClientMock) deletePodCollection(ctx context.Context, namespace string, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { |
| 77 | + return k8sClientDeletePodCollectionMock(ctx, namespace, opts, listOpts) |
| 78 | +} |
| 79 | + |
| 80 | +func (c k8sClientMock) deleteSecret(ctx context.Context, namespace string, name string, opts metav1.DeleteOptions) error { |
| 81 | + return k8sClientDeleteSecretMock(ctx, namespace, name, opts) |
| 82 | +} |
| 83 | + |
| 84 | +func (c k8sClientMock) createSecret(ctx context.Context, namespace string, secret *v1.Secret, opts metav1.CreateOptions) (*v1.Secret, error) { |
| 85 | + return k8sClientCreateSecretMock(ctx, namespace, secret, opts) |
| 86 | +} |
| 87 | + |
| 88 | +func (c k8sClientMock) updateSecret(ctx context.Context, namespace string, secret *v1.Secret, opts metav1.UpdateOptions) (*v1.Secret, error) { |
| 89 | + return k8sClientUpdateSecretMock(ctx, namespace, secret, opts) |
| 90 | +} |
| 91 | + |
| 92 | +func (c k8sClientMock) getSecret(ctx context.Context, namespace, secretName string, opts metav1.GetOptions) (*corev1.Secret, error) { |
| 93 | + return k8sclientGetSecretMock(ctx, namespace, secretName, opts) |
| 94 | +} |
| 95 | + |
| 96 | +func (c k8sClientMock) getService(ctx context.Context, namespace, serviceName string, opts metav1.GetOptions) (*corev1.Service, error) { |
| 97 | + return k8sclientGetServiceMock(ctx, namespace, serviceName, opts) |
| 98 | +} |
0 commit comments