kubectl/pkg/cmd/wait
Leoy 39dad5862b kubectl: use %w for error wrapping and remove redundant .Error() calls (#138223)
* kubectl: use %w for error wrapping and remove redundant .Error() calls

Replace fmt.Errorf with %s and err.Error() with idiomatic %w wrapping
in kubectl's polymorphichelpers, wait, and drain packages. This enables
proper error chain inspection via errors.Is/As and follows Go best
practices.

Also fixes a typo: "Statefulset" -> "StatefulSet" in history.go.

* Address review: use %w for error wrapping in extendErrWaitTimeout

Use fmt.Errorf with %w instead of %v to preserve the error chain,
allowing wait.Interrupted() to correctly detect timeout errors.

Signed-off-by: supermario_leo <leo.stack@outlook.com>

* Fix lint: wrap both errors with %w in cordon error path

The linter flags err used with %v when it is an error type. Since
Go 1.20+ supports multiple %w verbs in a single fmt.Errorf call,
wrap both err and patchErr to preserve both error chains.

Signed-off-by: supermario_leo <leo.stack@outlook.com>

---------

Signed-off-by: supermario_leo <leo.stack@outlook.com>

Kubernetes-commit: d916c320deb859cd264354c48f3bd5419f7a2950
2026-04-23 08:37:22 +08:00
..
condition.go kubectl: use %w for error wrapping and remove redundant .Error() calls (#138223) 2026-04-23 08:37:22 +08:00
create.go Add --for=create option to kubectl wait 2024-07-08 13:32:31 +02:00
delete.go When using kubectl to delete multiple sts pods simultaneously, it gets stuck and won't exit 2025-12-03 12:39:32 +08:00
json.go kubectl wait: split condition functions into separate files 2024-07-03 11:27:08 +02:00
wait.go kubectl wait: Support multiple conditions (#136855) 2026-03-04 21:00:27 +03:00
wait_test.go Check wait condition type cast to avoid potential panic 2026-03-05 18:41:52 -05:00