File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,15 @@ func main() {
72
72
}
73
73
cfg .SecretKey = secretKey
74
74
75
- tmpl , err := template .ParseFiles ("pmcompose_templates/docker-compose.yaml.tmpl" )
75
+ dir , err := utils .GetExecutableDir ()
76
+ if err != nil {
77
+ fmt .Printf ("Error: %v\n " , err )
78
+ return
79
+ }
80
+
81
+ templatePath := fmt .Sprintf ("%s/pmcompose_templates/docker-compose.yaml.tmpl" , dir )
82
+
83
+ tmpl , err := template .ParseFiles (templatePath )
76
84
if err != nil {
77
85
fmt .Println ("Error loading template:" , err )
78
86
return
Original file line number Diff line number Diff line change @@ -2,7 +2,10 @@ package utils
2
2
3
3
import (
4
4
"crypto/rand"
5
+ "fmt"
5
6
"math/big"
7
+ "os"
8
+ "path/filepath"
6
9
"strings"
7
10
)
8
11
@@ -31,3 +34,17 @@ func GenerateSecretString(length int) (string, error) {
31
34
32
35
return sb .String (), nil
33
36
}
37
+
38
+ func GetExecutableDir () (string , error ) {
39
+ execPath , err := os .Executable ()
40
+ if err != nil {
41
+ return "" , fmt .Errorf ("failed to get executable path: %w" , err )
42
+ }
43
+
44
+ realPath , err := filepath .EvalSymlinks (execPath )
45
+ if err != nil {
46
+ return "" , fmt .Errorf ("failed to resolve symlinks: %w" , err )
47
+ }
48
+
49
+ return filepath .Dir (realPath ), nil
50
+ }
You can’t perform that action at this time.
0 commit comments