add forgeinstance
This commit is contained in:
parent
9c7d2be7c6
commit
378966e45f
7 changed files with 28 additions and 22 deletions
|
@ -20,11 +20,11 @@ import (
|
|||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
func runDaemon(ctx context.Context, task *runtime.Task) func(cmd *cobra.Command, args []string) error {
|
||||
func runDaemon(ctx context.Context, envFile string) func(cmd *cobra.Command, args []string) error {
|
||||
return func(cmd *cobra.Command, args []string) error {
|
||||
log.Infoln("Starting runner daemon")
|
||||
|
||||
_ = godotenv.Load(task.Input.EnvFile)
|
||||
_ = godotenv.Load(envFile)
|
||||
cfg, err := config.FromEnviron()
|
||||
if err != nil {
|
||||
log.WithError(err).
|
||||
|
@ -103,6 +103,7 @@ func runDaemon(ctx context.Context, task *runtime.Task) func(cmd *cobra.Command,
|
|||
runner := &runtime.Runner{
|
||||
Client: cli,
|
||||
Machine: cfg.Runner.Name,
|
||||
ForgeInstance: cfg.ForgeInstance,
|
||||
Environ: cfg.Runner.Environ,
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ func initLogging(cfg config.Config) {
|
|||
}
|
||||
|
||||
func Execute(ctx context.Context) {
|
||||
task := runtime.NewTask(0, nil)
|
||||
task := runtime.NewTask("gitea", 0, nil)
|
||||
|
||||
// ./act_runner
|
||||
rootCmd := &cobra.Command{
|
||||
|
@ -54,7 +54,7 @@ func Execute(ctx context.Context) {
|
|||
Aliases: []string{"daemon"},
|
||||
Use: "execute runner daemon",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
RunE: runDaemon(ctx, task),
|
||||
RunE: runDaemon(ctx, task.Input.EnvFile),
|
||||
}
|
||||
// add all command
|
||||
rootCmd.AddCommand(daemonCmd)
|
||||
|
|
|
@ -21,6 +21,7 @@ type (
|
|||
Client Client
|
||||
Runner Runner
|
||||
Platform Platform
|
||||
ForgeInstance string
|
||||
}
|
||||
|
||||
Client struct {
|
||||
|
@ -68,6 +69,7 @@ func FromEnviron() (Config, error) {
|
|||
if runner.UUID != "" {
|
||||
cfg.Runner.UUID = runner.UUID
|
||||
}
|
||||
cfg.ForgeInstance = runner.ForgeInstance
|
||||
}
|
||||
|
||||
// runner config
|
||||
|
|
|
@ -8,4 +8,5 @@ type Runner struct {
|
|||
UUID string `json:"uuid"`
|
||||
Name string `json:"name"`
|
||||
Token string `json:"token"`
|
||||
ForgeInstance string `json:"forge_instance"`
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ func (p *Register) Register(ctx context.Context, cfg config.Runner) (*core.Runne
|
|||
UUID: resp.Msg.Runner.Uuid,
|
||||
Name: resp.Msg.Runner.Name,
|
||||
Token: resp.Msg.Runner.Token,
|
||||
// ForgeInstance: resp.Msg.Runner.ForgeInstance, TODO: add me
|
||||
}
|
||||
|
||||
file, err := json.MarshalIndent(data, "", " ")
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
// Runner runs the pipeline.
|
||||
type Runner struct {
|
||||
Machine string
|
||||
ForgeInstance string
|
||||
Environ map[string]string
|
||||
Client client.Client
|
||||
}
|
||||
|
@ -48,5 +49,5 @@ func (s *Runner) Run(ctx context.Context, task *runnerv1.Task) error {
|
|||
l.Info("update runner status to idle")
|
||||
}()
|
||||
|
||||
return NewTask(task.Id, s.Client).Run(ctx, task)
|
||||
return NewTask(s.ForgeInstance, task.Id, s.Client).Run(ctx, task)
|
||||
}
|
||||
|
|
|
@ -86,11 +86,11 @@ type Task struct {
|
|||
}
|
||||
|
||||
// NewTask creates a new task
|
||||
func NewTask(buildID int64, client client.Client) *Task {
|
||||
func NewTask(forgeInstance string, buildID int64, client client.Client) *Task {
|
||||
task := &Task{
|
||||
Input: &TaskInput{
|
||||
reuseContainers: true,
|
||||
ForgeInstance: "gitea",
|
||||
ForgeInstance: forgeInstance,
|
||||
},
|
||||
BuildID: buildID,
|
||||
|
||||
|
|
Loading…
Reference in a new issue