11package list
22
33import (
4+ "context"
45 "github.com/loft-sh/devspace/cmd/flags"
56 "github.com/loft-sh/devspace/pkg/util/factory"
7+ "github.com/loft-sh/devspace/pkg/util/log"
8+ "github.com/loft-sh/devspace/pkg/util/message"
9+ "github.com/pkg/errors"
610 "github.com/spf13/cobra"
711)
812
@@ -33,9 +37,9 @@ Lists the sync configuration
3337
3438// RunListSync runs the list sync command logic
3539func (cmd * syncCmd ) RunListSync (f factory.Factory , cobraCmd * cobra.Command , args []string ) error {
36- /* logger := f.GetLog()
40+ logger := f .GetLog ()
3741 // Set config root
38- configLoader := f.NewConfigLoader(cmd.ConfigPath)
42+ configLoader , _ := f .NewConfigLoader (cmd .ConfigPath )
3943 configExists , err := configLoader .SetDevSpaceRoot (logger )
4044 if err != nil {
4145 return err
@@ -44,58 +48,51 @@ func (cmd *syncCmd) RunListSync(f factory.Factory, cobraCmd *cobra.Command, args
4448 return errors .New (message .ConfigNotFound )
4549 }
4650
47- configInterface, err := configLoader.Load(cmd.ToConfigOptions(logger ), logger)
51+ configInterface , err := configLoader .Load (context . TODO (), nil , cmd .ToConfigOptions (), logger )
4852 if err != nil {
4953 return err
5054 }
5155
5256 config := configInterface .Config ()
53- if config.Dev.Sync == nil || len(config.Dev.Sync) == 0 {
54- logger.Info("No sync paths are configured. Run `devspace add sync` to add new sync path\n")
55- return nil
56- }
57-
58- headerColumnNames := []string{
59- "Label Selector",
60- "Local Path",
61- "Container Path",
62- "Excluded Paths",
63- }
57+ syncPaths := make ([][]string , 0 )
6458
65- syncPaths := make([][]string, 0, len(config.Dev.Sync))
66-
67- // Transform values into string arrays
68- for _, value := range config.Dev.Sync {
59+ for _ , dev := range config .Dev {
60+ if dev .Sync == nil || len (dev .Sync ) == 0 {
61+ logger .Info ("No sync paths are configured." )
62+ return nil
63+ }
6964 selector := ""
70-
71- for k, v := range value.LabelSelector {
65+ for k , v := range dev .LabelSelector {
7266 if len (selector ) > 0 {
7367 selector += ", "
7468 }
75-
7669 selector += k + "=" + v
7770 }
78- excludedPaths := ""
79-
80- if value.ExcludePaths != nil {
81- for _, v := range value.ExcludePaths {
82- if len(excludedPaths) > 0 {
83- excludedPaths += ", "
71+ // Transform values into string arrays
72+ for _ , value := range dev .Sync {
73+ excludedPaths := ""
74+ if value .ExcludePaths != nil {
75+ for _ , v := range value .ExcludePaths {
76+ if len (excludedPaths ) > 0 {
77+ excludedPaths += ", "
78+ }
79+ excludedPaths += v
8480 }
85-
86- excludedPaths += v
8781 }
82+ syncPaths = append (syncPaths , []string {
83+ selector ,
84+ value .Path ,
85+ excludedPaths ,
86+ })
8887 }
88+ }
8989
90- syncPaths = append(syncPaths, []string{
91- selector,
92- value.LocalSubPath,
93- value.ContainerPath,
94- excludedPaths,
95- })
90+ headerColumnNames := []string {
91+ "Label Selector" ,
92+ "Path (Local:Container)" ,
93+ "Excluded Paths" ,
9694 }
9795
9896 log .PrintTable (logger , headerColumnNames , syncPaths )
99- return nil*/
10097 return nil
10198}
0 commit comments