(syncConfig *latest.SyncConfig, options targetselector.Options)
| 301 | } |
| 302 | |
| 303 | func (cmd *SyncCmd) applyFlagsToSyncConfig(syncConfig *latest.SyncConfig, options targetselector.Options) (targetselector.Options, error) { |
| 304 | if cmd.Path != "" { |
| 305 | syncConfig.Path = cmd.Path |
| 306 | } |
| 307 | if len(cmd.Exclude) > 0 { |
| 308 | syncConfig.ExcludePaths = cmd.Exclude |
| 309 | } |
| 310 | if cmd.UploadOnly { |
| 311 | syncConfig.DisableDownload = cmd.UploadOnly |
| 312 | } |
| 313 | if cmd.DownloadOnly { |
| 314 | syncConfig.DisableUpload = cmd.DownloadOnly |
| 315 | } |
| 316 | |
| 317 | // if selection is specified through flags, we don't want to use the loaded |
| 318 | // sync config selection from the devspace.yaml. |
| 319 | if cmd.Container != "" { |
| 320 | options = options.WithContainer(cmd.Container) |
| 321 | } |
| 322 | if cmd.LabelSelector != "" { |
| 323 | options = options.WithLabelSelector(cmd.LabelSelector) |
| 324 | } |
| 325 | if cmd.Pod != "" { |
| 326 | options = options.WithPod(cmd.Pod) |
| 327 | } |
| 328 | if cmd.Namespace != "" { |
| 329 | options = options.WithNamespace(cmd.Namespace) |
| 330 | } |
| 331 | |
| 332 | if cmd.DownloadOnInitialSync { |
| 333 | syncConfig.InitialSync = latest.InitialSyncStrategyPreferLocal |
| 334 | } else { |
| 335 | syncConfig.InitialSync = latest.InitialSyncStrategyMirrorLocal |
| 336 | } |
| 337 | |
| 338 | if cmd.InitialSync != "" { |
| 339 | if !versions.ValidInitialSyncStrategy(latest.InitialSyncStrategy(cmd.InitialSync)) { |
| 340 | return options, errors.Errorf("--initial-sync is not valid '%s'", cmd.InitialSync) |
| 341 | } |
| 342 | |
| 343 | syncConfig.InitialSync = latest.InitialSyncStrategy(cmd.InitialSync) |
| 344 | } |
| 345 | |
| 346 | if cmd.Polling { |
| 347 | syncConfig.Polling = cmd.Polling |
| 348 | } |
| 349 | |
| 350 | return options, nil |
| 351 | } |
no test coverage detected