feat(daemon): task groups
This commit is contained in:
		| @@ -10,6 +10,7 @@ import ( | ||||
|  | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"code.dumpstack.io/tools/out-of-tree/api" | ||||
| 	"code.dumpstack.io/tools/out-of-tree/client" | ||||
| ) | ||||
|  | ||||
| @@ -26,11 +27,24 @@ type DaemonJobCmd struct { | ||||
| 	Log    DaemonJobsLogsCmd   `cmd:"" help:"job logs"` | ||||
| } | ||||
|  | ||||
| type DaemonJobsListCmd struct{} | ||||
| type DaemonJobsListCmd struct { | ||||
| 	Group  string `help:"group uuid"` | ||||
| 	Repo   string `help:"repo name"` | ||||
| 	Commit string `help:"commit sha"` | ||||
| 	Status string `help:"job status"` | ||||
| } | ||||
|  | ||||
| func (cmd *DaemonJobsListCmd) Run(dm *DaemonCmd, g *Globals) (err error) { | ||||
| 	c := client.Client{RemoteAddr: g.RemoteAddr} | ||||
| 	jobs, err := c.Jobs() | ||||
|  | ||||
| 	params := api.ListJobsParams{ | ||||
| 		Group:  cmd.Group, | ||||
| 		Repo:   cmd.Repo, | ||||
| 		Commit: cmd.Commit, | ||||
| 		Status: api.Status(cmd.Status), | ||||
| 	} | ||||
|  | ||||
| 	jobs, err := c.Jobs(params) | ||||
| 	if err != nil { | ||||
| 		log.Error().Err(err).Msg("") | ||||
| 		return | ||||
|   | ||||
							
								
								
									
										10
									
								
								cmd/pew.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								cmd/pew.go
									
									
									
									
									
								
							| @@ -16,6 +16,7 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/davecgh/go-spew/spew" | ||||
| 	"github.com/google/uuid" | ||||
| 	"github.com/remeh/sizedwaitgroup" | ||||
| 	"github.com/rs/zerolog" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| @@ -98,6 +99,9 @@ type PewCmd struct { | ||||
|  | ||||
| 	useRemote  bool | ||||
| 	remoteAddr string | ||||
|  | ||||
| 	// UUID of the job set | ||||
| 	groupUUID string | ||||
| } | ||||
|  | ||||
| func (cmd *PewCmd) getRepoName(worktree string, ka artifact.Artifact) { | ||||
| @@ -149,6 +153,8 @@ func (cmd *PewCmd) syncRepo(worktree string, ka artifact.Artifact) (err error) { | ||||
| } | ||||
|  | ||||
| func (cmd *PewCmd) Run(g *Globals) (err error) { | ||||
| 	cmd.groupUUID = uuid.New().String() | ||||
| 	log.Info().Str("group", cmd.groupUUID).Msg("") | ||||
| 	cmd.useRemote = g.Remote | ||||
| 	cmd.remoteAddr = g.RemoteAddr | ||||
|  | ||||
| @@ -326,10 +332,8 @@ func (cmd PewCmd) remote(swg *sizedwaitgroup.SizedWaitGroup, | ||||
| 		Str("kernel", ki.KernelRelease). | ||||
| 		Logger() | ||||
|  | ||||
| 	log.Trace().Msgf("artifact: %v", spew.Sdump(ka)) | ||||
| 	log.Trace().Msgf("kernelinfo: %v", spew.Sdump(ki)) | ||||
|  | ||||
| 	job := api.Job{} | ||||
| 	job.Group = cmd.groupUUID | ||||
| 	job.RepoName = cmd.repoName | ||||
| 	job.Commit = cmd.commit | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user