Skip to content

Commit e04327e

Browse files
authored
[supervisor] add new .gitpod.yml on-port option ignore-completely (#20828)
* [supervisor] add new .gitpod.yml on-port option `ignore-completely` * fixup * fix serve * fixup
1 parent f88268c commit e04327e

File tree

7 files changed

+240
-211
lines changed

7 files changed

+240
-211
lines changed

components/gitpod-protocol/data/gitpod-schema.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
"open-browser",
2525
"open-preview",
2626
"notify",
27-
"ignore"
27+
"ignore",
28+
"ignore-completely"
2829
],
29-
"description": "What to do when a service on this port was detected. 'notify' (default) will show a notification asking the user what to do. 'open-browser' will open a new browser tab. 'open-preview' will open in the preview on the right of the IDE. 'ignore' will do nothing."
30+
"description": "What to do when a service on this port was detected. 'notify' (default) will show a notification asking the user what to do. 'open-browser' will open a new browser tab. 'open-preview' will open in the preview on the right of the IDE. 'ignore' will do nothing. 'ignore-completely' will do nothing and prevent port forwarding."
3031
},
3132
"visibility": {
3233
"type": "string",

components/gitpod-protocol/go/gitpod-config-types.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/gitpod-protocol/src/protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ export interface PrebuiltWorkspaceUpdatable {
10011001
contextUrl?: string;
10021002
}
10031003

1004-
export type PortOnOpen = "open-browser" | "open-preview" | "notify" | "ignore";
1004+
export type PortOnOpen = "open-browser" | "open-preview" | "notify" | "ignore" | "ignore-completely";
10051005

10061006
export interface PortConfig {
10071007
port: number;

components/supervisor-api/go/status.pb.go

Lines changed: 153 additions & 149 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/supervisor-api/java/src/main/java/io/gitpod/supervisor/api/Status.java

Lines changed: 66 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/supervisor-api/status.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ message PortsStatus {
223223
open_preview = 2;
224224
notify = 3;
225225
notify_private = 4;
226+
ignore_completely = 5;
226227
}
227228

228229
// Action hint on open

components/supervisor/pkg/ports/ports.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ func (pm *Manager) updateState(ctx context.Context, exposed []ExposedPort, serve
272272
continue
273273
}
274274

275+
config, _, exists := pm.configs.Get(port.Port)
276+
// don't serve ports that are configured to be ignored-completely
277+
if exists && config.OnOpen == "ignore-completely" {
278+
continue
279+
}
280+
275281
current, exists := servedMap[port.Port]
276282
if !exists || (!port.BoundToLocalhost && current.BoundToLocalhost) {
277283
servedMap[port.Port] = port
@@ -624,6 +630,9 @@ func getOnOpenAction(config *gitpod.PortConfig, port uint32) api.PortsStatus_OnO
624630
}
625631
return api.PortsStatus_notify_private
626632
}
633+
if config.OnOpen == "ignore-completely" {
634+
return api.PortsStatus_ignore_completely
635+
}
627636
if config.OnOpen == "ignore" {
628637
return api.PortsStatus_ignore
629638
}
@@ -785,7 +794,12 @@ func (pm *Manager) Subscribe() (*Subscription, error) {
785794
func (pm *Manager) getStatus() []*api.PortsStatus {
786795
res := make([]*api.PortsStatus, 0, len(pm.state))
787796
for port := range pm.state {
788-
res = append(res, pm.getPortStatus(port))
797+
status := pm.getPortStatus(port)
798+
// make sure they are not listed in ports list
799+
if status.OnOpen == api.PortsStatus_ignore_completely {
800+
continue
801+
}
802+
res = append(res, status)
789803
}
790804
sort.SliceStable(res, func(i, j int) bool {
791805
// Max number of port 65536

0 commit comments

Comments
 (0)