summaryrefslogtreecommitdiff
path: root/internal/command/lfsauthenticate/lfsauthenticate.go
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-11-28 14:49:33 +1100
committerAsh McKenzie <amckenzie@gitlab.com>2019-12-03 15:17:07 +1100
commitf0a6e62da76c53a0853bcd0c3a6e0c9c384f5dea (patch)
treebc6bc10c843c34eb4d17ff6e6f1172a7f7986c79 /internal/command/lfsauthenticate/lfsauthenticate.go
parent0afa8ec5fcc571d7bdfb5f52533e3df4ab78f793 (diff)
downloadgitlab-shell-f0a6e62da76c53a0853bcd0c3a6e0c9c384f5dea.tar.gz
Use correct LFS download or upload operation names
Diffstat (limited to 'internal/command/lfsauthenticate/lfsauthenticate.go')
-rw-r--r--internal/command/lfsauthenticate/lfsauthenticate.go32
1 files changed, 18 insertions, 14 deletions
diff --git a/internal/command/lfsauthenticate/lfsauthenticate.go b/internal/command/lfsauthenticate/lfsauthenticate.go
index 1b2a742..2aaac2a 100644
--- a/internal/command/lfsauthenticate/lfsauthenticate.go
+++ b/internal/command/lfsauthenticate/lfsauthenticate.go
@@ -14,8 +14,8 @@ import (
)
const (
- downloadAction = "download"
- uploadAction = "upload"
+ downloadOperation = "download"
+ uploadOperation = "upload"
)
type Command struct {
@@ -40,8 +40,11 @@ func (c *Command) Execute() error {
return disallowedcommand.Error
}
+ // e.g. git-lfs-authenticate user/repo.git download
repo := args[1]
- action, err := actionToCommandType(args[2])
+ operation := args[2]
+
+ action, err := actionFromOperation(operation)
if err != nil {
return err
}
@@ -51,7 +54,7 @@ func (c *Command) Execute() error {
return err
}
- payload, err := c.authenticate(action, repo, accessResponse.UserId)
+ payload, err := c.authenticate(operation, repo, accessResponse.UserId)
if err != nil {
// return nothing just like Ruby's GitlabShell#lfs_authenticate does
return nil
@@ -62,18 +65,19 @@ func (c *Command) Execute() error {
return nil
}
-func actionToCommandType(action string) (commandargs.CommandType, error) {
- var accessAction commandargs.CommandType
- switch action {
- case downloadAction:
- accessAction = commandargs.UploadPack
- case uploadAction:
- accessAction = commandargs.ReceivePack
+func actionFromOperation(operation string) (commandargs.CommandType, error) {
+ var action commandargs.CommandType
+
+ switch operation {
+ case downloadOperation:
+ action = commandargs.UploadPack
+ case uploadOperation:
+ action = commandargs.ReceivePack
default:
return "", disallowedcommand.Error
}
- return accessAction, nil
+ return action, nil
}
func (c *Command) verifyAccess(action commandargs.CommandType, repo string) (*accessverifier.Response, error) {
@@ -82,13 +86,13 @@ func (c *Command) verifyAccess(action commandargs.CommandType, repo string) (*ac
return cmd.Verify(action, repo)
}
-func (c *Command) authenticate(action commandargs.CommandType, repo, userId string) ([]byte, error) {
+func (c *Command) authenticate(operation string, repo, userId string) ([]byte, error) {
client, err := lfsauthenticate.NewClient(c.Config, c.Args)
if err != nil {
return nil, err
}
- response, err := client.Authenticate(action, repo, userId)
+ response, err := client.Authenticate(operation, repo, userId)
if err != nil {
return nil, err
}