Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: honor defaults from drain dialog in request #2239

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions internal/view/drain_dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const drainKey = "drain"
type DrainFunc func(v ResourceViewer, path string, opts dao.DrainOptions)

// ShowDrain pops a node drain dialog.
func ShowDrain(view ResourceViewer, path string, defaults dao.DrainOptions, okFn DrainFunc) {
func ShowDrain(view ResourceViewer, path string, opts dao.DrainOptions, okFn DrainFunc) {
styles := view.App().Styles

f := tview.NewForm()
Expand All @@ -26,8 +26,7 @@ func ShowDrain(view ResourceViewer, path string, defaults dao.DrainOptions, okFn
SetLabelColor(styles.K9s.Info.FgColor.Color()).
SetFieldTextColor(styles.K9s.Info.SectionColor.Color())

var opts dao.DrainOptions
f.AddInputField("GracePeriod:", strconv.Itoa(defaults.GracePeriodSeconds), 0, nil, func(v string) {
f.AddInputField("GracePeriod:", strconv.Itoa(opts.GracePeriodSeconds), 0, nil, func(v string) {
a, err := asIntOpt(v)
if err != nil {
view.App().Flash().Err(err)
Expand All @@ -36,7 +35,7 @@ func ShowDrain(view ResourceViewer, path string, defaults dao.DrainOptions, okFn
view.App().Flash().Clear()
opts.GracePeriodSeconds = a
})
f.AddInputField("Timeout:", defaults.Timeout.String(), 0, nil, func(v string) {
f.AddInputField("Timeout:", opts.Timeout.String(), 0, nil, func(v string) {
a, err := asDurOpt(v)
if err != nil {
view.App().Flash().Err(err)
Expand All @@ -45,13 +44,13 @@ func ShowDrain(view ResourceViewer, path string, defaults dao.DrainOptions, okFn
view.App().Flash().Clear()
opts.Timeout = a
})
f.AddCheckbox("Ignore DaemonSets:", defaults.IgnoreAllDaemonSets, func(_ string, v bool) {
f.AddCheckbox("Ignore DaemonSets:", opts.IgnoreAllDaemonSets, func(_ string, v bool) {
opts.IgnoreAllDaemonSets = v
})
f.AddCheckbox("Delete Local Data:", defaults.DeleteEmptyDirData, func(_ string, v bool) {
f.AddCheckbox("Delete Local Data:", opts.DeleteEmptyDirData, func(_ string, v bool) {
opts.DeleteEmptyDirData = v
})
f.AddCheckbox("Force:", defaults.Force, func(_ string, v bool) {
f.AddCheckbox("Force:", opts.Force, func(_ string, v bool) {
opts.Force = v
})

Expand Down