mirror of https://github.com/docker/buildx.git
remoteutil: fix pkg remove unnecessary map initialization
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
85cf3bace9
commit
52bb668085
|
@ -1,7 +1,7 @@
|
||||||
//go:build !windows
|
//go:build !windows
|
||||||
// +build !windows
|
// +build !windows
|
||||||
|
|
||||||
package remote
|
package remoteutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package remote
|
package remoteutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
package remote
|
package remoteutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var schemes = map[string]struct{}{
|
var schemes = []string{
|
||||||
"tcp": {},
|
"docker-container",
|
||||||
"unix": {},
|
"kube-pod",
|
||||||
"ssh": {},
|
"npipe",
|
||||||
"docker-container": {},
|
"ssh",
|
||||||
"kube-pod": {},
|
"tcp",
|
||||||
"npipe": {},
|
"unix",
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsValidEndpoint(ep string) error {
|
func IsValidEndpoint(ep string) error {
|
||||||
|
@ -20,7 +21,7 @@ func IsValidEndpoint(ep string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to parse endpoint %s", ep)
|
return errors.Wrapf(err, "failed to parse endpoint %s", ep)
|
||||||
}
|
}
|
||||||
if _, ok := schemes[endpoint.Scheme]; !ok {
|
if _, ok := slices.BinarySearch(schemes, endpoint.Scheme); !ok {
|
||||||
return errors.Errorf("unrecognized url scheme %s", endpoint.Scheme)
|
return errors.Errorf("unrecognized url scheme %s", endpoint.Scheme)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package remoteutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"slices"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSchemes(t *testing.T) {
|
||||||
|
require.True(t, slices.IsSorted(schemes))
|
||||||
|
}
|
Loading…
Reference in New Issue