Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/cmd/kn_revision_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ kn revision delete NAME [flags]
--async DEPRECATED: please use --no-wait instead. Delete revision and don't wait for it to be deleted.
-h, --help help for delete
-n, --namespace string Specify the namespace to operate in.
--no-wait Delete revision and don't wait for it to be deleted.
--no-wait Delete revision and don't wait for it to be deleted. (default true)
--wait-timeout int Seconds to wait before giving up on waiting for revision to be deleted. (default 600)
```

Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/kn_service_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ kn service delete NAME [flags]
--async DEPRECATED: please use --no-wait instead. Delete service and don't wait for it to be deleted.
-h, --help help for delete
-n, --namespace string Specify the namespace to operate in.
--no-wait Delete service and don't wait for it to be deleted.
--no-wait Delete service and don't wait for it to be deleted. (default true)
--wait-timeout int Seconds to wait before giving up on waiting for service to be deleted. (default 600)
```

Expand Down
9 changes: 8 additions & 1 deletion pkg/kn/commands/wait_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@ type WaitFlags struct {
func (p *WaitFlags) AddConditionWaitFlags(command *cobra.Command, waitTimeoutDefault int, action, what, until string) {
waitUsage := fmt.Sprintf("%s %s and don't wait for it to be %s.", action, what, until)
//TODO: deprecated flag should be removed in next release

// Special-case 'delete' command so it comes back to the user immediately
noWaitDefault := false
if action == "Delete" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather see default value provided through function's argument. The current approach will change default for all delete operations, e.g. also Revisions. What about a new config struct that for now can have 2 fields, default value and timeout.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I didn't realize you could be more specific... I'll fix....

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, I would be happy to switch to no-wait as default for all delete operations (this would then be also easy to reason about).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do like consistency :-) We just need to figure out which way it spans. Making all deletes the same (as long as it doesn't have negative side-effects) seems ok to me. @dsimansk ?

Copy link
Copy Markdown
Contributor

@dsimansk dsimansk Apr 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure about all the usage. However, wait flags are used in Service (delete) and Revision (delete), no objections to go with --no-wait for all delete then.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok - if we do that, then I think the PR is ready for review

noWaitDefault = true
}

command.Flags().BoolVar(&p.Async, "async", false, "DEPRECATED: please use --no-wait instead. "+waitUsage)
command.Flags().BoolVar(&p.NoWait, "no-wait", false, waitUsage)
command.Flags().BoolVar(&p.NoWait, "no-wait", noWaitDefault, waitUsage)

timeoutUsage := fmt.Sprintf("Seconds to wait before giving up on waiting for %s to be %s.", what, until)
command.Flags().IntVar(&p.TimeoutInSeconds, "wait-timeout", waitTimeoutDefault, timeoutUsage)
Expand Down
9 changes: 9 additions & 0 deletions pkg/kn/commands/wait_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,12 @@ func TestAddWaitUsageMessage(t *testing.T) {
t.Error("wrong until message")
}
}

func TestAddWaitUsageDelete(t *testing.T) {
flags := &WaitFlags{}
cmd := cobra.Command{}
flags.AddConditionWaitFlags(&cmd, 60, "Delete", "blub", "deleted")
if !strings.Contains(cmd.UsageString(), "deleted. (default true)") {
t.Error("Delete has wrong default value for --no-wait")
}
}