Commit a55eb17
committed
fix: panic with kubectl when timestamps are enabled (#7947)
Fixes a bug where using the `--timestamps` flag with `kubectl` deploy
panics with:
> error:panic: runtime error: slice bounds out of range
With timestamps enabled, `skaffoldWriter.Write` includes the length of
the timestamp in its return value. But `Writer` implementations should
return the number of bytes _consumed_, not written. This results in
`textio.PrefixWriter`[^1] writing `N` bytes to its buffer and then
discarding `N+len(timestamp)` bytes, causing a panic.
[^1]: Used by `pkg/skaffold/deploy/kubectl/kubectl.go`
Relevant `textio.PrefixWriter` source code (ref:
https://github.com/segmentio/textio/blob/master/prefix.go#L54-L55):
```go
c, err = w.writeLine(chunk)
w.discard(c)
```
Fixes: #79471 parent fdf5579 commit a55eb17
2 files changed
Lines changed: 14 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
42 | 44 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 45 | + | |
| 46 | + | |
46 | 47 | | |
47 | | - | |
48 | | - | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
| |||
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | | - | |
60 | | - | |
61 | 58 | | |
62 | 59 | | |
63 | | - | |
| 60 | + | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
171 | 177 | | |
172 | 178 | | |
173 | 179 | | |
0 commit comments