remote: add additional connhelpers to buildx

Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
Justin Chadwell
2022-05-17 16:12:07 +01:00
parent 22ac3271d2
commit 1eff9310f8
3 changed files with 38 additions and 12 deletions

View File

@ -0,0 +1,26 @@
package remote
import (
"net/url"
"github.com/pkg/errors"
)
var schemes = map[string]struct{}{
"tcp": {},
"unix": {},
"ssh": {},
"docker-container": {},
"kube-pod": {},
}
func IsValidEndpoint(ep string) error {
endpoint, err := url.Parse(ep)
if err != nil {
return errors.Wrapf(err, "failed to parse endpoint %s", ep)
}
if _, ok := schemes[endpoint.Scheme]; !ok {
return errors.Errorf("unrecognized url scheme %s", endpoint.Scheme)
}
return nil
}