...

Source file src/github.com/redhat-developer/odo/pkg/kclient/interface.go

Documentation: github.com/redhat-developer/odo/pkg/kclient

     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  	// binding.go
    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  	// configmap.go
    47  	ListConfigMaps(labelSelector string) ([]corev1.ConfigMap, error)
    48  
    49  	// deployment.go
    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  	// dynamic.go
    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  	// events.go
    69  	PodWarningEventWatcher(ctx context.Context) (result watch.Interface, isForbidden bool, err error)
    70  
    71  	// kclient.go
    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  	// namespace.go
    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  	// oc_server.go
    95  	GetServerVersion(timeout time.Duration) (*ServerInfo, error)
    96  	GetOCVersion() (string, error)
    97  
    98  	// operators.go
    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  	// owner_reference.go
   111  	TryWithBlockOwnerDeletion(ownerReference metav1.OwnerReference, exec func(ownerReference metav1.OwnerReference) error) error
   112  
   113  	// pods.go
   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  	// port_forwarding.go
   119  	// SetupPortForwarding creates port-forwarding for the pod on the port pairs provided in the
   120  	// ["<localhost-port>":"<remote-pod-port>"] format. errOut is used by the client-go library to output any errors
   121  	// encountered while the port-forwarding is running
   122  	SetupPortForwarding(pod *corev1.Pod, portPairs []string, out io.Writer, errOut io.Writer, stopChan chan struct{}, address string) error
   123  
   124  	// projects.go
   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  	// secrets.go
   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  	// service.go
   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  	// user.go
   151  	RunLogout(stdout io.Writer) error
   152  
   153  	// volumes.go
   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  	// ingress_routes.go
   163  	ListIngresses(namespace, selector string) (*v1.IngressList, error)
   164  
   165  	ListJobs(selector string) (*batchv1.JobList, error)
   166  	// CreateJob creates a K8s job to execute task
   167  	CreateJob(job batchv1.Job, namespace string) (*batchv1.Job, error)
   168  	// WaitForJobToComplete to wait until a job completes or fails; it starts printing log or error if the job does not complete execution after 1 minute
   169  	WaitForJobToComplete(job *batchv1.Job) (*batchv1.Job, error)
   170  	// GetJobLogs retrieves pod logs of a job
   171  	GetJobLogs(job *batchv1.Job, containerName string) (io.ReadCloser, error)
   172  	DeleteJob(jobName string) error
   173  
   174  	// registry.go
   175  	// GetRegistryList returns all Devfile registries from both ClusterDevfileRegistriesList (cluster-scoped)
   176  	// and DevfileRegistriesList (namespace-scoped) resources.
   177  	// Registries from DevfileRegistriesList resources are returned first in the list.
   178  	GetRegistryList() ([]api.Registry, error)
   179  }
   180  

View as plain text