Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-shell
Commits
1bade9e1
Commit
1bade9e1
authored
Sep 11, 2019
by
Ash McKenzie
Committed by
Igor Drozdov
Oct 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More consistent console messages (golang)
parent
412ed17c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
16 additions
and
22 deletions
+16
-22
cmd/gitlab-shell-authorized-keys-check/main.go
cmd/gitlab-shell-authorized-keys-check/main.go
+2
-1
cmd/gitlab-shell-authorized-principals-check/main.go
cmd/gitlab-shell-authorized-principals-check/main.go
+2
-1
cmd/gitlab-shell/main.go
cmd/gitlab-shell/main.go
+2
-1
internal/command/lfsauthenticate/lfsauthenticate_test.go
internal/command/lfsauthenticate/lfsauthenticate_test.go
+2
-2
internal/command/receivepack/customaction.go
internal/command/receivepack/customaction.go
+3
-10
internal/command/receivepack/customaction_test.go
internal/command/receivepack/customaction_test.go
+1
-1
internal/command/shared/accessverifier/accessverifier.go
internal/command/shared/accessverifier/accessverifier.go
+2
-4
internal/command/shared/accessverifier/accessverifier_test.go
...rnal/command/shared/accessverifier/accessverifier_test.go
+1
-1
internal/command/shared/disallowedcommand/disallowedcommand.go
...nal/command/shared/disallowedcommand/disallowedcommand.go
+1
-1
No files found.
cmd/gitlab-shell-authorized-keys-check/main.go
View file @
1bade9e1
...
...
@@ -7,6 +7,7 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/internal/command"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/internal/console"
"gitlab.com/gitlab-org/gitlab-shell/internal/executable"
)
...
...
@@ -38,7 +39,7 @@ func main() {
}
if
err
=
cmd
.
Execute
();
err
!=
nil
{
fmt
.
Fprintf
(
readWriter
.
ErrOut
,
"%v
\n
"
,
err
)
console
.
DisplayWarningMessage
(
err
.
Error
(),
readWriter
.
ErrOut
)
os
.
Exit
(
1
)
}
}
cmd/gitlab-shell-authorized-principals-check/main.go
View file @
1bade9e1
...
...
@@ -7,6 +7,7 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/internal/command"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/internal/console"
"gitlab.com/gitlab-org/gitlab-shell/internal/executable"
)
...
...
@@ -38,7 +39,7 @@ func main() {
}
if
err
=
cmd
.
Execute
();
err
!=
nil
{
fmt
.
Fprintf
(
readWriter
.
ErrOut
,
"%v
\n
"
,
err
)
console
.
DisplayWarningMessage
(
err
.
Error
(),
readWriter
.
ErrOut
)
os
.
Exit
(
1
)
}
}
cmd/gitlab-shell/main.go
View file @
1bade9e1
...
...
@@ -7,6 +7,7 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/internal/command"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/internal/console"
"gitlab.com/gitlab-org/gitlab-shell/internal/executable"
)
...
...
@@ -38,7 +39,7 @@ func main() {
}
if
err
=
cmd
.
Execute
();
err
!=
nil
{
fmt
.
Fprintf
(
readWriter
.
ErrOut
,
"%v
\n
"
,
err
)
console
.
DisplayWarningMessage
(
err
.
Error
(),
readWriter
.
ErrOut
)
os
.
Exit
(
1
)
}
}
internal/command/lfsauthenticate/lfsauthenticate_test.go
View file @
1bade9e1
...
...
@@ -31,12 +31,12 @@ func TestFailedRequests(t *testing.T) {
{
desc
:
"With missing arguments"
,
arguments
:
&
commandargs
.
Shell
{},
expectedOutput
:
"
> GitLab:
Disallowed command"
,
expectedOutput
:
"Disallowed command"
,
},
{
desc
:
"With disallowed command"
,
arguments
:
&
commandargs
.
Shell
{
GitlabKeyId
:
"1"
,
SshArgs
:
[]
string
{
"git-lfs-authenticate"
,
"group/repo"
,
"unknown"
}},
expectedOutput
:
"
> GitLab:
Disallowed command"
,
expectedOutput
:
"Disallowed command"
,
},
{
desc
:
"With disallowed user"
,
...
...
internal/command/receivepack/customaction.go
View file @
1bade9e1
...
...
@@ -3,12 +3,13 @@ package receivepack
import
(
"bytes"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"strings"
"gitlab.com/gitlab-org/gitlab-shell/internal/console"
"gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet"
"gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/accessverifier"
)
...
...
@@ -32,19 +33,11 @@ func (c *Command) processCustomAction(response *accessverifier.Response) error {
return
errors
.
New
(
"Custom action error: Empty API endpoints"
)
}
c
.
displayInfoMessage
(
data
.
InfoMessage
)
c
onsole
.
DisplayInfoMessages
(
strings
.
Split
(
data
.
InfoMessage
,
"
\n
"
),
c
.
ReadWriter
.
ErrOut
)
return
c
.
processApiEndpoints
(
response
)
}
func
(
c
*
Command
)
displayInfoMessage
(
infoMessage
string
)
{
messages
:=
strings
.
Split
(
infoMessage
,
"
\n
"
)
for
_
,
msg
:=
range
messages
{
fmt
.
Fprintf
(
c
.
ReadWriter
.
ErrOut
,
"> GitLab: %v
\n
"
,
msg
)
}
}
func
(
c
*
Command
)
processApiEndpoints
(
response
*
accessverifier
.
Response
)
error
{
client
,
err
:=
gitlabnet
.
GetClient
(
c
.
Config
)
...
...
internal/command/receivepack/customaction_test.go
View file @
1bade9e1
...
...
@@ -100,6 +100,6 @@ func TestCustomReceivePack(t *testing.T) {
// expect printing of info message, "custom" string from the first request
// and "output" string from the second request
require
.
Equal
(
t
,
"
> GitLab: info_message
\n
> GitLab: one more message
\n
"
,
errBuf
.
String
())
require
.
Equal
(
t
,
"
remote:
\n
remote: info_message
\n
remote: one more message
\n
remote:
\n
"
,
errBuf
.
String
())
require
.
Equal
(
t
,
"customoutput"
,
outBuf
.
String
())
}
internal/command/shared/accessverifier/accessverifier.go
View file @
1bade9e1
...
...
@@ -2,11 +2,11 @@ package accessverifier
import
(
"errors"
"fmt"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/internal/console"
"gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/accessverifier"
)
...
...
@@ -39,7 +39,5 @@ func (c *Command) Verify(action commandargs.CommandType, repo string) (*Response
}
func
(
c
*
Command
)
displayConsoleMessages
(
messages
[]
string
)
{
for
_
,
msg
:=
range
messages
{
fmt
.
Fprintf
(
c
.
ReadWriter
.
ErrOut
,
"> GitLab: %v
\n
"
,
msg
)
}
console
.
DisplayInfoMessages
(
messages
,
c
.
ReadWriter
.
ErrOut
)
}
internal/command/shared/accessverifier/accessverifier_test.go
View file @
1bade9e1
...
...
@@ -77,6 +77,6 @@ func TestConsoleMessages(t *testing.T) {
cmd
.
Args
=
&
commandargs
.
Shell
{
GitlabKeyId
:
"1"
}
cmd
.
Verify
(
action
,
repo
)
require
.
Equal
(
t
,
"
> GitLab: console
\n
> GitLab: message
\n
"
,
errBuf
.
String
())
require
.
Equal
(
t
,
"
remote:
\n
remote: console
\n
remote: message
\n
remote:
\n
"
,
errBuf
.
String
())
require
.
Empty
(
t
,
outBuf
.
String
())
}
internal/command/shared/disallowedcommand/disallowedcommand.go
View file @
1bade9e1
...
...
@@ -3,5 +3,5 @@ package disallowedcommand
import
"errors"
var
(
Error
=
errors
.
New
(
"
> GitLab:
Disallowed command"
)
Error
=
errors
.
New
(
"Disallowed command"
)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment