@@ -129,28 +129,26 @@ func (l *configLoader) LoadWithParser(ctx context.Context, localCache localcache
129129 return nil , pluginErr
130130 }
131131
132+ // load the raw data
132133 data , err := l .LoadRaw ()
133134 if err != nil {
134135 return nil , err
135136 }
136137
138+ // make sure name is in config
137139 name := options .OverrideName
138140 if name == "" {
139- nameInterface , ok := data ["name" ]
141+ var ok bool
142+ name , ok = data ["name" ].(string )
140143 if ! ok {
141- name = "devspace"
142- } else {
143- name , ok = nameInterface .(string )
144- if ! ok || name == "" {
145- return nil , fmt .Errorf ("name property is not a string" )
146- }
144+ return nil , fmt .Errorf ("name is missing in " + filepath .Base (l .absConfigPath ))
147145 }
148146 }
149147
150148 // create remote cache
151149 var remoteCache remotecache.Cache
152150 if client != nil {
153- remoteCache , err = remotecache .NewCacheLoader (name ).Load (context . TODO () , client )
151+ remoteCache , err = remotecache .NewCacheLoader (name ).Load (ctx , client )
154152 if err != nil {
155153 return nil , fmt .Errorf ("error trying to load remote cache from current context and namespace: %v" , err )
156154 }
@@ -596,7 +594,6 @@ func GetLastProfile(profiles []string) string {
596594
597595// configExistsInPath checks whether a devspace configuration exists at a certain path
598596func configExistsInPath (path string ) bool {
599- // check devspace.yaml
600597 _ , err := os .Stat (path )
601598 return err == nil // false, no config file found
602599}
@@ -621,6 +618,18 @@ func (l *configLoader) LoadRaw() (map[string]interface{}, error) {
621618 return nil , err
622619 }
623620
621+ name , ok := rawMap ["name" ].(string )
622+ if ! ok || name == "" {
623+ directoryName := filepath .Base (filepath .Dir (l .absConfigPath ))
624+ if directoryName != "" && len (directoryName ) > 2 {
625+ name = directoryName
626+ } else {
627+ name = "devspace"
628+ }
629+
630+ rawMap ["name" ] = name
631+ }
632+
624633 return rawMap , nil
625634}
626635
@@ -637,11 +646,11 @@ func (l *configLoader) SetDevSpaceRoot(log log.Logger) (bool, error) {
637646 return configExists , nil
638647 }
639648
640- err := os .Chdir (filepath .Dir (ConfigPath ( l .absConfigPath ) ))
649+ err := os .Chdir (filepath .Dir (l .absConfigPath ))
641650 if err != nil {
642651 return false , err
643652 }
644- l . absConfigPath = filepath . Base ( ConfigPath ( l . absConfigPath ))
653+
645654 return true , nil
646655 }
647656
0 commit comments