Skip to content

Commit

Permalink
ext: add CleanAll() utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jzelinskie committed Jan 10, 2019
1 parent e16d17d commit 25078ac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 8 additions & 0 deletions ext/vulnmdsrc/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,11 @@ func Appenders() map[string]Appender {

return ret
}

// CleanAll is a utility function that calls Clean() on every registered
// Appender.
func CleanAll() {
for _, appender := range Appenders() {
appender.Clean()
}
}
8 changes: 8 additions & 0 deletions ext/vulnsrc/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ func ListUpdaters() []string {
}
return r
}

// CleanAll is a utility function that calls Clean() on every registered
// Updater.
func CleanAll() {
for _, updater := range Updaters() {
updater.Clean()
}
}
11 changes: 3 additions & 8 deletions updater.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 clair authors
// Copyright 2019 clair authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -91,13 +91,8 @@ func RunUpdater(config *UpdaterConfig, datastore database.Datastore, st *stopper

// Clean up any resources the updater left behind.
defer func() {
for _, appenders := range vulnmdsrc.Appenders() {
appenders.Clean()
}
for _, updaters := range vulnsrc.Updaters() {
updaters.Clean()
}

vulnmdsrc.CleanAll()
vulnsrc.CleanAll()
log.Info("updater service stopped")
}()

Expand Down

0 comments on commit 25078ac

Please sign in to comment.