diff --git a/pkg/transport/endpoint.go b/pkg/transport/endpoint.go index efe338d..adfea6d 100644 --- a/pkg/transport/endpoint.go +++ b/pkg/transport/endpoint.go @@ -84,6 +84,7 @@ func parseSCPLike(endpoint string) (*Endpoint, bool) { Host: host, Port: port, Path: path, + raw: endpoint, }, true } @@ -110,6 +111,8 @@ type Endpoint struct { ExtraHeader map[string]string // ExtraEnv extra env ExtraEnv map[string]string + // raw endpoint: only scp like url --> zeta@domain.com:namespace/repo + raw string } type Options struct { @@ -226,8 +229,11 @@ var defaultPorts = map[string]int{ "ssh": 22, } -// String returns a string representation of the Git URL. +// String returns a string representation of the zeta URL. func (u *Endpoint) String() string { + if len(u.raw) != 0 { + return u.raw + } var buf bytes.Buffer if u.Protocol != "" { buf.WriteString(u.Protocol) diff --git a/pkg/transport/struct_test.go b/pkg/transport/struct_test.go index b439259..6a7c6dc 100644 --- a/pkg/transport/struct_test.go +++ b/pkg/transport/struct_test.go @@ -44,6 +44,7 @@ func TestEndpointIsURL(t *testing.T) { "http://xxxx", "git@xxxx", "zeta@zzzz", + "zeta@zeta.io:jack/zeta-demo", } for _, s := range sss { fmt.Fprintf(os.Stderr, "%s %v\n", s, hasScheme(s)) @@ -63,6 +64,16 @@ func TestParseEndpoint(t *testing.T) { fmt.Fprintf(os.Stderr, "Parse: %v\n", err) continue } - fmt.Fprintf(os.Stderr, "endpoint: %v protocol: %s\n", e, e.Protocol) + fmt.Fprintf(os.Stderr, "endpoint: %v protocol: %s raw: %s\n", e, e.Protocol, s) + } +} + +func TestEndpoint(t *testing.T) { + raw := "zeta@zeta.io:jack/zeta-demo" + e, err := NewEndpoint(raw, nil) + if err != nil { + fmt.Fprintf(os.Stderr, "Parse: %v\n", err) + return } + fmt.Fprintf(os.Stderr, "endpoint: %v protocol: %s raw: %s\n", e, e.Protocol, raw) }