@@ -10,7 +10,6 @@ import (
1010 "github.com/loft-sh/devspace/pkg/devspace/plugin"
1111 "github.com/loft-sh/devspace/pkg/devspace/upgrade"
1212 "github.com/loft-sh/devspace/pkg/util/message"
13- "github.com/loft-sh/devspace/pkg/util/ptr"
1413 "k8s.io/apimachinery/pkg/labels"
1514
1615 "github.com/loft-sh/devspace/cmd/flags"
@@ -29,9 +28,12 @@ type SyncCmd struct {
2928 * flags.GlobalFlags
3029
3130 LabelSelector string
31+ ImageSelector string
3232 Container string
3333 Pod string
3434 Pick bool
35+ Wait bool
36+ Polling bool
3537
3638 Exclude []string
3739 ContainerPath string
@@ -82,6 +84,7 @@ devspace sync --container-path=/my-path
8284 syncCmd .Flags ().StringVarP (& cmd .Container , "container" , "c" , "" , "Container name within pod where to sync to" )
8385 syncCmd .Flags ().StringVar (& cmd .Pod , "pod" , "" , "Pod to sync to" )
8486 syncCmd .Flags ().StringVarP (& cmd .LabelSelector , "label-selector" , "l" , "" , "Comma separated key=value selector list (e.g. release=test)" )
87+ syncCmd .Flags ().StringVar (& cmd .ImageSelector , "image-selector" , "" , "The image to search a pod for (e.g. nginx, nginx:latest, ${runtime.images.app}, nginx:${runtime.images.app.tag})" )
8588 syncCmd .Flags ().BoolVar (& cmd .Pick , "pick" , true , "Select a pod" )
8689
8790 syncCmd .Flags ().StringSliceVarP (& cmd .Exclude , "exclude" , "e" , []string {}, "Exclude directory from sync" )
@@ -97,6 +100,9 @@ devspace sync --container-path=/my-path
97100 syncCmd .Flags ().BoolVar (& cmd .UploadOnly , "upload-only" , false , "If set DevSpace will only upload files" )
98101 syncCmd .Flags ().BoolVar (& cmd .DownloadOnly , "download-only" , false , "If set DevSpace will only download files" )
99102
103+ syncCmd .Flags ().BoolVar (& cmd .Wait , "wait" , true , "Wait for the pod(s) to start if they are not running" )
104+ syncCmd .Flags ().BoolVar (& cmd .Polling , "polling" , false , "If polling should be used to detect file changes in the container" )
105+
100106 return syncCmd
101107}
102108
@@ -176,7 +182,16 @@ func (cmd *SyncCmd) Run(f factory.Factory) error {
176182
177183 // Build params
178184 options := targetselector .NewOptionsFromFlags (cmd .Container , cmd .LabelSelector , cmd .Namespace , cmd .Pod , cmd .Pick )
179- options .Wait = ptr .Bool (false )
185+ // get image selector if specified
186+ imageSelector , err := getImageSelector (client , configLoader , configOptions , "" , cmd .ImageSelector , logger )
187+ if err != nil {
188+ return err
189+ }
190+
191+ // set image selector
192+ options .ImageSelector = imageSelector
193+ options .Wait = & cmd .Wait
194+
180195 if cmd .DownloadOnly && cmd .UploadOnly {
181196 return errors .New ("--upload-only cannot be used together with --download-only" )
182197 }
@@ -266,7 +281,7 @@ func (cmd *SyncCmd) applyFlagsToSyncConfig(syncConfig *latest.SyncConfig) error
266281 if cmd .Container != "" {
267282 syncConfig .ContainerName = ""
268283 }
269- if cmd .LabelSelector != "" || cmd .Pod != "" {
284+ if cmd .LabelSelector != "" || cmd .Pod != "" || cmd . ImageSelector != "" {
270285 syncConfig .LabelSelector = nil
271286 syncConfig .ImageSelector = ""
272287 }
@@ -288,5 +303,9 @@ func (cmd *SyncCmd) applyFlagsToSyncConfig(syncConfig *latest.SyncConfig) error
288303 syncConfig .InitialSync = latest .InitialSyncStrategy (cmd .InitialSync )
289304 }
290305
306+ if cmd .Polling {
307+ syncConfig .Polling = cmd .Polling
308+ }
309+
291310 return nil
292311}
0 commit comments