aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/internal/common
diff options
context:
space:
mode:
authorAnthony Weems <amlweems@gmail.com>2017-01-17 11:17:11 -0600
committerSantiago M. Mola <santi@mola.io>2017-01-17 18:17:11 +0100
commit6593c757346f9817a770ff0ea091cce3e8243070 (patch)
tree6fbb72583931b0386e382177970650a9cdbca4eb /plumbing/transport/internal/common
parent241e8ba00ac9533299d62dc38684305af2b6c301 (diff)
downloadgo-git-6593c757346f9817a770ff0ea091cce3e8243070.tar.gz
transport: remove SetAuth, fixes #206 (#210)
* remove SetAuth functions, implement at NewUploadPackSession/NewReceivePackSession level. * propagate transport.Auth from Fetch/Pull/Clone options to the transport API.
Diffstat (limited to 'plumbing/transport/internal/common')
-rw-r--r--plumbing/transport/internal/common/common.go21
1 files changed, 7 insertions, 14 deletions
diff --git a/plumbing/transport/internal/common/common.go b/plumbing/transport/internal/common/common.go
index 831c4d7..2285e26 100644
--- a/plumbing/transport/internal/common/common.go
+++ b/plumbing/transport/internal/common/common.go
@@ -37,15 +37,13 @@ type Commander interface {
// error should be returned if the endpoint is not supported or the
// command cannot be created (e.g. binary does not exist, connection
// cannot be established).
- Command(cmd string, ep transport.Endpoint) (Command, error)
+ Command(cmd string, ep transport.Endpoint, auth transport.AuthMethod) (Command, error)
}
// Command is used for a single command execution.
// This interface is modeled after exec.Cmd and ssh.Session in the standard
// library.
type Command interface {
- // SetAuth sets the authentication method.
- SetAuth(transport.AuthMethod) error
// StderrPipe returns a pipe that will be connected to the command's
// standard error when the command starts. It should not be called after
// Start.
@@ -82,17 +80,17 @@ func NewClient(runner Commander) transport.Transport {
}
// NewUploadPackSession creates a new UploadPackSession.
-func (c *client) NewUploadPackSession(ep transport.Endpoint) (
+func (c *client) NewUploadPackSession(ep transport.Endpoint, auth transport.AuthMethod) (
transport.UploadPackSession, error) {
- return c.newSession(transport.UploadPackServiceName, ep)
+ return c.newSession(transport.UploadPackServiceName, ep, auth)
}
// NewReceivePackSession creates a new ReceivePackSession.
-func (c *client) NewReceivePackSession(ep transport.Endpoint) (
+func (c *client) NewReceivePackSession(ep transport.Endpoint, auth transport.AuthMethod) (
transport.ReceivePackSession, error) {
- return c.newSession(transport.ReceivePackServiceName, ep)
+ return c.newSession(transport.ReceivePackServiceName, ep, auth)
}
type session struct {
@@ -107,8 +105,8 @@ type session struct {
errLines chan string
}
-func (c *client) newSession(s string, ep transport.Endpoint) (*session, error) {
- cmd, err := c.cmdr.Command(s, ep)
+func (c *client) newSession(s string, ep transport.Endpoint, auth transport.AuthMethod) (*session, error) {
+ cmd, err := c.cmdr.Command(s, ep, auth)
if err != nil {
return nil, err
}
@@ -158,11 +156,6 @@ func (c *client) listenErrors(r io.Reader) chan string {
return errLines
}
-// SetAuth delegates to the command's SetAuth.
-func (s *session) SetAuth(auth transport.AuthMethod) error {
- return s.Command.SetAuth(auth)
-}
-
// AdvertisedReferences retrieves the advertised references from the server.
func (s *session) AdvertisedReferences() (*packp.AdvRefs, error) {
if s.advRefs != nil {