Documentation
¶
Index ¶
- Constants
- Variables
- func CreateK8sClient(p Params) IOE.IOEither[error, kubernetes.Interface]
- func FetchJob(ctx PollContext) IOE.IOEither[error, PollContext]
- func FetchPods(ctx PollContext) IOE.IOEither[error, *corev1.PodList]
- func FindStuckReason(pods *corev1.PodList) O.Option[string]
- func JobAction(c *cli.Context) error
- type JobState
- type Params
- type PollContext
- type WithClient
Constants ¶
const PollInterval = 5 * time.Second
PollInterval is the delay between polling cycles.
Variables ¶
var SetClient = F.Curry2(func(c kubernetes.Interface, p Params) WithClient { return WithClient{Params: p, Client: c} })
SetClient is a curried setter used with IOE.Bind to inject the K8s client.
var SetPollReady = F.Curry2(func(deadline time.Time, c WithClient) PollContext { return PollContext{ WithClient: c, Deadline: deadline, State: JobPending, Condition: O.None[JobState](), } })
SetPollReady is a curried setter used with IOE.Let to attach the deadline. The Logger is preserved from Params.
Functions ¶
func CreateK8sClient ¶
CreateK8sClient builds a Kubernetes client from the kubeconfig path in Params. Falls back to in-cluster config when Kubeconfig is empty.
func FetchJob ¶
func FetchJob(ctx PollContext) IOE.IOEither[error, PollContext]
FetchJob retrieves the named Job from Kubernetes and stores it in ctx.Job.
func FindStuckReason ¶
FindStuckReason scans all pods and all containers for a known stuck reason. Returns Some(reason) on first match, None if all containers are healthy.
func JobAction ¶
JobAction is the urfave/cli v2 action for the wait-job subcommand.
Pipeline (8 steps):
- Build Params from CLI flags
- Inject Kubernetes client (Bind)
- Compute deadline and attach logger (Let)
- Run polling loop (returns PollContext with final State)
- Extract JobState from PollContext
- Execute IOEither effect → Either
- Validate terminal state (Complete → ok, else → error)
- Fold Either → error
Types ¶
type JobState ¶
type JobState string
JobState represents the observed state of a Kubernetes Job.
func ClassifyPodState ¶
ClassifyPodState returns JobStuck if any container is stuck, otherwise JobPending.
type Params ¶
type Params struct {
Name string
Namespace string
Timeout time.Duration
Kubeconfig string
Logger *slog.Logger
}
Params holds CLI-supplied parameters for the wait-job command.
type PollContext ¶
type PollContext struct {
WithClient
Deadline time.Time
Job *batchv1.Job
Condition O.Option[JobState]
State JobState
}
PollContext is the fully-enriched context used throughout the polling loop.
func ExtractJobCondition ¶
func ExtractJobCondition(ctx PollContext) PollContext
ExtractJobCondition reads ctx.Job, extracts the first terminal condition, and stores it in ctx.Condition.
type WithClient ¶
type WithClient struct {
Params
Client kubernetes.Interface
}
WithClient enriches Params with an injected Kubernetes client.