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

Function NewSyncCmd

cmd/sync.go:60–107  ·  view source on GitHub ↗

NewSyncCmd creates a new init command

(f factory.Factory, globalFlags *flags.GlobalFlags)

Source from the content-addressed store, hash-verified

58
59// NewSyncCmd creates a new init command
60func NewSyncCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command {
61 cmd := &SyncCmd{GlobalFlags: globalFlags}
62
63 syncCmd := &cobra.Command{
64 Use: "sync",
65 Short: "Starts a bi-directional sync between the target container and the local path",
66 Long: `
67#############################################################################
68################### devspace sync ###########################################
69#############################################################################
70Starts a bi-directional(default) sync between the target container path
71and local path:
72
73devspace sync --path=.:/app # localPath is current dir and remotePath is /app
74devspace sync --path=.:/app --image-selector nginx:latest
75devspace sync --path=.:/app --exclude=node_modules,test
76devspace sync --path=.:/app --pod=my-pod --container=my-container
77#############################################################################`,
78 RunE: func(cobraCmd *cobra.Command, args []string) error {
79 // Print upgrade message if new version available
80 upgrade.PrintUpgradeMessage(f.GetLog())
81 plugin.SetPluginCommand(cobraCmd, args)
82 return cmd.Run(f)
83 },
84 }
85
86 syncCmd.Flags().StringVarP(&cmd.Container, "container", "c", "", "Container name within pod where to sync to")
87 syncCmd.Flags().StringVar(&cmd.Pod, "pod", "", "Pod to sync to")
88 syncCmd.Flags().StringVarP(&cmd.LabelSelector, "label-selector", "l", "", "Comma separated key=value selector list (e.g. release=test)")
89 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})")
90 syncCmd.Flags().BoolVar(&cmd.Pick, "pick", true, "Select a pod")
91
92 syncCmd.Flags().StringSliceVarP(&cmd.Exclude, "exclude", "e", []string{}, "Exclude directory from sync")
93 syncCmd.Flags().StringVar(&cmd.Path, "path", "", "Path to use (Default is current directory). Example: ./local-path:/remote-path or local-path:.")
94
95 syncCmd.Flags().BoolVar(&cmd.DownloadOnInitialSync, "download-on-initial-sync", true, "DEPRECATED: Downloads all locally non existing remote files in the beginning")
96 syncCmd.Flags().StringVar(&cmd.InitialSync, "initial-sync", "", "The initial sync strategy to use (mirrorLocal, mirrorRemote, preferLocal, preferRemote, preferNewest, keepAll)")
97
98 syncCmd.Flags().BoolVar(&cmd.NoWatch, "no-watch", false, "Synchronizes local and remote and then stops")
99
100 syncCmd.Flags().BoolVar(&cmd.UploadOnly, "upload-only", false, "If set DevSpace will only upload files")
101 syncCmd.Flags().BoolVar(&cmd.DownloadOnly, "download-only", false, "If set DevSpace will only download files")
102
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
106 return syncCmd
107}
108
109type nameConfig struct {
110 name string

Callers 1

BuildRootFunction · 0.70

Calls 4

RunMethod · 0.95
PrintUpgradeMessageFunction · 0.92
SetPluginCommandFunction · 0.92
GetLogMethod · 0.65

Tested by

no test coverage detected