@@ -41,8 +41,8 @@ type Config struct {
4141 SSH sshConfig
4242 Environment map [string ]string
4343 Routes map [string ]* RouteConfig
44- Users map [string ]subConfig
45- Groups map [string ]subConfig
44+ Users [] map [string ]subConfig
45+ Groups [] map [string ]subConfig
4646}
4747
4848// RouteConfig represents the configuration of a route. Dest is mandatory,
@@ -199,26 +199,32 @@ func LoadConfig(filename, currentUsername, sid string, start time.Time, groups m
199199 config .SSH .Args = defaultSSHArgs
200200 }
201201
202- for groupnames , groupconfig := range config .Groups {
203- for _ , groupname := range strings .Split (groupnames , "," ) {
204- if groups [groupname ] {
205- if err := parseSubConfig (& config , & groupconfig ); err != nil {
206- return nil , err
202+ // we have to use a slice of maps in order to have ordered maps
203+ for _ , groupconfigs := range config .Groups {
204+ for groupnames , groupconfig := range groupconfigs {
205+ for _ , groupname := range strings .Split (groupnames , "," ) {
206+ if groups [groupname ] {
207+ if err := parseSubConfig (& config , & groupconfig ); err != nil {
208+ return nil , err
209+ }
210+ // no need to to parse the same subconfig twice
211+ break
207212 }
208- // no need to to parse the same subconfig twice
209- break
210213 }
211214 }
212215 }
213216
214- for usernames , userconfig := range config .Users {
215- for _ , username := range strings .Split (usernames , "," ) {
216- if username == currentUsername {
217- if err := parseSubConfig (& config , & userconfig ); err != nil {
218- return nil , err
217+ // we have to use a slice of maps in order to have ordered maps
218+ for _ , userconfigs := range config .Users {
219+ for usernames , userconfig := range userconfigs {
220+ for _ , username := range strings .Split (usernames , "," ) {
221+ if username == currentUsername {
222+ if err := parseSubConfig (& config , & userconfig ); err != nil {
223+ return nil , err
224+ }
225+ // no need to to parse the same subconfig twice
226+ break
219227 }
220- // no need to to parse the same subconfig twice
221- break
222228 }
223229 }
224230 }
0 commit comments