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

Method RunListSync

cmd/list/sync.go:40–99  ·  view source on GitHub ↗

RunListSync runs the list sync command logic

(f factory.Factory, cobraCmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

38
39// RunListSync runs the list sync command logic
40func (cmd *syncCmd) RunListSync(f factory.Factory, cobraCmd *cobra.Command, args []string) error {
41 logger := f.GetLog()
42 // Set config root
43 configLoader, _ := f.NewConfigLoader(cmd.ConfigPath)
44 configExists, err := configLoader.SetDevSpaceRoot(logger)
45 if err != nil {
46 return err
47 }
48 if !configExists {
49 return errors.New(message.ConfigNotFound)
50 }
51
52 configInterface, err := configLoader.Load(context.TODO(), nil, cmd.ToConfigOptions(), logger)
53 if err != nil {
54 return err
55 }
56
57 config := configInterface.Config()
58 syncPaths := make([][]string, 0)
59
60 for _, dev := range config.Dev {
61 if len(dev.Sync) == 0 {
62 logger.Info("No sync paths are configured.")
63 return nil
64 }
65 selector := ""
66 for k, v := range dev.LabelSelector {
67 if len(selector) > 0 {
68 selector += ", "
69 }
70 selector += k + "=" + v
71 }
72 // Transform values into string arrays
73 for _, value := range dev.Sync {
74 excludedPaths := ""
75 if value.ExcludePaths != nil {
76 for _, v := range value.ExcludePaths {
77 if len(excludedPaths) > 0 {
78 excludedPaths += ", "
79 }
80 excludedPaths += v
81 }
82 }
83 syncPaths = append(syncPaths, []string{
84 selector,
85 value.Path,
86 excludedPaths,
87 })
88 }
89 }
90
91 headerColumnNames := []string{
92 "Label Selector",
93 "Path (Local:Container)",
94 "Excluded Paths",
95 }
96
97 log.PrintTable(logger, headerColumnNames, syncPaths)

Callers 1

newSyncCmdFunction · 0.95

Calls 8

SetDevSpaceRootMethod · 0.95
LoadMethod · 0.95
PrintTableFunction · 0.92
ToConfigOptionsMethod · 0.80
GetLogMethod · 0.65
NewConfigLoaderMethod · 0.65
ConfigMethod · 0.65
InfoMethod · 0.45

Tested by

no test coverage detected