clientgoutils

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 90 Imported by: 0

Documentation

Index

Constants

View Source
const PortForwardProtocolV1Name = "portforward.k8s.io"

PortForwardProtocolV1Name is the subprotocol used for port forwarding. TODO move to API machinery and re-unify with kubelet/server/portfoward

View Source
const (
	ResourcePods = "pods"
)

Variables

View Source
var (
	AllVerbs = []string{"get", "list", "watch", "create", "patch", "delete"}

	PermissionDenied = errors.New("Permission Denied")
)
View Source
var (
	// a resource for dev start should check the permission from secret
	// , pod and itself
	//
	// if a resource needs others auth check put it into this mapping
	ExtCheckForResource = map[string][]string{
		"cronjob": {
			"job",
		},
		"daemonset": {
			"deployment",
		},
	}
)
View Source
var IoStreams = &genericclioptions.IOStreams{
	In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr,
}

Functions

func AddMetas

func AddMetas(ut *unstructured.Unstructured, flags *ApplyFlags)

func AuthCheck

func AuthCheck(namespace, kubeConfig string, cmd *cobra.Command) bool

func CheckForResource

func CheckForResource(kubeConfigContent, namespace string, verbs []string, passWhenTimeout bool, resources ...string) error

func CheckIfDeploymentIsReplicaFailure

func CheckIfDeploymentIsReplicaFailure(deploy *v1.Deployment) (bool, string, string, error)

func DeleteResourceInfo

func DeleteResourceInfo(info *resource.Info) error

func EnhanceListError

func EnhanceListError(err error, opts metav1.ListOptions, subj string) error

func Execute

func Execute(
	method string, url *url.URL, config *restclient.Config,
	stdin io.Reader, stdout, stderr io.Writer, tty bool, terminalSizeQueue k8sremotecommand.TerminalSizeQueue,
) error

func FollowContinue

func FollowContinue(initialOpts *metav1.ListOptions,
	listFunc func(metav1.ListOptions) (runtime.Object, error)) error

func GetCmd

func GetCmd(cmd *cobra.Command, from []string) []string

func GetControllerOfNoCopy

func GetControllerOfNoCopy(refs []metav1.OwnerReference) *metav1.OwnerReference

GetControllerOf returns a pointer to the controllerRef if controllee has a controller

func GetKubeContentFromPath

func GetKubeContentFromPath(kubePath string) ([]byte, error)

func GetNamespaceFromKubeConfig

func GetNamespaceFromKubeConfig(kubeConfig string) (string, error)

func GetYamlFilesAndDirs

func GetYamlFilesAndDirs(path string, ignorePaths []string) ([]string, []string, error)

Path can be a file or a dir

func IsNamespaced

func IsNamespaced(gvr schema.GroupVersionResource, mapper meta.RESTMapper) (bool, error)

func LoadValidManifest

func LoadValidManifest(path []string, ignorePaths ...[]string) []string

func Must

func Must(err error)

func MustI

func MustI(err error, s string)

func NewAuthCheckManager

func NewAuthCheckManager(kubeConfigPath string) *authCheckManager

func NewKustomizeResourceReader

func NewKustomizeResourceReader(path string) *kustomizeResourceReader

func NewManifestResourceReader

func NewManifestResourceReader(files []string) *manifestResourceReader

Types

type ApplyFlags

type ApplyFlags struct {

	// There is currently no need to delete labels, so similar support is not provided
	MergeableLabel      map[string]string
	MergeableAnnotation map[string]string

	// apply if set to true
	DoApply     bool
	BeforeApply func(string) error
}

func StandardNocalhostMetas

func StandardNocalhostMetas(releaseName, releaseNamespace string) *ApplyFlags

func (*ApplyFlags) SetBeforeApply

func (a *ApplyFlags) SetBeforeApply(fun func(string) error) *ApplyFlags

func (*ApplyFlags) SetDoApply

func (a *ApplyFlags) SetDoApply(doApply bool) *ApplyFlags

type AuthChecker

type AuthChecker struct {
	Verb        []string
	Name        string
	Version     string
	ResourceArg string
}

type ClientGoUtils

type ClientGoUtils struct {
	ClientSet *kubernetes.Clientset

	ClientConfig clientcmd.ClientConfig
	// contains filtered or unexported fields
}

func NewClientGoUtils

func NewClientGoUtils(kubeConfigPath string, namespace string) (*ClientGoUtils, error)

