Commit 81f58545 authored by Nick Thomas's avatar Nick Thomas

Merge branch '206-quick-fix' into 'master'

Replace symlinks with actual binaries

Closes #206

See merge request gitlab-org/gitlab-shell!324
parents f34e2cd5 41f919eb
...@@ -13,6 +13,8 @@ custom_hooks ...@@ -13,6 +13,8 @@ custom_hooks
hooks/*.d hooks/*.d
/go_build /go_build
/bin/gitlab-shell /bin/gitlab-shell
/bin/gitlab-shell-authorized-keys-check
/bin/gitlab-shell-authorized-principals-check
/bin/gitaly-upload-pack /bin/gitaly-upload-pack
/bin/gitaly-receive-pack /bin/gitaly-receive-pack
/bin/gitaly-upload-archive /bin/gitaly-upload-archive
...@@ -13,17 +13,14 @@ verify_golang: ...@@ -13,17 +13,14 @@ verify_golang:
test: test_ruby test_golang test: test_ruby test_golang
test_ruby: test_ruby:
# bin/gitlab-shell must exist and needs to be the Ruby version for # bin/gitlab-shell, bin/gitlab-shell-authorized-keys-check and
# rspec to be able to test. # bin/gitlab-shell-authorized-principals-check must exist and need to be
# the Ruby version for rspec to be able to test.
cp bin/gitlab-shell-ruby bin/gitlab-shell cp bin/gitlab-shell-ruby bin/gitlab-shell
# bin/gitlab-shell-authorized-keys-check and bin/gitlab-shell-authorized-principals-check cp bin/gitlab-shell-authorized-keys-check-ruby bin/gitlab-shell-authorized-keys-check
# should link to ruby scripts for rspec to be able to test. cp bin/gitlab-shell-authorized-principals-check-ruby bin/gitlab-shell-authorized-principals-check
ln -sf ./gitlab-shell-authorized-keys-check-ruby bin/gitlab-shell-authorized-keys-check
ln -sf ./gitlab-shell-authorized-principals-check-ruby bin/gitlab-shell-authorized-principals-check
bundle exec rspec --color --tag '~go' --format d spec bundle exec rspec --color --tag '~go' --format d spec
rm -f bin/gitlab-shell rm -f bin/gitlab-shell bin/gitlab-shell-authorized-keys-check bin/gitlab-shell-authorized-principals-check
ln -sf ./gitlab-shell bin/gitlab-shell-authorized-keys-check
ln -sf ./gitlab-shell bin/gitlab-shell-authorized-principals-check
test_golang: test_golang:
support/go-test support/go-test
...@@ -42,4 +39,4 @@ check: ...@@ -42,4 +39,4 @@ check:
bin/check bin/check
clean: clean:
rm -f bin/gitlab-shell rm -f bin/gitlab-shell bin/gitlab-shell-authorized-keys-check bin/gitlab-shell-authorized-principals-check
./gitlab-shell
\ No newline at end of file
./gitlab-shell
\ No newline at end of file
package main
import (
"fmt"
"os"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/executable"
)
func main() {
readWriter := &readwriter.ReadWriter{
Out: os.Stdout,
In: os.Stdin,
ErrOut: os.Stderr,
}
executable, err := executable.New(executable.AuthorizedKeysCheck)
if err != nil {
fmt.Fprintln(readWriter.ErrOut, "Failed to determine executable, exiting")
os.Exit(1)
}
config, err := config.NewFromDir(executable.RootDir)
if err != nil {
fmt.Fprintln(readWriter.ErrOut, "Failed to read config, exiting")
os.Exit(1)
}
cmd, err := command.New(executable, os.Args[1:], config, readWriter)
if err != nil {
// For now this could happen if `SSH_CONNECTION` is not set on
// the environment
fmt.Fprintf(readWriter.ErrOut, "%v\n", err)
os.Exit(1)
}
// The command will write to STDOUT on execution or replace the current
// process in case of the `fallback.Command`
if err = cmd.Execute(); err != nil {
fmt.Fprintf(readWriter.ErrOut, "%v\n", err)
os.Exit(1)
}
}
package main
import (
"fmt"
"os"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/executable"
)
func main() {
readWriter := &readwriter.ReadWriter{
Out: os.Stdout,
In: os.Stdin,
ErrOut: os.Stderr,
}
executable, err := executable.New(executable.AuthorizedPrincipalsCheck)
if err != nil {
fmt.Fprintln(readWriter.ErrOut, "Failed to determine executable, exiting")
os.Exit(1)
}
config, err := config.NewFromDir(executable.RootDir)
if err != nil {
fmt.Fprintln(readWriter.ErrOut, "Failed to read config, exiting")
os.Exit(1)
}
cmd, err := command.New(executable, os.Args[1:], config, readWriter)
if err != nil {
// For now this could happen if `SSH_CONNECTION` is not set on
// the environment
fmt.Fprintf(readWriter.ErrOut, "%v\n", err)
os.Exit(1)
}
// The command will write to STDOUT on execution or replace the current
// process in case of the `fallback.Command`
if err = cmd.Execute(); err != nil {
fmt.Fprintf(readWriter.ErrOut, "%v\n", err)
os.Exit(1)
}
}
...@@ -17,7 +17,7 @@ func main() { ...@@ -17,7 +17,7 @@ func main() {
ErrOut: os.Stderr, ErrOut: os.Stderr,
} }
executable, err := executable.New() executable, err := executable.New(executable.GitlabShell)
if err != nil { if err != nil {
fmt.Fprintln(readWriter.ErrOut, "Failed to determine executable, exiting") fmt.Fprintln(readWriter.ErrOut, "Failed to determine executable, exiting")
os.Exit(1) os.Exit(1)
......
...@@ -22,7 +22,7 @@ var ( ...@@ -22,7 +22,7 @@ var (
osExecutable = os.Executable osExecutable = os.Executable
) )
func New() (*Executable, error) { func New(name string) (*Executable, error) {
path, err := osExecutable() path, err := osExecutable()
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -34,7 +34,7 @@ func New() (*Executable, error) { ...@@ -34,7 +34,7 @@ func New() (*Executable, error) {
} }
executable := &Executable{ executable := &Executable{
Name: filepath.Base(path), Name: name,
RootDir: rootDir, RootDir: rootDir,
} }
......
...@@ -59,7 +59,7 @@ func TestNewSuccess(t *testing.T) { ...@@ -59,7 +59,7 @@ func TestNewSuccess(t *testing.T) {
fake.Setup() fake.Setup()
defer fake.Cleanup() defer fake.Cleanup()
result, err := New() result, err := New("gitlab-shell")
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, result.Name, "gitlab-shell") require.Equal(t, result.Name, "gitlab-shell")
...@@ -96,7 +96,7 @@ func TestNewFailure(t *testing.T) { ...@@ -96,7 +96,7 @@ func TestNewFailure(t *testing.T) {
fake.Setup() fake.Setup()
defer fake.Cleanup() defer fake.Cleanup()
_, err := New() _, err := New("gitlab-shell")
require.Error(t, err) require.Error(t, err)
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment