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

enhance: Add force flag for remove channel command #257

Merged
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
14 changes: 12 additions & 2 deletions states/etcd/remove/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ func ChannelCommand(cli clientv3.KV, basePath string) *cobra.Command {
fmt.Println(err.Error())
return
}
force, err := cmd.Flags().GetBool("force")
if err != nil {
fmt.Println(err.Error())
return
}

collections, err := common.ListCollectionsVersion(context.Background(), cli, basePath, etcdversion.GetVersion())
if err != nil {
Expand All @@ -48,12 +53,16 @@ func ChannelCommand(cli clientv3.KV, basePath string) *cobra.Command {
}
return true
})
if err != nil {
fmt.Println(err.Error())
return
}

targets := make([]string, 0, len(paths))
for i, watchChannel := range watchChannels {
_, ok := validChannels[watchChannel.GetVchan().GetChannelName()]
if !ok {
fmt.Printf("%s might be an orphan channel, collection id: %d\n", watchChannel.GetVchan().GetChannelName(), watchChannel.GetVchan().GetCollectionID())
if !ok || force {
fmt.Printf("%s selected as target channel, collection id: %d\n", watchChannel.GetVchan().GetChannelName(), watchChannel.GetVchan().GetCollectionID())
targets = append(targets, paths[i])
}
}
Expand All @@ -77,5 +86,6 @@ func ChannelCommand(cli clientv3.KV, basePath string) *cobra.Command {

cmd.Flags().Bool("run", false, "flags indicating whether to remove channel from meta")
cmd.Flags().String("channel", "", "channel name to remove")
cmd.Flags().Bool("force", false, "force remove channel ignoring collection check")
return cmd
}
Loading