NewClientGoUtils If namespace is not specified, use namespace defined in kubeconfig If namespace is not specified and can not get from kubeconfig, return error

func (*ClientGoUtils) AddClusterRoleToRoleBinding

func (c *ClientGoUtils) AddClusterRoleToRoleBinding(roleBinding, clusterRole, serviceAccount string) error

func (*ClientGoUtils) Apply

func (c *ClientGoUtils) Apply(files []string, continueOnError bool, flags *ApplyFlags, kustomize string) error

func (*ClientGoUtils) ApplyAndWait

func (c *ClientGoUtils) ApplyAndWait(files []string, continueOnError bool, flags *ApplyFlags) error

func (*ClientGoUtils) ApplyAndWaitFor

func (c *ClientGoUtils) ApplyAndWaitFor(manifests string, continueOnError bool, flags *ApplyFlags) error

func (*ClientGoUtils) ApplyResourceInfo

func (c *ClientGoUtils) ApplyResourceInfo(info *resource.Info, af *ApplyFlags) error

Similar to `kubectl apply`, but apply a resourceInfo instead a file

func (*ClientGoUtils) CheckDeploymentReady

func (c *ClientGoUtils) CheckDeploymentReady(name string) (bool, error)

func (*ClientGoUtils) CheckExistNameSpace

func (c *ClientGoUtils) CheckExistNameSpace(name string) error

func (*ClientGoUtils) Context

func (c *ClientGoUtils) Context(ctx context.Context) *ClientGoUtils

Context Set ClientGoUtils's Context

func (*ClientGoUtils) CreateAdminClusterRole

func (c *ClientGoUtils) CreateAdminClusterRole(name string) (*v1.ClusterRole, error)

func (*ClientGoUtils) CreateAdminClusterRoleINE

func (c *ClientGoUtils) CreateAdminClusterRoleINE(name string) (*v1.ClusterRole, error)

func (*ClientGoUtils) CreateClusterRole

func (c *ClientGoUtils) CreateClusterRole(name string, rule []rbacv1.PolicyRule) (*v1.ClusterRole, error)

func (*ClientGoUtils) CreateDeployment

func (c *ClientGoUtils) CreateDeployment(deploy *v1.Deployment) (*v1.Deployment, error)

func (*ClientGoUtils) CreateDeploymentAndWait

func (c *ClientGoUtils) CreateDeploymentAndWait(deployment *v1.Deployment) (*v1.Deployment, error)

func (*ClientGoUtils) CreateJob

func (c *ClientGoUtils) CreateJob(job *batchv1.Job) (*batchv1.Job, error)

func (*ClientGoUtils) CreateNameSpace

func (c *ClientGoUtils) CreateNameSpace(name string) error

func (*ClientGoUtils) CreateNamespaceINE

func (c *ClientGoUtils) CreateNamespaceINE(ns string) error

func (*ClientGoUtils) CreatePVC

func (c *ClientGoUtils) CreatePVC(
	name string, labels map[string]string, annotations map[string]string, quantityStr string, storageClassName *string,
) (*v1.PersistentVolumeClaim, error)

quantityStr: 10Gi, 10Mi ... storageClassName: nil to use default storageClassName

func (*ClientGoUtils) CreatePod

func (c *ClientGoUtils) CreatePod(pod *corev1.Pod) (*corev1.Pod, error)

func (*ClientGoUtils) CreatePortForwarder

func (c *ClientGoUtils) CreatePortForwarder(pod string, fps []*ForwardPort, readyChan, stopChan chan struct{}, g genericclioptions.IOStreams) (*PortForwarder, error)

func (*ClientGoUtils) CreateRoleBindingWithClusterRole

func (c *ClientGoUtils) CreateRoleBindingWithClusterRole(name, clusterRoleName string) (*v1.RoleBinding, error)

func (*ClientGoUtils) CreateRoleBindingWithClusterRoleINE

func (c *ClientGoUtils) CreateRoleBindingWithClusterRoleINE(name, clusterRoleName string) (*v1.RoleBinding, error)

func (*ClientGoUtils) CreateSecret

func (c *ClientGoUtils) CreateSecret(secret *corev1.Secret, options metav1.CreateOptions) (*corev1.Secret, error)

func (*ClientGoUtils) CreateServiceAccount

func (c *ClientGoUtils) CreateServiceAccount(name string) (*corev1.ServiceAccount, error)

