fix: allow just binary execution

This commit is contained in:
Urko. 2024-05-24 22:25:36 +02:00
parent adf47e4810
commit 9c735ccf64
2 changed files with 6 additions and 5 deletions

View File

@ -13,8 +13,8 @@ type Config struct {
} }
type ConfigScript struct { type ConfigScript struct {
Environment string `yaml:"environment"` Environment string `yaml:"environment"`
BinaryPath string `yaml:"binary"` Command string `yaml:"command"`
ScriptPath string `yaml:"script"` Arguments string `yaml:"args"`
} }
func LoadConfig(path string) (*Config, error) { func LoadConfig(path string) (*Config, error) {

View File

@ -27,6 +27,7 @@ func main() {
if err != nil { if err != nil {
log.Fatalf("Error loading config: %v", err) log.Fatalf("Error loading config: %v", err)
} }
log.Println("GOOO")
http.HandleFunc("/", handlePayload(cfg.Secret, cfg.Projects)) http.HandleFunc("/", handlePayload(cfg.Secret, cfg.Projects))
http.ListenAndServe(fmt.Sprintf(":%d", cfg.Port), nil) http.ListenAndServe(fmt.Sprintf(":%d", cfg.Port), nil)
} }
@ -80,15 +81,15 @@ func handlePayload(secret string, projects map[string][]config.ConfigScript) fun
} }
go func() { go func() {
if err := execute(scr.BinaryPath, scr.ScriptPath); err != nil { if err := execute(scr.Command, scr.Arguments); err != nil {
log.Println(err) log.Println(err)
} }
}() }()
}) })
} }
func execute(binaryPath, scriptPath string) error { func execute(command, args string) error {
cmd := exec.Command(binaryPath, scriptPath) cmd := exec.Command(command, args)
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr