diff --git a/cmd/clair/main.go b/cmd/clair/main.go index 02a299a5..6f5c9fbb 100644 --- a/cmd/clair/main.go +++ b/cmd/clair/main.go @@ -27,11 +27,17 @@ import ( // 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/data/aci" + _ "github.com/coreos/clair/worker/detectors/data/docker" + _ "github.com/coreos/clair/worker/detectors/feature/dpkg" _ "github.com/coreos/clair/worker/detectors/feature/rpm" + _ "github.com/coreos/clair/worker/detectors/namespace/aptsources" _ "github.com/coreos/clair/worker/detectors/namespace/lsbrelease" _ "github.com/coreos/clair/worker/detectors/namespace/osrelease" diff --git a/worker/detectors/data.go b/worker/detectors/data.go index d2dd869f..4e3f96b5 100644 --- a/worker/detectors/data.go +++ b/worker/detectors/data.go @@ -99,5 +99,5 @@ func DetectData(path string, format string, toExtract []string, maxFileSize int6 } } - return nil, nil + return nil, cerrors.NewBadRequestError(fmt.Sprintf("unsupported image format '%s'", format)) } diff --git a/worker/detectors/data/aci.go b/worker/detectors/data/aci/aci.go similarity index 98% rename from worker/detectors/data/aci.go rename to worker/detectors/data/aci/aci.go index 43a7a187..78551aa7 100644 --- a/worker/detectors/data/aci.go +++ b/worker/detectors/data/aci/aci.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package data +package aci import ( "io" diff --git a/worker/detectors/data/docker.go b/worker/detectors/data/docker/docker.go similarity index 98% rename from worker/detectors/data/docker.go rename to worker/detectors/data/docker/docker.go index d1b32ad4..d70de3bc 100644 --- a/worker/detectors/data/docker.go +++ b/worker/detectors/data/docker/docker.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package data +package docker import ( "io" diff --git a/worker/worker.go b/worker/worker.go index a01999dd..9856caac 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -48,10 +48,11 @@ var ( ErrParentUnknown = errors.New("worker: parent layer is unknown, it must be processed first") // SupportedNamespacePrefixes is the list of namespace prefixes that the worker supports. + // TODO(Quentin-M): We should remove this from here and allow registered Namespace Detectors to + // tell which prefixes are supported. Otherwise, it doesn't make sense to allow registering them. + // Similarly, we could do the same thing with Data Detectors to detect early unsupported + // ImageFormats. SupportedNamespacePrefixes = []string{"debian:", "ubuntu:", "centos:"} - - // SupportedImageFormat is the list of image formats that the worker supports. - SupportedImageFormat = []string{"Docker", "ACI"} ) // Process detects the Namespace of a layer, the features it adds/removes, and @@ -72,17 +73,6 @@ func Process(datastore database.Datastore, name, parentName, path, imageFormat s return cerrors.NewBadRequestError("could not process a layer which does not have a format") } - isSupported := false - for _, format := range SupportedImageFormat { - if strings.EqualFold(imageFormat, format) { - isSupported = true - break - } - } - if !isSupported { - return cerrors.NewBadRequestError("could not process a layer which does not have a supported format") - } - log.Debugf("layer %s: processing (Location: %s, Engine version: %d, Parent: %s, Format: %s)", name, utils.CleanURL(path), Version, parentName, imageFormat) diff --git a/worker/worker_test.go b/worker/worker_test.go index f1cf045b..87cfa3e5 100644 --- a/worker/worker_test.go +++ b/worker/worker_test.go @@ -23,9 +23,9 @@ import ( "github.com/coreos/clair/database/pgsql" "github.com/coreos/clair/utils/types" "github.com/stretchr/testify/assert" - + // Register the required detectors. - _ "github.com/coreos/clair/worker/detectors/data" + _ "github.com/coreos/clair/worker/detectors/data/docker" _ "github.com/coreos/clair/worker/detectors/feature/dpkg" _ "github.com/coreos/clair/worker/detectors/namespace/aptsources" _ "github.com/coreos/clair/worker/detectors/namespace/osrelease"