func (*ClientGoUtils) CreateServiceAccountINE

func (c *ClientGoUtils) CreateServiceAccountINE(name string) (*corev1.ServiceAccount, error)

func (*ClientGoUtils) CreateStatefulSet

func (c *ClientGoUtils) CreateStatefulSet(s *v1.StatefulSet) (*v1.StatefulSet, error)

func (*ClientGoUtils) CreateStatefulSetAndWait

func (c *ClientGoUtils) CreateStatefulSetAndWait(s *v1.StatefulSet) (*v1.StatefulSet, error)

func (*ClientGoUtils) Delete

func (c *ClientGoUtils) Delete(files []string, continueOnError bool, flags *ApplyFlags, kustomize string) error

useless temporally

func (*ClientGoUtils) DeleteConfigMapByName

func (c *ClientGoUtils) DeleteConfigMapByName(name string) error

func (*ClientGoUtils) DeleteDeployment

func (c *ClientGoUtils) DeleteDeployment(name string, wait bool) error

func (*ClientGoUtils) DeleteEvent

func (c *ClientGoUtils) DeleteEvent(name string) error

func (*ClientGoUtils) DeleteEvents

func (c *ClientGoUtils) DeleteEvents(evs []corev1.Event, continueOnErr bool) error

func (*ClientGoUtils) DeleteJob

func (c *ClientGoUtils) DeleteJob(name string) error

func (*ClientGoUtils) DeleteNameSpace

func (c *ClientGoUtils) DeleteNameSpace(name string, wait bool) error

func (*ClientGoUtils) DeletePVC

func (c *ClientGoUtils) DeletePVC(name string) error

func (*ClientGoUtils) DeletePod

func (c *ClientGoUtils) DeletePod(podName string, wait bool, duration time.Duration) error

func (*ClientGoUtils) DeletePodByName

func (c *ClientGoUtils) DeletePodByName(name string, gracePeriodSeconds int64) error

DeletePodByName gracePeriodSeconds: The duration in seconds before the object should be deleted. The value zero indicates delete immediately. If this value is negative integer, the default grace period for the specified type will be used.

func (*ClientGoUtils) DeleteSecret

func (c *ClientGoUtils) DeleteSecret(name string) error

func (*ClientGoUtils) DeleteStatefulSet

func (c *ClientGoUtils) DeleteStatefulSet(name string) error

func (*ClientGoUtils) DeleteStatefulSetAndPVC

func (c *ClientGoUtils) DeleteStatefulSetAndPVC(name string) error

func (*ClientGoUtils) Discovery

func (c *ClientGoUtils) Discovery()

func (*ClientGoUtils) Exec

func (c *ClientGoUtils) Exec(podName string, containerName string, command []string) error

func (*ClientGoUtils) ExecShell

func (c *ClientGoUtils) ExecShell(podName string, containerName string, shell, banner string) error

func (*ClientGoUtils) FieldSelector

func (c *ClientGoUtils) FieldSelector(f string) *ClientGoUtils

func (*ClientGoUtils) Forward

func (c *ClientGoUtils) Forward(pod string, localPort, remotePort int, readyChan, stopChan chan struct{}, g genericclioptions.IOStreams) error

func (*ClientGoUtils) ForwardPortForwardByPod

func (c *ClientGoUtils) ForwardPortForwardByPod(pod string, localPort, remotePort int, readyChan, stopChan chan struct{}, g genericclioptions.IOStreams) error

func (*ClientGoUtils) Get

func (c *ClientGoUtils) Get(resourceType string, resourceName string) (*runtime.Object, error)

func (*ClientGoUtils) GetAPIGroupResources

func (c *ClientGoUtils) GetAPIGroupResources() ([]*restmapper.APIGroupResources, error)

func (*ClientGoUtils) GetClusterRole

func (c *ClientGoUtils) GetClusterRole(name string) (*v1.ClusterRole, error)

func (*ClientGoUtils) GetConfigMaps

func (c *ClientGoUtils) GetConfigMaps(name string) (*v1.ConfigMap, error)

func (*ClientGoUtils) GetContext

func (c *ClientGoUtils) GetContext() context.Context

func (*ClientGoUtils) GetCopy

func (c *ClientGoUtils) GetCopy() *ClientGoUtils

func (*ClientGoUtils) GetCronJobs

func (c *ClientGoUtils) GetCronJobs(name string) (*v1beta1.CronJob, error)

