worker: move each data detector to their own packages and remove image format whitelist
This commit is contained in:
parent
3ecb8b69cb
commit
90fe137de8
@ -27,11 +27,17 @@ import (
|
|||||||
|
|
||||||
// Register components
|
// Register components
|
||||||
_ "github.com/coreos/clair/notifier/notifiers"
|
_ "github.com/coreos/clair/notifier/notifiers"
|
||||||
|
|
||||||
_ "github.com/coreos/clair/updater/fetchers/debian"
|
_ "github.com/coreos/clair/updater/fetchers/debian"
|
||||||
_ "github.com/coreos/clair/updater/fetchers/rhel"
|
_ "github.com/coreos/clair/updater/fetchers/rhel"
|
||||||
_ "github.com/coreos/clair/updater/fetchers/ubuntu"
|
_ "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/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"
|
||||||
_ "github.com/coreos/clair/worker/detectors/namespace/lsbrelease"
|
_ "github.com/coreos/clair/worker/detectors/namespace/lsbrelease"
|
||||||
_ "github.com/coreos/clair/worker/detectors/namespace/osrelease"
|
_ "github.com/coreos/clair/worker/detectors/namespace/osrelease"
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
|
@ -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 data
|
package aci
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
@ -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 data
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
@ -48,10 +48,11 @@ var (
|
|||||||
ErrParentUnknown = errors.New("worker: parent layer is unknown, it must be processed first")
|
ErrParentUnknown = errors.New("worker: parent layer is unknown, it must be processed first")
|
||||||
|
|
||||||
// SupportedNamespacePrefixes is the list of namespace prefixes that the worker supports.
|
// 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:"}
|
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
|
// 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")
|
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)",
|
log.Debugf("layer %s: processing (Location: %s, Engine version: %d, Parent: %s, Format: %s)",
|
||||||
name, utils.CleanURL(path), Version, parentName, imageFormat)
|
name, utils.CleanURL(path), Version, parentName, imageFormat)
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ import (
|
|||||||
"github.com/coreos/clair/database/pgsql"
|
"github.com/coreos/clair/database/pgsql"
|
||||||
"github.com/coreos/clair/utils/types"
|
"github.com/coreos/clair/utils/types"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
// Register the required detectors.
|
// 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/feature/dpkg"
|
||||||
_ "github.com/coreos/clair/worker/detectors/namespace/aptsources"
|
_ "github.com/coreos/clair/worker/detectors/namespace/aptsources"
|
||||||
_ "github.com/coreos/clair/worker/detectors/namespace/osrelease"
|
_ "github.com/coreos/clair/worker/detectors/namespace/osrelease"
|
||||||
|
Loading…
Reference in New Issue
Block a user