fsjobqueue: accept jobs of any type

Soon, we want to begin tagging the jobs with the name of its submitter.
The simplest way to add a tag to a job is to put it into its type string.
However, as we don't know (and don't want to know) the submitters' names when
osbuild-composer is initialized, we need to be able to push arbitrary job
types into the jobqueue.

This commit therefore lifts the restriction that a jobqueue accepts only
a predefined set of job types. Now, jobqueue clients can push jobs of
arbitrary names.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2020-11-11 13:48:23 +01:00 committed by Tom Gundersen
parent e007f9964e
commit a6df2877a3
4 changed files with 30 additions and 36 deletions

View file

@ -69,20 +69,7 @@ func NewComposer(config *ComposerConfigFile, stateDir, cacheDir string, logger *
c.rpm = rpmmd.NewRPMMD(path.Join(c.cacheDir, "rpmmd"), "/usr/libexec/osbuild-composer/dnf-json")
// construct job types of the form osbuild:{arch} and osbuild-koji:{arch} for all arches
jobTypes := []string{"osbuild", "koji-init", "koji-finalize"}
archSet := map[string]bool{}
for _, name := range c.distros.List() {
d := c.distros.GetDistro(name)
for _, arch := range d.ListArches() {
if !archSet[arch] {
archSet[arch] = true
jobTypes = append(jobTypes, "osbuild:"+arch, "osbuild-koji:"+arch)
}
}
}
jobs, err := fsjobqueue.New(queueDir, jobTypes)
jobs, err := fsjobqueue.New(queueDir)
if err != nil {
return nil, fmt.Errorf("cannot create jobqueue: %v", err)
}