func (*ClientGoUtils) GetCronJobsClient

func (c *ClientGoUtils) GetCronJobsClient() batchV1beta1.CronJobInterface

func (*ClientGoUtils) GetDaemonSet

func (c *ClientGoUtils) GetDaemonSet(name string) (*v1.DaemonSet, error)

func (*ClientGoUtils) GetDaemonSetClient

func (c *ClientGoUtils) GetDaemonSetClient() appsV1.DaemonSetInterface

func (*ClientGoUtils) GetDefaultNamespace

func (c *ClientGoUtils) GetDefaultNamespace() (string, error)

func (*ClientGoUtils) GetDeployment

func (c *ClientGoUtils) GetDeployment(name string) (*v1.Deployment, error)

func (*ClientGoUtils) GetDeploymentClient

func (c *ClientGoUtils) GetDeploymentClient() appsV1.DeploymentInterface

func (*ClientGoUtils) GetDiscoveryClient

func (c *ClientGoUtils) GetDiscoveryClient() (*discovery.DiscoveryClient, error)

func (*ClientGoUtils) GetDynamicClient

func (c *ClientGoUtils) GetDynamicClient() dynamic.Interface

func (*ClientGoUtils) GetJobs

func (c *ClientGoUtils) GetJobs(name string) (*batchv1.Job, error)

func (*ClientGoUtils) GetJobsClient

func (c *ClientGoUtils) GetJobsClient() batchV1.JobInterface

func (*ClientGoUtils) GetNameSpace

func (c *ClientGoUtils) GetNameSpace() string

func (*ClientGoUtils) GetNodesList

func (c *ClientGoUtils) GetNodesList() (*corev1.NodeList, error)

func (*ClientGoUtils) GetPod

func (c *ClientGoUtils) GetPod(name string) (*corev1.Pod, error)

func (*ClientGoUtils) GetPodClient

func (c *ClientGoUtils) GetPodClient() coreV1.PodInterface

func (*ClientGoUtils) GetPvcByLabels

func (c *ClientGoUtils) GetPvcByLabels(labels map[string]string) ([]v1.PersistentVolumeClaim, error)

func (*ClientGoUtils) GetPvcByName

func (c *ClientGoUtils) GetPvcByName(name string) (*v1.PersistentVolumeClaim, error)

func (*ClientGoUtils) GetReplicaSetsByDeployment

func (c *ClientGoUtils) GetReplicaSetsByDeployment(deploymentName string) (map[int]*v1.ReplicaSet, error)

func (*ClientGoUtils) GetResourceInfo

func (c *ClientGoUtils) GetResourceInfo(resourceType string, resourceName string) (*resource.Info, error)

func (*ClientGoUtils) GetResourceInfoFromReader

func (c *ClientGoUtils) GetResourceInfoFromReader(reader io.Reader, continueOnError bool) ([]*resource.Info, error)

func (*ClientGoUtils) GetResourceInfoFromString

func (c *ClientGoUtils) GetResourceInfoFromString(str string, continueOnError bool) ([]*resource.Info, error)

GetResourceInfoFromString Str is in json format (Can be a yaml ?)

func (*ClientGoUtils) GetResourcesByRestClient

func (c *ClientGoUtils) GetResourcesByRestClient(
	gv *schema.GroupVersion, resource string, result runtime.Object,
) error

if namespace is empty, use "default" namespace

func (*ClientGoUtils) GetRestClient

func (c *ClientGoUtils) GetRestClient(gv *schema.GroupVersion) (*rest.RESTClient, error)

func (*ClientGoUtils) GetSecret

func (c *ClientGoUtils) GetSecret(name string) (*corev1.Secret, error)

func (*ClientGoUtils) GetService

func (c *ClientGoUtils) GetService(name string) (*corev1.Service, error)

func (*ClientGoUtils) GetServiceAccount

func (c *ClientGoUtils) GetServiceAccount(name string) (*corev1.ServiceAccount, error)

func (*ClientGoUtils) GetSortedReplicaSetsByDeployment

func (c *ClientGoUtils) GetSortedReplicaSetsByDeployment(deployment string) ([]*v1.ReplicaSet, error)

func (*ClientGoUtils) GetStatefulSet

func (c *ClientGoUtils) GetStatefulSet(name string) (*v1.StatefulSet, error)

func (*ClientGoUtils) GetStatefulSetClient

func (c *ClientGoUtils) GetStatefulSetClient() appsV1.StatefulSetInterface

