@@ -2,6 +2,8 @@ package cmd
22
33import (
44 "fmt"
5+ "github.com/loft-sh/devspace/pkg/devspace/kubectl/selector"
6+ "github.com/loft-sh/devspace/pkg/util/stringutil"
57 "io"
68 "os"
79 "os/exec"
@@ -10,7 +12,6 @@ import (
1012 "time"
1113
1214 runtimevar "github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/runtime"
13- "github.com/loft-sh/devspace/pkg/devspace/imageselector"
1415 "github.com/loft-sh/devspace/pkg/util/command"
1516
1617 "github.com/loft-sh/devspace/pkg/devspace/config"
@@ -624,24 +625,24 @@ func (cmd *DevCmd) startOutput(configInterface config.Config, dependencies []typ
624625 }
625626 return 0 , nil
626627 } else {
627- selectorOptions := targetselector .NewDefaultOptions ().ApplyCmdParameter ("" , "" , cmd .Namespace , "" )
628+ selectorOptions := targetselector .NewEmptyOptions ().
629+ WithContainerFilter (selector .FilterNonRunningContainers ).
630+ WithPick (true ).
631+ WithNamespace (cmd .Namespace )
628632 if config .Dev .Terminal != nil {
629- selectorOptions = selectorOptions .ApplyConfigParameter (config .Dev .Terminal .LabelSelector , config .Dev .Terminal .Namespace , config .Dev .Terminal .ContainerName , "" )
630- }
633+ var imageSelectors []string
634+ if config .Dev .Terminal .ImageSelector != "" {
635+ imageSelector , err := runtimevar .NewRuntimeResolver (true ).FillRuntimeVariablesAsImageSelector (config .Dev .Terminal .ImageSelector , configInterface , dependencies )
636+ if err != nil {
637+ return 0 , err
638+ }
631639
632- var imageSelectors []imageselector.ImageSelector
633- if config .Dev .Terminal != nil && config .Dev .Terminal .ImageSelector != "" {
634- imageSelector , err := runtimevar .NewRuntimeResolver (true ).FillRuntimeVariablesAsImageSelector (config .Dev .Terminal .ImageSelector , configInterface , dependencies )
635- if err != nil {
636- return 0 , err
640+ imageSelectors = []string {imageSelector .Image }
637641 }
638-
639- imageSelectors = append (imageSelectors , * imageSelector )
642+ selectorOptions = selectorOptions .ApplyConfigParameter (config .Dev .Terminal .ContainerName , config .Dev .Terminal .LabelSelector , imageSelectors , config .Dev .Terminal .Namespace , "" )
640643 }
641644
642645 cmd .log .Info ("Terminal: Waiting for containers to start..." )
643- selectorOptions .ImageSelector = imageSelectors
644-
645646 code , err := servicesClient .StartTerminal (selectorOptions , args , cmd .WorkingDirectory , exitChan , true , cmd .TerminalReconnect , stdout , stderr , stdin )
646647 if services .IsUnexpectedExitCode (code ) {
647648 cmd .log .Warnf ("Command terminated with exit code %d" , code )
@@ -758,7 +759,7 @@ func GetPaths(config *latest.Config) []string {
758759 }
759760 }
760761
761- return removeDuplicates (paths )
762+ return stringutil . RemoveDuplicates (paths )
762763}
763764
764765func (cmd * DevCmd ) loadConfig (configOptions * loader.ConfigOptions ) (config.Config , error ) {
@@ -823,25 +824,6 @@ func defaultStdStreams(stdout io.Writer, stderr io.Writer, stdin io.Reader) (io.
823824 return stdout , stderr , stdin
824825}
825826
826- func removeDuplicates (arr []string ) []string {
827- newArr := []string {}
828- for _ , v := range arr {
829- if ! contains (newArr , v ) {
830- newArr = append (newArr , v )
831- }
832- }
833- return newArr
834- }
835-
836- func contains (haystack []string , needle string ) bool {
837- for _ , v := range haystack {
838- if v == needle {
839- return true
840- }
841- }
842- return false
843- }
844-
845827func updateLastKubeContext (configLoader loader.ConfigLoader , client kubectl.Client , generatedConfig * generated.Config ) error {
846828 // Update generated if we deploy the application
847829 if generatedConfig != nil {
0 commit comments