@@ -25,9 +25,10 @@ type RangeConfig struct {
25
25
26
26
// Configs provides access to port configurations.
27
27
type Configs struct {
28
- workspaceConfigs map [uint32 ]* gitpod.PortConfig
29
- instancePortConfigs map [uint32 ]* gitpod.PortConfig
30
- instanceRangeConfigs []* RangeConfig
28
+ workspaceConfigs map [uint32 ]* gitpod.PortConfig
29
+ instancePortConfigs map [uint32 ]* gitpod.PortConfig
30
+ instanceRangeConfigs []* RangeConfig
31
+ workspaceConfigsOrder []uint32
31
32
}
32
33
33
34
// ForEach iterates over all configured ports.
@@ -124,7 +125,7 @@ func (service *ConfigService) Observe(ctx context.Context) (<-chan *Configs, <-c
124
125
if err != nil {
125
126
errorsChan <- err
126
127
} else {
127
- current .workspaceConfigs = parseWorkspaceConfigs (info .Workspace .Config .Ports )
128
+ current .workspaceConfigs , current . workspaceConfigsOrder = parseWorkspaceConfigs (info .Workspace .Config .Ports )
128
129
updatesChan <- & Configs {workspaceConfigs : current .workspaceConfigs }
129
130
}
130
131
} else {
@@ -144,9 +145,10 @@ func (service *ConfigService) Observe(ctx context.Context) (<-chan *Configs, <-c
144
145
continue
145
146
}
146
147
updatesChan <- & Configs {
147
- workspaceConfigs : current .workspaceConfigs ,
148
- instancePortConfigs : current .instancePortConfigs ,
149
- instanceRangeConfigs : current .instanceRangeConfigs ,
148
+ workspaceConfigs : current .workspaceConfigs ,
149
+ instancePortConfigs : current .instancePortConfigs ,
150
+ instanceRangeConfigs : current .instanceRangeConfigs ,
151
+ workspaceConfigsOrder : current .workspaceConfigsOrder ,
150
152
}
151
153
}
152
154
}
@@ -168,19 +170,20 @@ func (service *ConfigService) update(config *gitpod.GitpodConfig, current *Confi
168
170
169
171
var portRangeRegexp = regexp .MustCompile (`^(\d+)[-:](\d+)$` )
170
172
171
- func parseWorkspaceConfigs (ports []* gitpod.PortConfig ) (portConfigs map [uint32 ]* gitpod.PortConfig ) {
173
+ func parseWorkspaceConfigs (ports []* gitpod.PortConfig ) (portConfigs map [uint32 ]* gitpod.PortConfig , portsOrder [] uint32 ) {
172
174
if len (ports ) == 0 {
173
- return nil
175
+ return
174
176
}
175
177
portConfigs = make (map [uint32 ]* gitpod.PortConfig )
176
178
for _ , config := range ports {
177
179
port := uint32 (config .Port )
178
180
_ , exists := portConfigs [port ]
179
181
if ! exists {
180
182
portConfigs [port ] = config
183
+ portsOrder = append (portsOrder , port )
181
184
}
182
185
}
183
- return portConfigs
186
+ return
184
187
}
185
188
186
189
func parseInstanceConfigs (ports []* gitpod.PortsItems ) (portConfigs map [uint32 ]* gitpod.PortConfig , rangeConfigs []* RangeConfig ) {
0 commit comments