func (*ClientGoUtils) GetUnstructured

func (c *ClientGoUtils) GetUnstructured(resourceType string, resourceName string) (*unstructured.Unstructured, error)

func (*ClientGoUtils) GetUnstructuredFromString

func (c *ClientGoUtils) GetUnstructuredFromString(str string) (*unstructured.Unstructured, error)

func (*ClientGoUtils) IncludeDeletedResources

func (c *ClientGoUtils) IncludeDeletedResources(i bool) *ClientGoUtils

func (*ClientGoUtils) IsClusterAdmin

func (c *ClientGoUtils) IsClusterAdmin() bool

IsClusterAdmin judge weather is cluster scope kubeconfig or not

func (*ClientGoUtils) KindFor

func (*ClientGoUtils) KubeConfigFilePath

func (c *ClientGoUtils) KubeConfigFilePath() string

func (*ClientGoUtils) Labels

func (c *ClientGoUtils) Labels(labels map[string]string) *ClientGoUtils

func (*ClientGoUtils) ListConfigMaps

func (c *ClientGoUtils) ListConfigMaps() ([]v1.ConfigMap, error)

func (*ClientGoUtils) ListDaemonSets

func (c *ClientGoUtils) ListDaemonSets() ([]v1.DaemonSet, error)

func (*ClientGoUtils) ListDeployments

func (c *ClientGoUtils) ListDeployments() ([]v1.Deployment, error)

func (*ClientGoUtils) ListEvents

func (c *ClientGoUtils) ListEvents() ([]corev1.Event, error)

func (*ClientGoUtils) ListEventsByReplicaSet

func (c *ClientGoUtils) ListEventsByReplicaSet(rsName string) ([]corev1.Event, error)

func (*ClientGoUtils) ListEventsByStatefulSet

func (c *ClientGoUtils) ListEventsByStatefulSet(name string) ([]corev1.Event, error)

func (*ClientGoUtils) ListHPA

func (*ClientGoUtils) ListJobs

func (c *ClientGoUtils) ListJobs() (*batchv1.JobList, error)

func (*ClientGoUtils) ListLatestRevisionPodsByDeployment

func (c *ClientGoUtils) ListLatestRevisionPodsByDeployment(deployName string) ([]corev1.Pod, error)

func (*ClientGoUtils) ListPods

func (c *ClientGoUtils) ListPods() ([]corev1.Pod, error)

func (*ClientGoUtils) ListPodsByCronJob

func (c *ClientGoUtils) ListPodsByCronJob(name string) (*corev1.PodList, error)

ListPodsByCronJob This method can not list pods whose deployment is already deleted.

func (*ClientGoUtils) ListPodsByDaemonSet

func (c *ClientGoUtils) ListPodsByDaemonSet(name string) ([]corev1.Pod, error)

func (*ClientGoUtils) ListPodsByDeployment

func (c *ClientGoUtils) ListPodsByDeployment(name string) (*corev1.PodList, error)

ListPodsByDeployment This method can not list pods whose deployment is already deleted.

func (*ClientGoUtils) ListPodsByJob

func (c *ClientGoUtils) ListPodsByJob(name string) (*corev1.PodList, error)

This method can not list pods whose deployment is already deleted.

func (*ClientGoUtils) ListPodsByLabels

func (c *ClientGoUtils) ListPodsByLabels(labelMap map[string]string) ([]corev1.Pod, error)

func (*ClientGoUtils) ListPodsByStatefulSet

func (c *ClientGoUtils) ListPodsByStatefulSet(name string) (*corev1.PodList, error)

func (*ClientGoUtils) ListPodsOfDeployment

func (c *ClientGoUtils) ListPodsOfDeployment(deployName string) ([]corev1.Pod, error)

func (*ClientGoUtils) ListPvcs

func (c *ClientGoUtils) ListPvcs() ([]v1.PersistentVolumeClaim, error)

func (*ClientGoUtils) ListResourceInfo

func (c *ClientGoUtils) ListResourceInfo(resourceType string) ([]*resource.Info, error)

func (*ClientGoUtils) ListStatefulSets

func (c *ClientGoUtils) ListStatefulSets() ([]v1.StatefulSet, error)

func (*ClientGoUtils) NameSpace

func (c *ClientGoUtils) NameSpace(namespace string) *ClientGoUtils

NameSpace Set ClientGoUtils's namespace

