Skip to content

Commit

Permalink
Fix supervisor send empty port name and desc
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed May 24, 2022
1 parent e148325 commit cf43f79
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 26 deletions.
7 changes: 5 additions & 2 deletions components/gitpod-protocol/go/gitpod-config-types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions components/supervisor/pkg/ports/ports-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ func (configs *Configs) Get(port uint32) (*gitpod.PortConfig, ConfigKind, bool)
for _, rangeConfig := range configs.instanceRangeConfigs {
if rangeConfig.Start <= port && port <= rangeConfig.End {
return &gitpod.PortConfig{
Port: float64(port),
OnOpen: rangeConfig.OnOpen,
Visibility: rangeConfig.Visibility,
Port: float64(port),
OnOpen: rangeConfig.OnOpen,
Visibility: rangeConfig.Visibility,
Description: rangeConfig.Description,
Name: rangeConfig.Name,
}, RangeConfigKind, true
}
}
Expand Down Expand Up @@ -197,9 +199,11 @@ func parseInstanceConfigs(ports []*gitpod.PortsItems) (portConfigs map[uint32]*g
_, exists := portConfigs[port]
if !exists {
portConfigs[port] = &gitpod.PortConfig{
OnOpen: config.OnOpen,
Port: float64(Port),
Visibility: config.Visibility,
OnOpen: config.OnOpen,
Port: float64(Port),
Visibility: config.Visibility,
Description: config.Description,
Name: config.Name,
}
}
continue
Expand Down
48 changes: 30 additions & 18 deletions components/supervisor/pkg/ports/ports-config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@ func TestPortsConfig(t *testing.T) {
Desc: "workspace port config",
WorkspacePorts: []*gitpod.PortConfig{
{
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Name: "Nice Port Name",
Description: "Nice Port Description",
},
},
Expectation: &PortConfigTestExpectations{
WorkspaceConfigs: []*gitpod.PortConfig{
{
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Name: "Nice Port Name",
Description: "Nice Port Description",
},
},
},
Expand All @@ -49,18 +53,22 @@ func TestPortsConfig(t *testing.T) {
GitpodConfig: &gitpod.GitpodConfig{
Ports: []*gitpod.PortsItems{
{
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Name: "Nice Port Name",
Description: "Nice Port Description",
},
},
},
Expectation: &PortConfigTestExpectations{
InstancePortConfigs: []*gitpod.PortConfig{
{
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Port: 9229,
OnOpen: "ignore",
Visibility: "public",
Name: "Nice Port Name",
Description: "Nice Port Description",
},
},
},
Expand All @@ -70,19 +78,23 @@ func TestPortsConfig(t *testing.T) {
GitpodConfig: &gitpod.GitpodConfig{
Ports: []*gitpod.PortsItems{
{
Port: "9229-9339",
OnOpen: "ignore",
Visibility: "public",
Port: "9229-9339",
OnOpen: "ignore",
Visibility: "public",
Name: "Nice Port Name",
Description: "Nice Port Description",
},
},
},
Expectation: &PortConfigTestExpectations{
InstanceRangeConfigs: []*RangeConfig{
{
PortsItems: &gitpod.PortsItems{
Port: "9229-9339",
OnOpen: "ignore",
Visibility: "public",
Port: "9229-9339",
OnOpen: "ignore",
Visibility: "public",
Description: "Nice Port Description",
Name: "Nice Port Name",
},
Start: 9229,
End: 9339,
Expand Down
6 changes: 6 additions & 0 deletions components/supervisor/pkg/ports/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ func (pm *Manager) nextState(ctx context.Context) map[uint32]*managedPort {

var public bool
config, kind, exists := pm.configs.Get(mp.LocalhostPort)
if exists {
mp.Name = config.Name
mp.Description = config.Description
mp.OnExposed = getOnExposedAction(config, mp.LocalhostPort)
}

configured := exists && kind == PortConfigKind
if mp.Exposed || configured {
public = mp.Visibility == api.PortVisibility_public
Expand Down

0 comments on commit cf43f79

Please sign in to comment.