summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Drozdov <idrozdov@gitlab.com>2020-07-23 12:44:57 +0000
committerIgor Drozdov <idrozdov@gitlab.com>2020-07-23 12:44:57 +0000
commit701ebca0b5d4a8451afe677c3bdb19cc92a5a2f0 (patch)
tree95b395f208bc2d4e5547a125b0bfe81acce928bb
parent869aeb9057962b089abfd8ce0b6d4a0962bbb154 (diff)
parentbbb1de8d2b3f3dfc872308f804743b8c30626791 (diff)
downloadgitlab-shell-701ebca0b5d4a8451afe677c3bdb19cc92a5a2f0.tar.gz
Merge branch 'revert-869aeb90' into 'master'
Revert "Update executable.go" See merge request gitlab-org/gitlab-shell!403
-rw-r--r--internal/executable/executable.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/executable/executable.go b/internal/executable/executable.go
index c6253b1..c6355b9 100644
--- a/internal/executable/executable.go
+++ b/internal/executable/executable.go
@@ -13,6 +13,11 @@ const (
AuthorizedPrincipalsCheck = "gitlab-shell-authorized-principals-check"
)
+type Executable struct {
+ Name string
+ RootDir string
+}
+
var (
// osExecutable is overridden in tests
osExecutable = os.Executable
@@ -36,3 +41,20 @@ func New(name string) (*Executable, error) {
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
+}