func (*ClientGoUtils) NewFactory

func (c *ClientGoUtils) NewFactory() cmdutil.Factory

func (*ClientGoUtils) Patch

func (c *ClientGoUtils) Patch(resourceType string, name string, patchContent string, pathType string) error

func (*ClientGoUtils) ResourceFor

func (c *ClientGoUtils) ResourceFor(resourceArg string, tryLoadFromCache bool) schema.GroupVersionResource

func (*ClientGoUtils) ResourceForGVK

func (*ClientGoUtils) ScaleDeploymentReplicasToOne

func (c *ClientGoUtils) ScaleDeploymentReplicasToOne(name string) error

func (*ClientGoUtils) ScaleStatefulSetReplicasToOne

func (c *ClientGoUtils) ScaleStatefulSetReplicasToOne(name string) error

func (*ClientGoUtils) SearchEvents

func (c *ClientGoUtils) SearchEvents(objOrRef runtime.Object) (*corev1.EventList, error)

func (*ClientGoUtils) UpdateConfigMaps

func (c *ClientGoUtils) UpdateConfigMaps(cm *v1.ConfigMap) (*v1.ConfigMap, error)

func (*ClientGoUtils) UpdateCronJob

func (c *ClientGoUtils) UpdateCronJob(cj *batchv1beta1.CronJob) (*batchv1beta1.CronJob, error)

func (*ClientGoUtils) UpdateDaemonSet

func (c *ClientGoUtils) UpdateDaemonSet(ds *v1.DaemonSet) (*v1.DaemonSet, error)

func (*ClientGoUtils) UpdateDeployment

func (c *ClientGoUtils) UpdateDeployment(deployment *v1.Deployment, wait bool) (*v1.Deployment, error)

UpdateDeployment Update deployment If wait, UpdateDeployment will not return until: 1. Deployment is ready 2. Previous revision of ReplicaSet terminated 3. Latest revision of ReplicaSet is ready After update, UpdateDeployment will clean up previous revision's events If Latest revision of ReplicaSet fails to be ready, return err

func (*ClientGoUtils) UpdatePod

func (c *ClientGoUtils) UpdatePod(pod *corev1.Pod) (*corev1.Pod, error)

func (*ClientGoUtils) UpdateReplicaSet

func (c *ClientGoUtils) UpdateReplicaSet(rs *v1.ReplicaSet) (*v1.ReplicaSet, error)

func (*ClientGoUtils) UpdateSecret

func (c *ClientGoUtils) UpdateSecret(secret *corev1.Secret, options metav1.UpdateOptions) (*corev1.Secret, error)

func (*ClientGoUtils) UpdateStatefulSet

func (c *ClientGoUtils) UpdateStatefulSet(statefulSet *v1.StatefulSet, wait bool) (*v1.StatefulSet, error)

func (*ClientGoUtils) WaitDeploymentToBeReady

func (c *ClientGoUtils) WaitDeploymentToBeReady(name string) error

func (*ClientGoUtils) WaitForResourceReady

func (c *ClientGoUtils) WaitForResourceReady(
	resourceType ResourceType, name string, isReady func(object runtime.Object) (bool, error),
) error

func (*ClientGoUtils) WaitJobToBeReady

func (c *ClientGoUtils) WaitJobToBeReady(name, format string) error

func (*ClientGoUtils) WaitLatestRevisionReady

func (c *ClientGoUtils) WaitLatestRevisionReady(deploymentName string) error

WaitLatestRevisionReplicaSetOfDeploymentToBeReady

func (*ClientGoUtils) WaitStatefulSetToBeReady

func (c *ClientGoUtils) WaitStatefulSetToBeReady(name string) error

type ClientgoPortForwarder

type ClientgoPortForwarder struct {
	genericclioptions.IOStreams
	// contains filtered or unexported fields
}

func (*ClientgoPortForwarder) ForwardPorts

func (f *ClientgoPortForwarder) ForwardPorts(method string, url *url.URL, opts portforward.PortForwardOptions) error

func (ClientgoPortForwarder) GetPorts

func (f ClientgoPortForwarder) GetPorts() ([]ForwardedPort, error)

type ErrorType

type ErrorType string
const (
	InvalidYaml ErrorType = "InvalidYaml"
)

type ForwardPort

type ForwardPort struct {
	LocalPort  int
	RemotePort int
}

type ForwardedPort

type ForwardedPort struct {
	Local  uint16
	Remote uint16
}

