updater: move each fetcher to its own package

This commit is contained in:
Quentin Machu 2016-01-13 16:41:00 -05:00 committed by Jimmy Zelinskie
parent 1b53142e38
commit 452f7018ec
12 changed files with 19 additions and 34 deletions

View File

@ -26,6 +26,10 @@ import (
"github.com/coreos/pkg/capnslog" "github.com/coreos/pkg/capnslog"
// Register components // Register components
_ "github.com/coreos/clair/notifier/notifiers"
_ "github.com/coreos/clair/updater/fetchers/debian"
_ "github.com/coreos/clair/updater/fetchers/rhel"
_ "github.com/coreos/clair/updater/fetchers/ubuntu"
_ "github.com/coreos/clair/worker/detectors/feature/dpkg" _ "github.com/coreos/clair/worker/detectors/feature/dpkg"
_ "github.com/coreos/clair/worker/detectors/feature/rpm" _ "github.com/coreos/clair/worker/detectors/feature/rpm"
_ "github.com/coreos/clair/worker/detectors/namespace/aptsources" _ "github.com/coreos/clair/worker/detectors/namespace/aptsources"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package fetchers package debian
import ( import (
"crypto/sha1" "crypto/sha1"
@ -53,7 +53,7 @@ type jsonRel struct {
type DebianFetcher struct{} type DebianFetcher struct{}
func init() { func init() {
//updater.RegisterFetcher("debian", &DebianFetcher{}) updater.RegisterFetcher("debian", &DebianFetcher{})
} }
// FetchUpdate fetches vulnerability updates from the Debian Security Tracker. // FetchUpdate fetches vulnerability updates from the Debian Security Tracker.

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package fetchers package debian
import ( import (
"os" "os"

View File

@ -1,19 +0,0 @@
package fetchers
import "github.com/coreos/clair/updater"
// NVDFetcher implements updater.Fetcher and gets vulnerability updates from
// the National Vulnerability Database (NVD), from the
// National Institute of Standards and Technology (NIST).
type NVDFetcher struct{}
func init() {
//updater.RegisterFetcher("NVD", &RHELFetcher{})
}
// FetchUpdate gets vulnerability updates from the NVD database.
func (f *NVDFetcher) FetchUpdate() (resp updater.FetcherResponse, err error) {
log.Info("fetching NVD vulneratibilities")
return
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package fetchers package rhel
import ( import (
"bufio" "bufio"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package fetchers package rhel
import ( import (
"os" "os"
@ -56,10 +56,10 @@ func TestRHELParser(t *testing.T) {
}, },
} }
for _, expectedPackage := range expectedPackages { for _, expectedPackage := range expectedPackages {
assert.Contains(t, packages, expectedPackage) assert.Contains(t, packages, expectedPackage)
assert.Contains(t, vulnerabilities[0].FixedInNodes, expectedPackage.GetNode()) assert.Contains(t, vulnerabilities[0].FixedInNodes, expectedPackage.GetNode())
} }
} }
// Test parsing testdata/fetcher_rhel_test.2.xml // Test parsing testdata/fetcher_rhel_test.2.xml
@ -84,9 +84,9 @@ func TestRHELParser(t *testing.T) {
}, },
} }
for _, expectedPackage := range expectedPackages { for _, expectedPackage := range expectedPackages {
assert.Contains(t, packages, expectedPackage) assert.Contains(t, packages, expectedPackage)
assert.Contains(t, vulnerabilities[0].FixedInNodes, expectedPackage.GetNode()) assert.Contains(t, vulnerabilities[0].FixedInNodes, expectedPackage.GetNode())
} }
} }
} }

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package fetchers package ubuntu
import ( import (
"bufio" "bufio"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package fetchers package ubuntu
import ( import (
"os" "os"