summaryrefslogtreecommitdiff
path: root/go/internal/executable/executable.go
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-10-17 12:04:52 +0100
committerNick Thomas <nick@gitlab.com>2019-10-18 11:47:25 +0100
commit83d11f4deeb20b852a0af3433190a0f7250a0027 (patch)
tree1a9df18d6f9f59712c6f5c98e995a4918eb94a11 /go/internal/executable/executable.go
parent7d5229db263a62661653431881bef8b46984d0de (diff)
downloadgitlab-shell-83d11f4deeb20b852a0af3433190a0f7250a0027.tar.gz
Move go code up one level
Diffstat (limited to 'go/internal/executable/executable.go')
-rw-r--r--go/internal/executable/executable.go60
1 files changed, 0 insertions, 60 deletions
diff --git a/go/internal/executable/executable.go b/go/internal/executable/executable.go
deleted file mode 100644
index c6355b9..0000000
--- a/go/internal/executable/executable.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package executable
-
-import (
- "os"
- "path/filepath"
-)
-
-const (
- BinDir = "bin"
- Healthcheck = "check"
- GitlabShell = "gitlab-shell"
- AuthorizedKeysCheck = "gitlab-shell-authorized-keys-check"
- AuthorizedPrincipalsCheck = "gitlab-shell-authorized-principals-check"
-)
-
-type Executable struct {
- Name string
- RootDir string
-}
-
-var (
- // osExecutable is overridden in tests
- osExecutable = os.Executable
-)
-
-func New(name string) (*Executable, error) {
- path, err := osExecutable()
- if err != nil {
- return nil, err
- }
-
- rootDir, err := findRootDir(path)
- if err != nil {
- return nil, err
- }
-
- executable := &Executable{
- Name: name,
- RootDir: rootDir,
- }
-
- return executable, nil
-}
-
-func findRootDir(path string) (string, error) {
- // Start: /opt/.../gitlab-shell/bin/gitlab-shell
- // Ends: /opt/.../gitlab-shell
- rootDir := filepath.Dir(filepath.Dir(path))
- pathFromEnv := os.Getenv("GITLAB_SHELL_DIR")
-
- if pathFromEnv != "" {
- if _, err := os.Stat(pathFromEnv); os.IsNotExist(err) {
- return "", err
- }
-
- rootDir = pathFromEnv
- }
-
- return rootDir, nil
-}