ForwardedPort contains a Local:Remote port pairing.

type PortForwardAPodRequest

type PortForwardAPodRequest struct {
	// listenAddress
	Listen []string
	// Pod is the selected pod for this port forwarding
	Pod corev1.Pod
	// LocalPort is the local port that will be selected to expose the PodPort
	LocalPort int
	// PodPort is the target port for the pod
	PodPort int
	// Steams configures where to write or read input from
	Streams genericclioptions.IOStreams
	// StopCh is the channel used to manage the port forward lifecycle
	StopCh <-chan struct{}
	// ReadyCh communicates when the tunnel is ready to receive traffic
	ReadyCh chan struct{}
}

type PortForwardFlags

type PortForwardFlags struct {
	ResourcesName string // eg: "pod/pod-01", "deployment/d1"
	ForwardPort   string // eg: 1110:1110, :1234
	Streams       genericclioptions.IOStreams
	StopChannel   chan struct{}
	ReadyChannel  chan struct{}
}

type PortForwarder

type PortForwarder struct {
	Ready chan struct{}
	// contains filtered or unexported fields
}

PortForwarder knows how to listen for local connections and forward them to a remote pod via an upgraded HTTP request.

func New

func New(dialer httpstream.Dialer, ports []string, stopChan <-chan struct{}, readyChan chan struct{}, out, errOut io.Writer) (*PortForwarder, error)

New creates a new PortForwarder with localhost listen addresses.

func NewOnAddresses

func NewOnAddresses(dialer httpstream.Dialer, addresses []string, ports []string, stopChan <-chan struct{}, readyChan chan struct{}, out, errOut io.Writer) (*PortForwarder, error)

NewOnAddresses creates a new PortForwarder with custom listen addresses.

func (*PortForwarder) Close

func (pf *PortForwarder) Close()

Close stops all listeners of PortForwarder.

func (*PortForwarder) ForwardPorts

func (pf *PortForwarder) ForwardPorts() error

ForwardPorts formats and executes a port forwarding request. The connection will remain open until stopChan is closed.

func (*PortForwarder) GetPorts

func (pf *PortForwarder) GetPorts() ([]ForwardedPort, error)

GetPorts will return the ports that were forwarded; this can be used to retrieve the locally-bound port in cases where the input was port 0. This function will signal an error if the Ready channel is nil or if the listeners are not ready yet; this function will succeed after the Ready channel has been closed.

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

func NewResourceFromStr

func NewResourceFromStr(manifest string) *Resource

func (Resource) Append

func (r Resource) Append(s string)

func (*Resource) GetResourceInfo

func (r *Resource) GetResourceInfo(c *ClientGoUtils, continueOnError bool) ([]*resource.Info, error)

func (Resource) String

func (r Resource) String() string

type ResourceList

type ResourceList []*resource.Info

ResourceList provides convenience methods for comparing collections of Infos.

func (*ResourceList) Append

func (r *ResourceList) Append(val *resource.Info)

Append adds an Info to the Result.

func (ResourceList) Contains

func (r ResourceList) Contains(info *resource.Info) bool

Contains checks to see if an object exists.

func (ResourceList) Difference

func (r ResourceList) Difference(rs ResourceList) ResourceList

Difference will return a new Result with objects not contained in rs.

func (ResourceList) Filter

func (r ResourceList) Filter(fn func(*resource.Info) bool) ResourceList

Filter returns a new Result with Infos that satisfy the predicate fn.

func (ResourceList) Get

func (r ResourceList) Get(info *resource.Info) *resource.Info

Get returns the Info from the result that matches the name and kind.

func (ResourceList) Intersect

func (r ResourceList) Intersect(rs ResourceList) ResourceList

Intersect will return a new Result with objects contained in both Results.

func (ResourceList) Visit

func (r ResourceList) Visit(fn resource.VisitorFunc) error

Visit implements resource.Visitor.

func (ResourceList) Visits

func (r ResourceList) Visits(fns []resource.VisitorFunc) error

Visit implements resource.Visitor.

type ResourceReader

type ResourceReader interface {
	LoadResource() (*Resource, error)
}

type ResourceType

type ResourceType string
const (
	JobType         ResourceType = "jobs"
	DeploymentType  ResourceType = "deployments"
	StatefulSetType ResourceType = "statefulsets"
)

type TypedError

type TypedError struct {
	ErrorType ErrorType
	Mes       string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL