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
|
||||
// +build !windows
|
||||
|
||||
package remote
|
||||
package remoteutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package remote
|
||||
package remoteutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package remote
|
||||
package remoteutil
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"slices"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var schemes = map[string]struct{}{
|
||||
"tcp": {},
|
||||
"unix": {},
|
||||
"ssh": {},
|
||||
"docker-container": {},
|
||||
"kube-pod": {},
|
||||
"npipe": {},
|
||||
var schemes = []string{
|
||||
"docker-container",
|
||||
"kube-pod",
|
||||
"npipe",
|
||||
"ssh",
|
||||
"tcp",
|
||||
"unix",
|
||||
}
|
||||
|
||||
func IsValidEndpoint(ep string) error {
|
||||
|
@ -20,7 +21,7 @@ func IsValidEndpoint(ep string) error {
|
|||
if err != nil {
|
||||
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 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