mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 10:03:42 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			514 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			514 B
		
	
	
	
		
			Go
		
	
	
	
	
	
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
 | 
						|
}
 |