Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --What happened: Using without specifying should modify existing container images without trying to create a new one. Instead it tries to create a new container and returns an error that isn't set: What you expected to happen: This command should change all container images to instead of returning an error. /sig cli /kind bug /priority important-soon
/assign /triage accepted
My kubernetes cluster version is 1.19.0,and i use kubectl-debug version 0.1.1 try to debug my pod,bug i got error: <img width="1470" alt="image" src="https://user-"Who one know about that

Discussion:
TargetContainer string TTY             bool <ins> attachChanged         bool </ins> deprecatedInvocation  bool shareProcessedChanged bool

return err } <del> // Share processes </del> <ins> // Record flags that the user explicitly changed from their defaults o.attachChanged = cmd.Flags().Changed("attach") </ins> o.shareProcessedChanged = cmd.Flags().Changed("share-processes") return nil

// Validate checks that the provided debug options are specified. func (o *DebugOptions) Validate(cmd *cobra.Command) error { <ins> // Attach if o.Attach && o.attachChanged && len(o.Image) == 0 && len(o.Container) == 0 { return fmt.Errorf("you must specify --container or create a new container using --image in order to attach.") } </ins> // CopyTo if len(o.CopyTo) > 0 { if len(o.Image) == 0 && len(o.SetImages) == 0 && len(o.Args) == 0 {

return visitErr } <del> if o.Attach { </del> <ins> if o.Attach && len(containerName) > 0 { </ins> opts := &attach.AttachOptions{ StreamOptions: exec.StreamOptions{ IOStreams: o.IOStreams,

} } <del> containerByName := containerNameToRef(copied) name := o.Container if len(name) == 0 { name = o.computeDebugContainerName(copied) } </del> <ins> name, containerByName := o.Container, containerNameToRef(copied) </ins> c, ok := containerByName[name] if !ok { // Adding a new debug container if len(o.Image) == 0 { <ins> if len(o.SetImages) > 0 { // This was a --set-image only invocation return copied, "", nil } </ins> return nil, "", fmt.Errorf("you must specify image when creating new container") } <ins> if len(name) == 0 { name = o.computeDebugContainerName(copied) } </ins> c = &corev1.Container{ Name:                     name, TerminationMessagePolicy: corev1.TerminationMessageReadFile,

name: "Change image for all containers with set-image", opts: &DebugOptions{ CopyTo:    "myapp-copy", <del> Container: "app", </del> SetImages: map[string]string{"*": "busybox"}, }, havePod: &corev1.Pod{

name: "Change image for multiple containers with set-image", opts: &DebugOptions{ CopyTo:    "myapp-copy", <del> Container: "app", </del> SetImages: map[string]string{"*": "busybox", "app": "app-debugger"}, }, havePod: &corev1.Pod{

}, }, { <ins> name: "Pod copy: explicit attach", args: "mypod --image=busybox --copy-to=my-debugger --attach -- sleep 1d", wantOpts: &DebugOptions{ Args:           []string{"sleep", "1d"}, Attach:         true, CopyTo:         "my-debugger", Image:          "busybox", Namespace:      "default", ShareProcesses: true, TargetNames:    []string{"mypod"}, }, }, { </ins> name: "Pod copy: replace single image of existing container", args: "mypod --image=busybox --container=my-container --copy-to=my-debugger", wantOpts: &DebugOptions{

wantError: true, }, { <ins> name:      "Pod copy: specifying attach without existing or newly created container", args:      "mypod --set-image=*=busybox --copy-to=my-debugger --attach", wantError: true, }, { </ins> name: "Node: interactive session minimal args", args: "node/mynode -it --image=busybox", wantOpts: &DebugOptions{