Files
moby/libnetwork/portallocator
Sebastiaan van Stijn c37690b98e libnet/portallocator: un-export errors that were not used as sentinel errors
The `ErrPortAlreadyAllocated` error was introduced in ffd68badc0,
and at the time used as sentinel error in the bridge driver. It was later
integrated into libnetwork ([libnetwork@672ced7]), and brought back when
libnetwork was integrated in v1.7.0; 272f8cd4bc
After libnetwork was integrated, the error was unused as sentinel error,
except for locally inside the package as part of a test;

    git rev-parse --verify HEAD
    496bc46c88

    git grep '\.ErrPortAlreadyAllocated'

Which is still the case Today;

    git describe --tags --match="v[0-9]*" HEAD
    v28.0.0
    git rev-parse --verify HEAD
    af898abe44
    git grep '\.ErrPortAlreadyAllocated'

Same for the `ErrAllPortsAllocated` (added in 739d124480)
and `ErrUnknownProtocol` (added in 303ed3c830)
errors, which were never used as sentinel errors, and still aren't;

    git grep '\.ErrAllPortsAllocated'
    git grep '\.ErrUnknownProtocol'
    vendor/github.com/moby/buildkit/client/llb/source.go:   if errors.Is(err, gitutil.ErrUnknownProtocol) {

This patch;

- un-exports these errors as they are not used as sentinel errors
- strips down the `ErrPortAlreadyAllocated`, removing the methods that
  were added, but never used.
- removes the `newErrPortAlreadyAllocated` constructor
- renames `ErrPortAlreadyAllocated` to `alreadyAllocatedErr` to follow
  go conventions.

[libnetwork@672ced7]: c0474b6438

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-20 23:58:44 +01:00
..