Skip to content

[supervisor] add new .gitpod.yml on-port option ignore-completely #20828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions components/gitpod-protocol/data/gitpod-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
"open-browser",
"open-preview",
"notify",
"ignore"
"ignore",
"ignore-completely"
],
"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."
"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."
},
"visibility": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion 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.

2 changes: 1 addition & 1 deletion components/gitpod-protocol/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ export interface PrebuiltWorkspaceUpdatable {
contextUrl?: string;
}

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

export interface PortConfig {
port: number;
Expand Down
302 changes: 153 additions & 149 deletions components/supervisor-api/go/status.pb.go

Large diffs are not rendered by default.

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

1 change: 1 addition & 0 deletions components/supervisor-api/status.proto
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ message PortsStatus {
open_preview = 2;
notify = 3;
notify_private = 4;
ignore_completely = 5;
}

// Action hint on open
Expand Down
16 changes: 15 additions & 1 deletion components/supervisor/pkg/ports/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ func (pm *Manager) updateState(ctx context.Context, exposed []ExposedPort, serve
continue
}

config, _, exists := pm.configs.Get(port.Port)
// don't serve ports that are configured to be ignored-completely
if exists && config.OnOpen == "ignore-completely" {
continue
}

current, exists := servedMap[port.Port]
if !exists || (!port.BoundToLocalhost && current.BoundToLocalhost) {
servedMap[port.Port] = port
Expand Down Expand Up @@ -624,6 +630,9 @@ func getOnOpenAction(config *gitpod.PortConfig, port uint32) api.PortsStatus_OnO
}
return api.PortsStatus_notify_private
}
if config.OnOpen == "ignore-completely" {
return api.PortsStatus_ignore_completely
}
if config.OnOpen == "ignore" {
return api.PortsStatus_ignore
}
Expand Down Expand Up @@ -785,7 +794,12 @@ func (pm *Manager) Subscribe() (*Subscription, error) {
func (pm *Manager) getStatus() []*api.PortsStatus {
res := make([]*api.PortsStatus, 0, len(pm.state))
for port := range pm.state {
res = append(res, pm.getPortStatus(port))
status := pm.getPortStatus(port)
// make sure they are not listed in ports list
if status.OnOpen == api.PortsStatus_ignore_completely {
continue
}
res = append(res, status)
}
sort.SliceStable(res, func(i, j int) bool {
// Max number of port 65536
Expand Down
Loading