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
1f8556b2
Commit
1f8556b2
authored
Aug 28, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial feature-flagged go/ruby switch
parent
1cc2993f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
6 deletions
+53
-6
.gitignore
.gitignore
+1
-0
bin/gitlab-shell-ruby
bin/gitlab-shell-ruby
+0
-0
config.yml.example
config.yml.example
+3
-0
go/cmd/gitlab-shell/main.go
go/cmd/gitlab-shell/main.go
+36
-0
go/internal/config/config.go
go/internal/config/config.go
+4
-3
go/internal/config/config_test.go
go/internal/config/config_test.go
+9
-3
No files found.
.gitignore
View file @
1f8556b2
...
...
@@ -12,6 +12,7 @@ tags
custom_hooks
hooks/*.d
/go_build
/bin/gitlab-shell
/bin/gitaly-upload-pack
/bin/gitaly-receive-pack
/bin/gitaly-upload-archive
bin/gitlab-shell
→
bin/gitlab-shell
-ruby
View file @
1f8556b2
File moved
config.yml.example
View file @
1f8556b2
...
...
@@ -49,3 +49,6 @@ log_level: INFO
# Set to true to see real usernames in the logs instead of key ids, which is easier to follow, but
# incurs an extra API call on every gitlab-shell command.
audit_usernames: false
# Feature flag: go or ruby
experimental: false
go/cmd/gitlab-shell/main.go
0 → 100644
View file @
1f8556b2
package
main
import
(
"fmt"
"os"
"path/filepath"
"syscall"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/config"
)
func
experiment
()
{
fmt
.
Println
(
"Experiment! nothing works!"
)
os
.
Exit
(
1
)
}
func
main
()
{
root
:=
filepath
.
Dir
(
os
.
Args
[
0
])
ruby
:=
filepath
.
Join
(
root
,
"gitlab-shell-ruby"
)
config
,
err
:=
config
.
New
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
}
if
config
.
Experimental
{
experiment
()
}
else
{
execErr
:=
syscall
.
Exec
(
ruby
,
os
.
Args
,
os
.
Environ
())
if
execErr
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Failed to exec(%q): %v
\n
"
,
ruby
,
execErr
)
os
.
Exit
(
1
)
}
}
}
go/internal/config/config.go
View file @
1f8556b2
...
...
@@ -14,9 +14,10 @@ const (
)
type
Config
struct
{
RootDir
string
LogFile
string
`yaml:"log_file"`
LogFormat
string
`yaml:"log_format"`
RootDir
string
LogFile
string
`yaml:"log_file"`
LogFormat
string
`yaml:"log_format"`
Experimental
bool
`yaml:"experimental"`
}
func
New
()
(
*
Config
,
error
)
{
...
...
go/internal/config/config_test.go
View file @
1f8556b2
...
...
@@ -8,14 +8,16 @@ import (
func
TestConfigLogFile
(
t
*
testing
.
T
)
{
testRoot
:=
"/foo/bar"
testCases
:=
[]
struct
{
yaml
string
path
string
format
string
yaml
string
path
string
format
string
experimental
bool
}{
{
path
:
"/foo/bar/gitlab-shell.log"
,
format
:
"text"
},
{
yaml
:
"log_file: my-log.log"
,
path
:
"/foo/bar/my-log.log"
,
format
:
"text"
},
{
yaml
:
"log_file: /qux/my-log.log"
,
path
:
"/qux/my-log.log"
,
format
:
"text"
},
{
yaml
:
"log_format: json"
,
path
:
"/foo/bar/gitlab-shell.log"
,
format
:
"json"
},
{
yaml
:
"experimental: true"
,
path
:
"/foo/bar/gitlab-shell.log"
,
format
:
"text"
,
experimental
:
true
},
}
for
_
,
tc
:=
range
testCases
{
...
...
@@ -25,6 +27,10 @@ func TestConfigLogFile(t *testing.T) {
t
.
Fatal
(
err
)
}
if
cfg
.
Experimental
!=
tc
.
experimental
{
t
.
Fatalf
(
"expected %v, got %v"
,
tc
.
experimental
,
cfg
.
Experimental
)
}
if
cfg
.
LogFile
!=
tc
.
path
{
t
.
Fatalf
(
"expected %q, got %q"
,
tc
.
path
,
cfg
.
LogFile
)
}
...
...
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