From 4d53feb0ba8c54b2066c6c0573f0289c0ecba31b Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Mon, 11 Sep 2023 11:20:08 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20migrate=20os/npm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit we do not use it yet, but it will come up soon, so migrate Signed-off-by: Dominik Richter --- .../packs/os => providers/os/resources}/npm/packagejson.go | 7 +++---- .../os => providers/os/resources}/npm/packagejson_test.go | 4 ++-- .../os/resources}/npm/testdata/d3-yarn.lock | 0 .../os/resources}/npm/testdata/express-package.json | 0 .../os/resources}/npm/testdata/workbox-package-lock.json | 0 .../packs/os => providers/os/resources}/npm/yarn.go | 2 +- .../packs/os => providers/os/resources}/npm/yarn_test.go | 4 ++-- 7 files changed, 8 insertions(+), 9 deletions(-) rename {_resources/packs/os => providers/os/resources}/npm/packagejson.go (95%) rename {_resources/packs/os => providers/os/resources}/npm/packagejson_test.go (92%) rename {_resources/packs/os => providers/os/resources}/npm/testdata/d3-yarn.lock (100%) rename {_resources/packs/os => providers/os/resources}/npm/testdata/express-package.json (100%) rename {_resources/packs/os => providers/os/resources}/npm/testdata/workbox-package-lock.json (100%) rename {_resources/packs/os => providers/os/resources}/npm/yarn.go (96%) rename {_resources/packs/os => providers/os/resources}/npm/yarn_test.go (93%) diff --git a/_resources/packs/os/npm/packagejson.go b/providers/os/resources/npm/packagejson.go similarity index 95% rename from _resources/packs/os/npm/packagejson.go rename to providers/os/resources/npm/packagejson.go index 5e1b414d0d..ea998ba798 100644 --- a/_resources/packs/os/npm/packagejson.go +++ b/providers/os/resources/npm/packagejson.go @@ -6,9 +6,8 @@ package npm import ( "encoding/json" "io" - "io/ioutil" - "go.mondoo.com/cnquery/upstream/mvd" + "go.mondoo.com/cnquery/providers-sdk/v1/upstream/mvd" ) // PackageJson allows parsing the package json file @@ -34,7 +33,7 @@ type PackageJsonLock struct { } func ParsePackageJson(r io.Reader) ([]*mvd.Package, error) { - data, err := ioutil.ReadAll(r) + data, err := io.ReadAll(r) if err != nil { return nil, err } @@ -70,7 +69,7 @@ func ParsePackageJson(r io.Reader) ([]*mvd.Package, error) { } func ParsePackageJsonLock(r io.Reader) ([]*mvd.Package, error) { - data, err := ioutil.ReadAll(r) + data, err := io.ReadAll(r) if err != nil { return nil, err } diff --git a/_resources/packs/os/npm/packagejson_test.go b/providers/os/resources/npm/packagejson_test.go similarity index 92% rename from _resources/packs/os/npm/packagejson_test.go rename to providers/os/resources/npm/packagejson_test.go index 32b69dcc7b..d24759d325 100644 --- a/_resources/packs/os/npm/packagejson_test.go +++ b/providers/os/resources/npm/packagejson_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "go.mondoo.com/cnquery/resources/packs/os/npm" - "go.mondoo.com/cnquery/upstream/mvd" + "go.mondoo.com/cnquery/providers-sdk/v1/upstream/mvd" + "go.mondoo.com/cnquery/providers/os/resources/npm" ) func TestPackageJsonParser(t *testing.T) { diff --git a/_resources/packs/os/npm/testdata/d3-yarn.lock b/providers/os/resources/npm/testdata/d3-yarn.lock similarity index 100% rename from _resources/packs/os/npm/testdata/d3-yarn.lock rename to providers/os/resources/npm/testdata/d3-yarn.lock diff --git a/_resources/packs/os/npm/testdata/express-package.json b/providers/os/resources/npm/testdata/express-package.json similarity index 100% rename from _resources/packs/os/npm/testdata/express-package.json rename to providers/os/resources/npm/testdata/express-package.json diff --git a/_resources/packs/os/npm/testdata/workbox-package-lock.json b/providers/os/resources/npm/testdata/workbox-package-lock.json similarity index 100% rename from _resources/packs/os/npm/testdata/workbox-package-lock.json rename to providers/os/resources/npm/testdata/workbox-package-lock.json diff --git a/_resources/packs/os/npm/yarn.go b/providers/os/resources/npm/yarn.go similarity index 96% rename from _resources/packs/os/npm/yarn.go rename to providers/os/resources/npm/yarn.go index 7ca8c20d09..7f7a58c854 100644 --- a/_resources/packs/os/npm/yarn.go +++ b/providers/os/resources/npm/yarn.go @@ -12,7 +12,7 @@ import ( "strings" "github.com/rs/zerolog/log" - "go.mondoo.com/cnquery/upstream/mvd" + "go.mondoo.com/cnquery/providers-sdk/v1/upstream/mvd" "sigs.k8s.io/yaml" ) diff --git a/_resources/packs/os/npm/yarn_test.go b/providers/os/resources/npm/yarn_test.go similarity index 93% rename from _resources/packs/os/npm/yarn_test.go rename to providers/os/resources/npm/yarn_test.go index e595f0f54a..dcbf2482ee 100644 --- a/_resources/packs/os/npm/yarn_test.go +++ b/providers/os/resources/npm/yarn_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "go.mondoo.com/cnquery/resources/packs/os/npm" - "go.mondoo.com/cnquery/upstream/mvd" + "go.mondoo.com/cnquery/providers-sdk/v1/upstream/mvd" + "go.mondoo.com/cnquery/providers/os/resources/npm" ) func TestYarnParser(t *testing.T) {