mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
afd40436f0
fixes https://github.com/coder/internal/issues/1123 We want to tests that ports are not included after they are no longer used, but this isn't safe on the real OS networking stack because there is no way to guarantee a port _won't_ be used. Instead, we introduce an interface and fake implementation for testing. On order to leave the filtering logic in the test path, this PR also does some refactoring. Caching logic is left in the real OS querying implementation and a new test case is added for it in this PR.
21 lines
530 B
Go
21 lines
530 B
Go
//go:build !linux && !(windows && amd64)
|
|
|
|
package agent
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/coder/coder/v2/codersdk"
|
|
)
|
|
|
|
type osListeningPortsGetter struct {
|
|
cacheDuration time.Duration
|
|
}
|
|
|
|
func (*osListeningPortsGetter) GetListeningPorts() ([]codersdk.WorkspaceAgentListeningPort, error) {
|
|
// Can't scan for ports on non-linux or non-windows_amd64 systems at the
|
|
// moment. The UI will not show any "no ports found" message to the user, so
|
|
// the user won't suspect a thing.
|
|
return []codersdk.WorkspaceAgentListeningPort{}, nil
|
|
}
|