Skip to content

Commit

Permalink
feat: set plugins path
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-goto committed Oct 18, 2024
1 parent 7879ab3 commit adac6c7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ With the github plugin, there is a Receiver Plugin and a Handler Plugin.
---
work_dir: /tmp/
pid_file_dir: /tmp/
plugins_path: ~/.config/anklet/plugins/
log:
# if file_dir is not set, it will be set to current directory you execute anklet in
file_dir: /Users/myUser/Library/Logs/
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Config struct {
WorkDir string `yaml:"work_dir"`
Metrics Metrics `yaml:"metrics"`
GlobalPrivateKey string `yaml:"global_private_key"`
PluginsPath string `yaml:"plugins_path"`
}

type Log struct {
Expand Down
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ func main() {
// return
// }

pluginsPath := filepath.Join(homeDir, ".config", "anklet", "plugins")
var pluginsPath string
if loadedConfig.PluginsPath != "" {
pluginsPath = loadedConfig.PluginsPath
} else {
pluginsPath = filepath.Join(homeDir, ".config", "anklet", "plugins")
}
parentCtx = context.WithValue(parentCtx, config.ContextKey("globals"), config.Globals{
RunOnce: runOnce,
PullLock: &sync.Mutex{},
Expand Down
2 changes: 1 addition & 1 deletion plugins/handlers/github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
echo "123"
```

Finally, the `github` plugin requires three different bash scripts available on the host, which it will copy into the VM and run. You can find them under https://github.com/veertuinc/anklet/tree/main/plugins/handlers/github. They can be customized to fit your needs. You'll need to place all three in `~/.config/anklet/plugins/handlers/github/`.
Finally, the `github` plugin requires three different bash scripts available on the host, which it will copy into the VM and run. You can find them under https://github.com/veertuinc/anklet/tree/main/plugins/handlers/github. They can be customized to fit your needs. You'll need to place all three in the path that you specify with `plugins_path + "/handlers/github/"` in the global config, defaults to `~/.config/anklet/plugins/handlers/github/`.

---

Expand Down
7 changes: 4 additions & 3 deletions plugins/handlers/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log/slog"
"os"
"path/filepath"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -773,9 +774,9 @@ func Run(
// Install runner
globals := config.GetGlobalsFromContext(pluginCtx)
logger.InfoContext(pluginCtx, "installing github runner inside of vm")
installRunnerPath := globals.PluginsPath + "/handlers/github/install-runner.bash"
registerRunnerPath := globals.PluginsPath + "/handlers/github/register-runner.bash"
startRunnerPath := globals.PluginsPath + "/handlers/github/start-runner.bash"
installRunnerPath := filepath.Join(globals.PluginsPath, "handlers", "github", "install-runner.bash")
registerRunnerPath := filepath.Join(globals.PluginsPath, "handlers", "github", "register-runner.bash")
startRunnerPath := filepath.Join(globals.PluginsPath, "handlers", "github", "start-runner.bash")
_, installRunnerErr := os.Stat(installRunnerPath)
_, registerRunnerErr := os.Stat(registerRunnerPath)
_, startRunnerErr := os.Stat(startRunnerPath)
Expand Down

0 comments on commit adac6c7

Please sign in to comment.