in ospatch/yum_update.go [91:141]
func RunYumUpdate(ctx context.Context, opts ...YumUpdateOption) error {
yumOpts := &yumUpdateOpts{
security: false,
minimal: false,
dryrun: false,
}
for _, opt := range opts {
opt(yumOpts)
}
pkgs, err := packages.YumUpdates(ctx, packages.YumUpdateMinimal(yumOpts.minimal), packages.YumUpdateSecurity(yumOpts.security))
if err != nil {
return err
}
// Yum excludes are already excluded while listing yumUpdates, so we send
// and empty list.
fPkgs, err := filterPackages(pkgs, yumOpts.exclusivePackages, yumOpts.excludes)
if err != nil {
return err
}
if len(fPkgs) == 0 {
clog.Infof(ctx, "No packages to update.")
return nil
}
var pkgNames []string
for _, pkg := range fPkgs {
pkgNames = append(pkgNames, fullPackageName(pkg))
}
msg := fmt.Sprintf("%d packages: %q", len(pkgNames), fPkgs)
if yumOpts.dryrun {
clog.Infof(ctx, "Running in dryrun mode, not updating %s", msg)
return nil
}
ops := opsToReport{
packages: fPkgs,
}
logOps(ctx, ops)
err = packages.InstallYumPackages(ctx, pkgNames)
if err == nil {
logSuccess(ctx, ops)
} else {
logFailure(ctx, ops, err)
}
return err
}