summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
+}