Fix GracePeriodSeconds (#1739)

`var x int64` means the value is 0 rather than the intended nil
(default).

`Delete` doesn't provide a way to configure the grace period anyway so
remove the variable and only override on a `force`

Co-authored-by: Phil Kates <phil.kates@cartacapitalmarkets.com>
mine
Phil Kates 2022-09-18 10:09:16 -04:00 committed by GitHub
parent ea18aec512
commit 403cc63ddd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -98,14 +98,13 @@ func (g *Generic) Delete(ctx context.Context, path string, propagation *metav1.D
return fmt.Errorf("user is not authorized to delete %s", path)
}
const defaultKillGrace = 1
var grace int64
if force {
grace = defaultKillGrace
}
opts := metav1.DeleteOptions{
PropagationPolicy: propagation,
GracePeriodSeconds: &grace,
PropagationPolicy: propagation,
}
if force {
var defaultKillGrace int64 = 1
opts.GracePeriodSeconds = &defaultKillGrace
}
dial, err := g.dynClient()