2024-01-30 16:42:56 +01:00
|
|
|
package db_lib
|
|
|
|
|
|
|
|
import (
|
2024-10-22 08:46:26 +02:00
|
|
|
"fmt"
|
2024-01-30 16:42:56 +01:00
|
|
|
"os"
|
2024-04-12 12:32:54 +02:00
|
|
|
|
2024-10-26 14:56:17 +02:00
|
|
|
"github.com/semaphoreui/semaphore/pkg/task_logger"
|
|
|
|
"github.com/semaphoreui/semaphore/util"
|
2024-01-30 16:42:56 +01:00
|
|
|
)
|
|
|
|
|
2024-10-22 08:35:55 +02:00
|
|
|
func getEnvironmentVars() []string {
|
2024-10-27 23:14:18 +01:00
|
|
|
res := []string{
|
|
|
|
fmt.Sprintf("PATH=%s", os.Getenv("PATH")),
|
|
|
|
}
|
2024-10-24 19:53:33 +02:00
|
|
|
|
2024-10-24 20:07:25 +02:00
|
|
|
for _, e := range util.Config.ForwardedEnvVars {
|
|
|
|
v := os.Getenv(e)
|
|
|
|
if v != "" {
|
|
|
|
res = append(res, fmt.Sprintf("%s=%s", e, v))
|
2024-10-24 19:53:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for k, v := range util.Config.EnvVars {
|
2024-10-22 08:46:26 +02:00
|
|
|
res = append(res, fmt.Sprintf("%s=%s", k, v))
|
2024-10-22 08:35:55 +02:00
|
|
|
}
|
2024-10-24 19:53:33 +02:00
|
|
|
|
2024-10-22 08:35:55 +02:00
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
2024-11-24 11:32:24 +01:00
|
|
|
type LocalAppRunningArgs struct {
|
|
|
|
CliArgs []string
|
|
|
|
EnvironmentVars *[]string
|
|
|
|
Inputs map[string]string
|
|
|
|
TaskParams interface{}
|
|
|
|
Callback func(*os.Process)
|
|
|
|
}
|
|
|
|
|
2024-01-30 16:42:56 +01:00
|
|
|
type LocalApp interface {
|
2024-04-12 12:32:54 +02:00
|
|
|
SetLogger(logger task_logger.Logger) task_logger.Logger
|
2024-12-06 14:53:46 +01:00
|
|
|
InstallRequirements(environmentVars *[]string, params interface{}) error
|
2024-11-24 11:32:24 +01:00
|
|
|
Run(args LocalAppRunningArgs) error
|
2024-01-30 16:42:56 +01:00
|
|
|
}
|