Documentation
¶
Index ¶
- func GetKubeConfigPath() (string, bool)
- type Client
- func (c *Client) ApplyManifest(obj *unstructured.Unstructured, source string, fallbackNamespace string) error
- func (c *Client) ApplyManifestFromFile(path string, fallbackNamespace string) (int, error)
- func (c *Client) ApplyManifestFromString(manifest string, fallbackNamespace string) (int, error)
- func (c *Client) CheckIfResourceExists(gvr schema.GroupVersionResource, namespace string, name string) (bool, error)
- func (c *Client) CreateNamespace(namespace string) (bool, error)
- func (c *Client) DeleteAllApplicationsOlderThan(namespace string, minutes int) error
- func (c *Client) DeleteArgoCDApplication(namespace string, name string) error
- func (c *Client) DeleteArgoCDApplications(namespace string) error
- func (c *Client) GetArgoCDApplication(namespace string, name string) (*v1alpha1.Application, error)
- func (c *Client) GetConfig() *rest.Config
- func (c *Client) GetConfigMaps(namespace string, names ...string) (string, error)
- func (c *Client) GetListOfNamespacedScopedResources() (map[schema.GroupKind]bool, error)
- func (c *Client) GetSecretValue(namespace string, name string, key string) (string, error)
- func (c *Client) GetServiceNameByLabel(namespace, labelSelector string) (string, error)
- func (c *Client) PortForwardToPod(namespace, podName string, localPort, remotePort int, readyChan chan struct{}, ...) error
- func (c *Client) PortForwardToService(namespace, serviceName string, localPort, remotePort int, ...) error
- func (c *Client) RemoveObstructiveFinalizers(namespace string) error
- func (c *Client) SetArgoCDAppRefreshAnnotation(namespace string, name string) error
- func (c *Client) WaitForDeploymentReady(namespace, labelSelector string, timeoutSeconds int) error
- func (c *Client) WatchForContainerRestarts(namespace, labelSelector string, pollInterval time.Duration) chan struct{}
- type CrashEvent
- type CrashWatcherState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetKubeConfigPath ¶ added in v0.1.27
GetKubeConfigPath returns the path to the kubeconfig file and a boolean indicating if the file exists
Types ¶
type Client ¶ added in v0.1.27
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ApplyManifest ¶ added in v0.1.27
func (c *Client) ApplyManifest(obj *unstructured.Unstructured, source string, fallbackNamespace string) error
Helper function to apply a single manifest from an unstructured object
func (*Client) ApplyManifestFromFile ¶ added in v0.1.27
ApplyManifestFromFile applies a Kubernetes manifest from a file
func (*Client) ApplyManifestFromString ¶ added in v0.1.27
func (*Client) CheckIfResourceExists ¶ added in v0.1.27
func (*Client) CreateNamespace ¶ added in v0.1.27
create namespace. Returns true if the namespace was created, false if it already existed.
func (*Client) DeleteAllApplicationsOlderThan ¶ added in v0.1.27
DeleteAllApplicationsOlderThan deletes all ArgoCD applications older than a given number of minutes and matching the given label key
func (*Client) DeleteArgoCDApplication ¶ added in v0.1.27
DeleteArgoCDApplication deletes a single ArgoCD application by name
func (*Client) DeleteArgoCDApplications ¶ added in v0.1.27
func (*Client) GetArgoCDApplication ¶ added in v0.1.27
GetArgoCDApplication gets a single ArgoCD application by name
func (*Client) GetConfigMaps ¶ added in v0.1.27
func (*Client) GetListOfNamespacedScopedResources ¶ added in v0.1.27
GetListOfNamespacedScopedResources returns metadata about all namespaced resource types Returns a map where the key is schema.GroupKind and the value is true (indicating the resource is namespaced) This format matches the interface expected by Argo CD's kubeutil.ResourceInfoProvider
func (*Client) GetSecretValue ¶ added in v0.1.27
get secret value from key. e.g. key: "password"
func (*Client) GetServiceNameByLabel ¶ added in v0.1.27
GetServiceNameByLabel finds a service in the namespace with the specified label selector Returns the name of the first matching service, or an error if no service is found
func (*Client) PortForwardToPod ¶ added in v0.1.27
func (c *Client) PortForwardToPod(namespace, podName string, localPort, remotePort int, readyChan chan struct{}, stopChan chan struct{}) error
PortForwardToPod sets up a port forward to a pod in the specified namespace Returns a channel that will be closed when the port forward is ready, a stop channel to terminate the forward, and an error if the setup fails
func (*Client) PortForwardToService ¶ added in v0.1.27
func (c *Client) PortForwardToService(namespace, serviceName string, localPort, remotePort int, readyChan chan struct{}, stopChan chan struct{}) error
PortForwardToService sets up a port forward to a service by finding a pod for that service Returns a channel that will be closed when the port forward is ready, a stop channel to terminate the forward, and an error if the setup fails
func (*Client) RemoveObstructiveFinalizers ¶ added in v0.1.27
RemoveObstructiveFinalizers removes finalizers from applications that would prevent deletion
func (*Client) SetArgoCDAppRefreshAnnotation ¶ added in v0.1.27
SetArgoCDAppRefreshAnnotation sets the refresh annotation on an ArgoCD application to trigger a refresh
func (*Client) WaitForDeploymentReady ¶ added in v0.1.27
WaitForDeploymentReady waits for a deployment to be available Uses the provided label selector to find the deployment (e.g., "app.kubernetes.io/component=server")
func (*Client) WatchForContainerRestarts ¶ added in v0.1.27
func (c *Client) WatchForContainerRestarts(namespace, labelSelector string, pollInterval time.Duration) chan struct{}
WatchForContainerRestarts starts a background goroutine that monitors pods matching the given label selector for container restarts. It logs a warning whenever a container's restart count increases or when a container enters CrashLoopBackOff. Close the returned channel to stop watching.
type CrashEvent ¶ added in v0.1.27
type CrashEvent struct {
PodName string
ContainerName string
EventType string // "restart" or "crash-loop"
PrevRestarts int32 // only set for "restart" events
CurrRestarts int32 // only set for "restart" events
}
CrashEvent represents a single crash event detected by the watcher.
type CrashWatcherState ¶ added in v0.1.27
type CrashWatcherState struct {
// RestartCounts tracks "podName/containerName" -> last seen restart count
RestartCounts map[string]int32
// CrashLoopReported tracks whether we've already warned about CrashLoopBackOff for a given key
CrashLoopReported map[string]bool
}
CrashWatcherState tracks restart counts and CrashLoopBackOff state across polls for the container crash watcher. Exported for testability.
func NewCrashWatcherState ¶ added in v0.1.27
func NewCrashWatcherState() *CrashWatcherState
NewCrashWatcherState creates a new CrashWatcherState with initialized maps.
func (*CrashWatcherState) DetectCrashEvents ¶ added in v0.1.27
func (s *CrashWatcherState) DetectCrashEvents(pods []corev1.Pod) []CrashEvent
DetectCrashEvents inspects container statuses from a list of pods and returns any new crash events (restarts or CrashLoopBackOff) since the last poll. It updates the state in-place so subsequent calls only report new events.