MCPcopy Index your code
hub / github.com/devspace-sh/devspace / applyFlagsToSyncConfig

Method applyFlagsToSyncConfig

cmd/sync.go:303–351  ·  view source on GitHub ↗
(syncConfig *latest.SyncConfig, options targetselector.Options)

Source from the content-addressed store, hash-verified

301}
302
303func (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}

Callers 1

RunMethod · 0.95

Calls 7

ValidInitialSyncStrategyFunction · 0.92
InitialSyncStrategyTypeAlias · 0.92
WithLabelSelectorMethod · 0.80
WithPodMethod · 0.80
WithNamespaceMethod · 0.80
WithContainerMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected