1 package kclient
2
3 import (
4 "context"
5 "io"
6 "time"
7
8 "github.com/go-openapi/spec"
9 projectv1 "github.com/openshift/api/project/v1"
10 olm "github.com/operator-framework/api/pkg/operators/v1alpha1"
11 appsv1 "k8s.io/api/apps/v1"
12 batchv1 "k8s.io/api/batch/v1"
13 corev1 "k8s.io/api/core/v1"
14 v1 "k8s.io/api/networking/v1"
15 "k8s.io/apimachinery/pkg/api/meta"
16 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
18 "k8s.io/apimachinery/pkg/runtime/schema"
19 "k8s.io/apimachinery/pkg/watch"
20 "k8s.io/client-go/discovery"
21 "k8s.io/client-go/dynamic"
22 "k8s.io/client-go/kubernetes"
23 "k8s.io/client-go/rest"
24 "k8s.io/client-go/tools/clientcmd"
25 psaApi "k8s.io/pod-security-admission/api"
26
27 "github.com/redhat-developer/odo/pkg/api"
28 "github.com/redhat-developer/odo/pkg/platform"
29 bindingApi "github.com/redhat-developer/service-binding-operator/apis/binding/v1alpha1"
30 specApi "github.com/redhat-developer/service-binding-operator/apis/spec/v1alpha3"
31 )
32
33 type ClientInterface interface {
34 platform.Client
35
36
37 IsServiceBindingSupported() (bool, error)
38 GetBindableKinds() (bindingApi.BindableKinds, error)
39 GetBindableKindStatusRestMapping(bindableKindStatuses []bindingApi.BindableKindsStatus) ([]*meta.RESTMapping, error)
40 GetBindingServiceBinding(name string) (bindingApi.ServiceBinding, error)
41 GetSpecServiceBinding(name string) (specApi.ServiceBinding, error)
42 ListServiceBindingsFromAllGroups() ([]specApi.ServiceBinding, []bindingApi.ServiceBinding, error)
43 NewServiceBindingServiceObject(serviceNs string, unstructuredService unstructured.Unstructured, bindingName string) (bindingApi.Service, error)
44 GetWorkloadKinds() ([]string, []schema.GroupVersionKind, error)
45
46
47 ListConfigMaps(labelSelector string) ([]corev1.ConfigMap, error)
48
49
50 GetDeploymentByName(name string) (*appsv1.Deployment, error)
51 GetOneDeployment(componentName, appName string, isPartOfComponent bool) (*appsv1.Deployment, error)
52 GetOneDeploymentFromSelector(selector string) (*appsv1.Deployment, error)
53 GetDeploymentFromSelector(selector string) ([]appsv1.Deployment, error)
54 CreateDeployment(deploy appsv1.Deployment) (*appsv1.Deployment, error)
55 UpdateDeployment(deploy appsv1.Deployment) (*appsv1.Deployment, error)
56 ApplyDeployment(deploy appsv1.Deployment) (*appsv1.Deployment, error)
57 GetDeploymentAPIVersion() (schema.GroupVersionKind, error)
58 IsDeploymentExtensionsV1Beta1() (bool, error)
59 DeploymentWatcher(ctx context.Context, selector string) (watch.Interface, error)
60
61
62 PatchDynamicResource(exampleCustomResource unstructured.Unstructured) (bool, error)
63 ListDynamicResources(namespace string, gvr schema.GroupVersionResource, selector string) (*unstructured.UnstructuredList, error)
64 GetDynamicResource(gvr schema.GroupVersionResource, name string) (*unstructured.Unstructured, error)
65 UpdateDynamicResource(gvr schema.GroupVersionResource, name string, u *unstructured.Unstructured) error
66 DeleteDynamicResource(name string, gvr schema.GroupVersionResource, wait bool) error
67
68
69 PodWarningEventWatcher(ctx context.Context) (result watch.Interface, isForbidden bool, err error)
70
71
72 GetClient() kubernetes.Interface
73 GetConfig() clientcmd.ClientConfig
74 GetClientConfig() *rest.Config
75 GetDynamicClient() dynamic.Interface
76 GeneratePortForwardReq(podName string) *rest.Request
77 SetDiscoveryInterface(client discovery.DiscoveryInterface)
78 IsResourceSupported(apiGroup, apiVersion, resourceName string) (bool, error)
79 IsSSASupported() bool
80 Refresh() (newConfig bool, err error)
81
82
83 GetCurrentNamespace() string
84 SetNamespace(ns string)
85 GetNamespaces() ([]string, error)
86 GetNamespace(name string) (*corev1.Namespace, error)
87 GetNamespaceNormal(name string) (*corev1.Namespace, error)
88 CreateNamespace(name string) (*corev1.Namespace, error)
89 DeleteNamespace(name string, wait bool) error
90 SetCurrentNamespace(namespace string) error
91 WaitForServiceAccountInNamespace(namespace, serviceAccountName string) error
92 GetCurrentNamespacePolicy() (psaApi.Policy, error)
93
94
95 GetServerVersion(timeout time.Duration) (*ServerInfo, error)
96 GetOCVersion() (string, error)
97
98
99 IsCSVSupported() (bool, error)
100 ListClusterServiceVersions() (*olm.ClusterServiceVersionList, error)
101 GetCustomResourcesFromCSV(csv *olm.ClusterServiceVersion) *[]olm.CRDDescription
102 GetCSVWithCR(name string) (*olm.ClusterServiceVersion, error)
103 GetResourceSpecDefinition(group, version, kind string) (*spec.Schema, error)
104 GetRestMappingFromUnstructured(unstructured.Unstructured) (*meta.RESTMapping, error)
105 GetRestMappingFromGVK(gvk schema.GroupVersionKind) (*meta.RESTMapping, error)
106 GetOperatorGVRList() ([]meta.RESTMapping, error)
107 GetGVKFromGVR(gvr schema.GroupVersionResource) (schema.GroupVersionKind, error)
108 GetGVRFromGVK(gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
109
110
111 TryWithBlockOwnerDeletion(ownerReference metav1.OwnerReference, exec func(ownerReference metav1.OwnerReference) error) error
112
113
114 GetPodUsingComponentName(componentName string) (*corev1.Pod, error)
115 PodWatcher(ctx context.Context, selector string) (watch.Interface, error)
116 IsPodNameMatchingSelector(ctx context.Context, podname string, selector string) (bool, error)
117
118
119
120
121
122 SetupPortForwarding(pod *corev1.Pod, portPairs []string, out io.Writer, errOut io.Writer, stopChan chan struct{}, address string) error
123
124
125 CreateNewProject(projectName string, wait bool) error
126 DeleteProject(name string, wait bool) error
127 GetCurrentProjectName() string
128 GetProject(projectName string) (*projectv1.Project, error)
129 IsProjectSupported() (bool, error)
130 ListProjectNames() ([]string, error)
131
132
133 CreateTLSSecret(tlsCertificate []byte, tlsPrivKey []byte, objectMeta metav1.ObjectMeta) (*corev1.Secret, error)
134 GetSecret(name, namespace string) (*corev1.Secret, error)
135 UpdateSecret(secret *corev1.Secret, namespace string) (*corev1.Secret, error)
136 DeleteSecret(secretName, namespace string) error
137 CreateSecret(objectMeta metav1.ObjectMeta, data map[string]string, ownerReference metav1.OwnerReference) error
138 CreateSecrets(componentName string, commonObjectMeta metav1.ObjectMeta, svc *corev1.Service, ownerReference metav1.OwnerReference) error
139 ListSecrets(labelSelector string) ([]corev1.Secret, error)
140 WaitAndGetSecret(name string, namespace string) (*corev1.Secret, error)
141
142
143 CreateService(svc corev1.Service) (*corev1.Service, error)
144 UpdateService(svc corev1.Service) (*corev1.Service, error)
145 ListServices(selector string) ([]corev1.Service, error)
146 DeleteService(serviceName string) error
147 GetOneService(componentName, appName string, isPartOfComponent bool) (*corev1.Service, error)
148 GetOneServiceFromSelector(selector string) (*corev1.Service, error)
149
150
151 RunLogout(stdout io.Writer) error
152
153
154 CreatePVC(pvc corev1.PersistentVolumeClaim) (*corev1.PersistentVolumeClaim, error)
155 DeletePVC(pvcName string) error
156 ListPVCs(selector string) ([]corev1.PersistentVolumeClaim, error)
157 ListPVCNames(selector string) ([]string, error)
158 GetPVCFromName(pvcName string) (*corev1.PersistentVolumeClaim, error)
159 UpdatePVCLabels(pvc *corev1.PersistentVolumeClaim, labels map[string]string) error
160 UpdateStorageOwnerReference(pvc *corev1.PersistentVolumeClaim, ownerReference ...metav1.OwnerReference) error
161
162
163 ListIngresses(namespace, selector string) (*v1.IngressList, error)
164
165 ListJobs(selector string) (*batchv1.JobList, error)
166
167 CreateJob(job batchv1.Job, namespace string) (*batchv1.Job, error)
168
169 WaitForJobToComplete(job *batchv1.Job) (*batchv1.Job, error)
170
171 GetJobLogs(job *batchv1.Job, containerName string) (io.ReadCloser, error)
172 DeleteJob(jobName string) error
173
174
175
176
177
178 GetRegistryList() ([]api.Registry, error)
179 }
180
View as plain text