add forgeinstance
This commit is contained in:
parent
9c7d2be7c6
commit
378966e45f
|
@ -20,11 +20,11 @@ import (
|
||||||
"golang.org/x/sync/errgroup"
|
"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 {
|
return func(cmd *cobra.Command, args []string) error {
|
||||||
log.Infoln("Starting runner daemon")
|
log.Infoln("Starting runner daemon")
|
||||||
|
|
||||||
_ = godotenv.Load(task.Input.EnvFile)
|
_ = godotenv.Load(envFile)
|
||||||
cfg, err := config.FromEnviron()
|
cfg, err := config.FromEnviron()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).
|
log.WithError(err).
|
||||||
|
@ -103,6 +103,7 @@ func runDaemon(ctx context.Context, task *runtime.Task) func(cmd *cobra.Command,
|
||||||
runner := &runtime.Runner{
|
runner := &runtime.Runner{
|
||||||
Client: cli,
|
Client: cli,
|
||||||
Machine: cfg.Runner.Name,
|
Machine: cfg.Runner.Name,
|
||||||
|
ForgeInstance: cfg.ForgeInstance,
|
||||||
Environ: cfg.Runner.Environ,
|
Environ: cfg.Runner.Environ,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ func initLogging(cfg config.Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Execute(ctx context.Context) {
|
func Execute(ctx context.Context) {
|
||||||
task := runtime.NewTask(0, nil)
|
task := runtime.NewTask("gitea", 0, nil)
|
||||||
|
|
||||||
// ./act_runner
|
// ./act_runner
|
||||||
rootCmd := &cobra.Command{
|
rootCmd := &cobra.Command{
|
||||||
|
@ -54,7 +54,7 @@ func Execute(ctx context.Context) {
|
||||||
Aliases: []string{"daemon"},
|
Aliases: []string{"daemon"},
|
||||||
Use: "execute runner daemon",
|
Use: "execute runner daemon",
|
||||||
Args: cobra.MaximumNArgs(1),
|
Args: cobra.MaximumNArgs(1),
|
||||||
RunE: runDaemon(ctx, task),
|
RunE: runDaemon(ctx, task.Input.EnvFile),
|
||||||
}
|
}
|
||||||
// add all command
|
// add all command
|
||||||
rootCmd.AddCommand(daemonCmd)
|
rootCmd.AddCommand(daemonCmd)
|
||||||
|
|
|
@ -21,6 +21,7 @@ type (
|
||||||
Client Client
|
Client Client
|
||||||
Runner Runner
|
Runner Runner
|
||||||
Platform Platform
|
Platform Platform
|
||||||
|
ForgeInstance string
|
||||||
}
|
}
|
||||||
|
|
||||||
Client struct {
|
Client struct {
|
||||||
|
@ -68,6 +69,7 @@ func FromEnviron() (Config, error) {
|
||||||
if runner.UUID != "" {
|
if runner.UUID != "" {
|
||||||
cfg.Runner.UUID = runner.UUID
|
cfg.Runner.UUID = runner.UUID
|
||||||
}
|
}
|
||||||
|
cfg.ForgeInstance = runner.ForgeInstance
|
||||||
}
|
}
|
||||||
|
|
||||||
// runner config
|
// runner config
|
||||||
|
|
|
@ -8,4 +8,5 @@ type Runner struct {
|
||||||
UUID string `json:"uuid"`
|
UUID string `json:"uuid"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Token string `json:"token"`
|
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,
|
UUID: resp.Msg.Runner.Uuid,
|
||||||
Name: resp.Msg.Runner.Name,
|
Name: resp.Msg.Runner.Name,
|
||||||
Token: resp.Msg.Runner.Token,
|
Token: resp.Msg.Runner.Token,
|
||||||
|
// ForgeInstance: resp.Msg.Runner.ForgeInstance, TODO: add me
|
||||||
}
|
}
|
||||||
|
|
||||||
file, err := json.MarshalIndent(data, "", " ")
|
file, err := json.MarshalIndent(data, "", " ")
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
// Runner runs the pipeline.
|
// Runner runs the pipeline.
|
||||||
type Runner struct {
|
type Runner struct {
|
||||||
Machine string
|
Machine string
|
||||||
|
ForgeInstance string
|
||||||
Environ map[string]string
|
Environ map[string]string
|
||||||
Client client.Client
|
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")
|
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
|
// 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{
|
task := &Task{
|
||||||
Input: &TaskInput{
|
Input: &TaskInput{
|
||||||
reuseContainers: true,
|
reuseContainers: true,
|
||||||
ForgeInstance: "gitea",
|
ForgeInstance: forgeInstance,
|
||||||
},
|
},
|
||||||
BuildID: buildID,
|
BuildID: buildID,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue