Documentation ¶
Index ¶
- func DescribeKubernetesResource(ctx context.Context, kc *client.KubernetesClient, ...) (string, error)
- func ExecKubernetesResources(params ExecParams) (string, error)
- func GetResourceStatus(ctx context.Context, kc *client.KubernetesClient, ...) (bool, error)
- func WaitForResourceState(ctx context.Context, ...) error
- type DefaultExecutorCreator
- type ExecParams
- type ExecutorCreator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DescribeKubernetesResource ¶
func DescribeKubernetesResource(ctx context.Context, kc *client.KubernetesClient, resourceName, namespace string, gvr schema.GroupVersionResource) (string, error)
DescribeKubernetesResource retrieves the details of a specific Kubernetes resource using the provided dynamic client, resource name, namespace, and GroupVersionResource (GVR).
**Parameters:**
ctx: The context to use for the request. kc: The KubernetesClient that includes both the standard and dynamic clients. resourceName: The name of the resource to describe. namespace: The namespace of the resource. gvr: The GroupVersionResource of the resource.
**Returns:**
string: A string representation of the resource, similar to `kubectl describe`. error: An error if any issue occurs while trying to describe the resource.
func ExecKubernetesResources ¶
func ExecKubernetesResources(params ExecParams) (string, error)
ExecKubernetesResources executes a command in a specified resource within a given namespace using the existing KubernetesClient.
**Parameters:**
ctx: The context to use for the request. kc: The KubernetesClient that includes both the standard and dynamic clients. namespace: The namespace of the resource where the pod is located. podName: The name of the pod to execute the command in. command: A slice of strings representing the command to execute inside the pod.
**Returns:**
string: The output from the executed command or an error message if execution fails. error: An error if any issue occurs during the setup or execution of the command.
func GetResourceStatus ¶
func GetResourceStatus(ctx context.Context, kc *client.KubernetesClient, resourceName, namespace string, gvr schema.GroupVersionResource) (bool, error)
GetResourceStatus checks the status of any Kubernetes resource.
**Parameters:**
ctx: A context.Context to control the operation. kc: The KubernetesClient that includes both the standard and dynamic clients. resourceName: The name of the resource being checked. namespace: The namespace of the resource. gvr: The schema.GroupVersionResource that specifies the resource type.
**Returns:**
bool: true if the resource status is 'Running', false otherwise. error: An error if the resource cannot be retrieved or the status is not found.
func WaitForResourceState ¶ added in v2.2.7
func WaitForResourceState(ctx context.Context, resourceName, namespace, resourceType, desiredState string, checkStatusFunc func(name, namespace string) (bool, error)) error
WaitForResourceState waits for a Kubernetes resource to reach a specified state.
**Parameters:**
ctx: A context.Context to allow for cancellation and timeouts. resourceName: The name of the resource to monitor. namespace: The namespace in which the resource exists. resourceType: The type of the resource (e.g., Pod, Service). desiredState: A string representing the desired state (e.g., "Running", "Deleted"). checkStatusFunc: A function that checks if the resource is in the desired state.
**Returns:**
error: An error if the waiting is cancelled by context, times out, or fails to determine the state.
Types ¶
type DefaultExecutorCreator ¶ added in v2.2.6
type DefaultExecutorCreator struct{}
DefaultExecutorCreator represents a struct that includes a method for creating a new SPDY executor.
func (*DefaultExecutorCreator) NewSPDYExecutor ¶ added in v2.2.6
func (dec *DefaultExecutorCreator) NewSPDYExecutor(config *rest.Config, method string, url *url.URL) (remotecommand.Executor, error)
NewSPDYExecutor creates a new SPDY executor given a configuration, method, and URL. It returns a remotecommand.Executor and an error.
**Parameters:**
config: A pointer to a rest.Config struct that includes the configuration for the executor. method: A string representing the HTTP method to use for the request. url: A pointer to a url.URL struct that includes the URL for the request.
**Returns:**
remotecommand.Executor: The created SPDY executor. error: An error if any issue occurs while creating the executor.
type ExecParams ¶ added in v2.2.6
type ExecParams struct { Context context.Context Client *client.KubernetesClient Namespace string PodName string Command []string Stdin io.Reader Stdout io.Writer Stderr io.Writer }
ExecParams contains all the parameters needed to execute a command in a Kubernetes pod.
**Attributes:**
Context: The context to use for the request. Client: The KubernetesClient that includes both the standard and dynamic clients. Namespace: The namespace of the resource where the pod is located. PodName: The name of the pod to execute the command in. Command: A slice of strings representing the command to execute inside the pod. Stdin: An io.Reader to use as the standard input for the command. Stdout: An io.Writer to use as the standard output for the command. Stderr: An io.Writer to use as the standard error for the command.
type ExecutorCreator ¶ added in v2.2.6
type ExecutorCreator interface { // NewSPDYExecutor creates a new SPDY executor given a configuration, // method, and URL. It returns a remotecommand.Executor and an error. // // **Parameters:** // // config: A pointer to a rest.Config struct that includes the configuration // for the executor. // method: A string representing the HTTP method to use for the request. // url: A pointer to a url.URL struct that includes the URL for the request. // // **Returns:** // // remotecommand.Executor: The created SPDY executor. // error: An error if any issue occurs while creating the executor. NewSPDYExecutor(config *rest.Config, method string, url *url.URL) (remotecommand.Executor, error) }
ExecutorCreator represents an interface that includes a method for creating a new SPDY executor.
**Methods:**
NewSPDYExecutor: Creates a new SPDY executor given a configuration, method, and URL.