Skip to content

Commit

Permalink
clairctl: move to updates.Manager interface
Browse files Browse the repository at this point in the history
An underlying claircore change removed the `OfflineUpdaters` interface
that used to live in `libvuln`.

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed May 11, 2021
1 parent 04f2cb7 commit c80a99d
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions cmd/clairctl/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package main

import (
"errors"
"fmt"
"io"
"os"
"regexp"

"github.com/quay/claircore/libvuln"
"github.com/quay/claircore/libvuln/driver"
"github.com/quay/claircore/updater"
"github.com/quay/claircore/libvuln/jsonblob"
"github.com/quay/claircore/libvuln/updates"
_ "github.com/quay/claircore/updater/defaults"
"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -57,10 +57,6 @@ func exportAction(c *cli.Context) error {
if err != nil {
return err
}
filter, err := regexp.Compile(cfg.Updaters.Filter)
if err != nil {
return err
}
cfgs := make(map[string]driver.ConfigUnmarshaler, len(cfg.Updaters.Config))
for name, node := range cfg.Updaters.Config {
cfgs[name] = node.Decode
Expand All @@ -71,22 +67,24 @@ func exportAction(c *cli.Context) error {
return err
}

u, err := libvuln.NewOfflineUpdater(cfgs, filter.MatchString, out)
store, err := jsonblob.New()
if err != nil {
return err
}

defs := updater.Registered()
cfg.Updaters.FilterSets(defs)
if err := updater.Configure(ctx, defs, cfgs, cl); err != nil {
defer func() {
if err := store.Store(out); err != nil {
fmt.Fprintln(os.Stderr, err)
}
}()
mgr, err := updates.NewManager(ctx, store, updates.LocalLockSource(), cl,
updates.WithConfigs(cfgs),
updates.WithEnabled(cfg.Updaters.Sets),
)
if err != nil {
return err
}
ufs := make([]driver.UpdaterSetFactory, 0, len(defs))
for _, u := range defs {
ufs = append(ufs, u)
}

if err := u.RunUpdaters(ctx, ufs...); err != nil {
if err := mgr.Run(ctx); err != nil {
// Don't exit non-zero if we run into errors, unless the strict flag was
// provided.
code := 0
Expand Down

0 comments on commit c80a99d

Please sign in to comment.