From 38e3405f0e6251a865f02298e1793a438cdc985d Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 5 Mar 2021 09:46:24 -0500 Subject: [PATCH] remove schema-validation checks No longer required since it is always going to be one schema imported as part of `db` Signed-off-by: Alfredo Deza --- Makefile | 7 +------ test/validate_schema.py | 32 -------------------------------- 2 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 test/validate_schema.py diff --git a/Makefile b/Makefile index 44106dc1..80351b25 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,7 @@ bootstrap: ## Download and install all go dependencies (+ prep tooling in the ./ [ -f "$(TEMPDIR)/goreleaser" ] || curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh -s -- -b $(TEMPDIR)/ v0.140.0 .PHONY: static-analysis -static-analysis: lint check-licenses validate-schema +static-analysis: lint check-licenses .PHONY: lint lint: ## Run gofmt + golangci lint checks @@ -100,11 +100,6 @@ lint: ## Run gofmt + golangci lint checks $(eval MALFORMED_FILENAMES := $(shell find . | grep -e ':')) @bash -c "[[ '$(MALFORMED_FILENAMES)' == '' ]] || (printf '\nfound unsupported filename characters:\n$(MALFORMED_FILENAMES)\n\n' && false)" -.PHONY: validate-schema -validate-schema: - # ensure the codebase is only referencing a single grype-db schema version, multiple is not allowed - python test/validate_schema.py - .PHONY: validate-cyclonedx-schema validate-cyclonedx-schema: cd schema/cyclonedx && make diff --git a/test/validate_schema.py b/test/validate_schema.py deleted file mode 100644 index 285ecce5..00000000 --- a/test/validate_schema.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python2 -import re -import os -import sys - -pattern = re.compile(r'github.com/anchore/grype-db/pkg/db/v(?P\d+)') - -def main(): - schema_versions_found = set() - - for root, dirs, files in os.walk("."): - for file in files: - if not file.endswith(".go"): - continue - with open(os.path.join(root, file)) as f: - for match in pattern.findall(f.read(), re.MULTILINE): - schema_versions_found.add(match) - - num_schemas = len(schema_versions_found) - if num_schemas != 1: - sys.exit("Found multiple schemas: %s" % repr(schema_versions_found)) - - try: - for x in schema_versions_found: - int(x) - except Exception: - sys.exit("Non-numeric schema found: %s" % repr(schema_versions_found)) - - print("Schemas Found: %s" % repr(schema_versions_found)) - -if __name__ == "__main__": - main()