diff --git a/cmd/netpolicy/cmd/evaluate.go b/cmd/netpolicy/cmd/evaluate.go index 62b95b52..2da04730 100644 --- a/cmd/netpolicy/cmd/evaluate.go +++ b/cmd/netpolicy/cmd/evaluate.go @@ -26,9 +26,9 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" "github.com/np-guard/netpol-analyzer/pkg/logger" + "github.com/np-guard/netpol-analyzer/pkg/manifests/fsscanner" + "github.com/np-guard/netpol-analyzer/pkg/manifests/parser" "github.com/np-guard/netpol-analyzer/pkg/netpol/eval" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/fsscanner" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/parser" ) // TODO: consider using k8s.io/cli-runtime/pkg/genericclioptions to load kube config. diff --git a/pkg/netpol/manifests/fsscanner/manifests.go b/pkg/manifests/fsscanner/manifests.go similarity index 100% rename from pkg/netpol/manifests/fsscanner/manifests.go rename to pkg/manifests/fsscanner/manifests.go diff --git a/pkg/netpol/manifests/parser/error_types.go b/pkg/manifests/parser/error_types.go similarity index 100% rename from pkg/netpol/manifests/parser/error_types.go rename to pkg/manifests/parser/error_types.go diff --git a/pkg/netpol/manifests/parser/k8sobj.go b/pkg/manifests/parser/k8sobj.go similarity index 100% rename from pkg/netpol/manifests/parser/k8sobj.go rename to pkg/manifests/parser/k8sobj.go diff --git a/pkg/netpol/manifests/parser/parser.go b/pkg/manifests/parser/parser.go similarity index 100% rename from pkg/netpol/manifests/parser/parser.go rename to pkg/manifests/parser/parser.go diff --git a/pkg/netpol/connlist/connlist.go b/pkg/netpol/connlist/connlist.go index 59b7684b..454e3369 100644 --- a/pkg/netpol/connlist/connlist.go +++ b/pkg/netpol/connlist/connlist.go @@ -21,11 +21,11 @@ import ( "k8s.io/cli-runtime/pkg/resource" "github.com/np-guard/netpol-analyzer/pkg/logger" + "github.com/np-guard/netpol-analyzer/pkg/manifests/fsscanner" + "github.com/np-guard/netpol-analyzer/pkg/manifests/parser" "github.com/np-guard/netpol-analyzer/pkg/netpol/common" "github.com/np-guard/netpol-analyzer/pkg/netpol/connlist/internal/ingressanalyzer" "github.com/np-guard/netpol-analyzer/pkg/netpol/eval" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/fsscanner" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/parser" utilerrors "k8s.io/apimachinery/pkg/util/errors" ) diff --git a/pkg/netpol/connlist/connlist_test.go b/pkg/netpol/connlist/connlist_test.go index cb7b0356..f4ffb84b 100644 --- a/pkg/netpol/connlist/connlist_test.go +++ b/pkg/netpol/connlist/connlist_test.go @@ -5,9 +5,9 @@ import ( "strings" "testing" + "github.com/np-guard/netpol-analyzer/pkg/manifests/fsscanner" "github.com/np-guard/netpol-analyzer/pkg/netpol/common" "github.com/np-guard/netpol-analyzer/pkg/netpol/internal/testutils" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/fsscanner" "github.com/stretchr/testify/require" ) diff --git a/pkg/netpol/connlist/internal/ingressanalyzer/ingress_analyzer.go b/pkg/netpol/connlist/internal/ingressanalyzer/ingress_analyzer.go index 4b1995c7..debc9603 100644 --- a/pkg/netpol/connlist/internal/ingressanalyzer/ingress_analyzer.go +++ b/pkg/netpol/connlist/internal/ingressanalyzer/ingress_analyzer.go @@ -26,9 +26,9 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "github.com/np-guard/netpol-analyzer/pkg/logger" + "github.com/np-guard/netpol-analyzer/pkg/manifests/parser" "github.com/np-guard/netpol-analyzer/pkg/netpol/common" "github.com/np-guard/netpol-analyzer/pkg/netpol/eval" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/parser" ) type serviceInfo struct { diff --git a/pkg/netpol/connlist/internal/ingressanalyzer/ingress_analyzer_test.go b/pkg/netpol/connlist/internal/ingressanalyzer/ingress_analyzer_test.go index 304a0eae..a41c2fb9 100644 --- a/pkg/netpol/connlist/internal/ingressanalyzer/ingress_analyzer_test.go +++ b/pkg/netpol/connlist/internal/ingressanalyzer/ingress_analyzer_test.go @@ -9,10 +9,10 @@ import ( "k8s.io/apimachinery/pkg/types" "github.com/np-guard/netpol-analyzer/pkg/logger" + "github.com/np-guard/netpol-analyzer/pkg/manifests/fsscanner" + "github.com/np-guard/netpol-analyzer/pkg/manifests/parser" "github.com/np-guard/netpol-analyzer/pkg/netpol/eval" "github.com/np-guard/netpol-analyzer/pkg/netpol/internal/testutils" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/fsscanner" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/parser" ) // helping func - scans the directory objects and returns the ingress analyzer built from them diff --git a/pkg/netpol/connlist/internal/ingressanalyzer/service_test.go b/pkg/netpol/connlist/internal/ingressanalyzer/service_test.go index 30b870b2..77fb6320 100644 --- a/pkg/netpol/connlist/internal/ingressanalyzer/service_test.go +++ b/pkg/netpol/connlist/internal/ingressanalyzer/service_test.go @@ -9,10 +9,10 @@ import ( "github.com/stretchr/testify/require" "github.com/np-guard/netpol-analyzer/pkg/logger" + "github.com/np-guard/netpol-analyzer/pkg/manifests/fsscanner" + "github.com/np-guard/netpol-analyzer/pkg/manifests/parser" "github.com/np-guard/netpol-analyzer/pkg/netpol/eval" "github.com/np-guard/netpol-analyzer/pkg/netpol/internal/testutils" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/fsscanner" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/parser" ) const servicesDirName = "services" diff --git a/pkg/netpol/diff/diff.go b/pkg/netpol/diff/diff.go index 0264bada..f041a047 100644 --- a/pkg/netpol/diff/diff.go +++ b/pkg/netpol/diff/diff.go @@ -14,11 +14,11 @@ import ( "k8s.io/cli-runtime/pkg/resource" "github.com/np-guard/netpol-analyzer/pkg/logger" + "github.com/np-guard/netpol-analyzer/pkg/manifests/fsscanner" + "github.com/np-guard/netpol-analyzer/pkg/manifests/parser" "github.com/np-guard/netpol-analyzer/pkg/netpol/common" "github.com/np-guard/netpol-analyzer/pkg/netpol/connlist" "github.com/np-guard/netpol-analyzer/pkg/netpol/eval" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/fsscanner" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/parser" utilerrors "k8s.io/apimachinery/pkg/util/errors" ) diff --git a/pkg/netpol/diff/diff_test.go b/pkg/netpol/diff/diff_test.go index 6f7eb124..fd2b08da 100644 --- a/pkg/netpol/diff/diff_test.go +++ b/pkg/netpol/diff/diff_test.go @@ -8,9 +8,9 @@ import ( "github.com/stretchr/testify/require" + "github.com/np-guard/netpol-analyzer/pkg/manifests/fsscanner" "github.com/np-guard/netpol-analyzer/pkg/netpol/common" "github.com/np-guard/netpol-analyzer/pkg/netpol/internal/testutils" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/fsscanner" ) const expectedOutputFilePrefix = "diff_output_from_" diff --git a/pkg/netpol/eval/eval_test.go b/pkg/netpol/eval/eval_test.go index 1aeb4239..ef60409b 100644 --- a/pkg/netpol/eval/eval_test.go +++ b/pkg/netpol/eval/eval_test.go @@ -19,10 +19,10 @@ import ( "sigs.k8s.io/yaml" "github.com/np-guard/netpol-analyzer/pkg/logger" + "github.com/np-guard/netpol-analyzer/pkg/manifests/fsscanner" + "github.com/np-guard/netpol-analyzer/pkg/manifests/parser" "github.com/np-guard/netpol-analyzer/pkg/netpol/common" "github.com/np-guard/netpol-analyzer/pkg/netpol/internal/testutils" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/fsscanner" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/parser" ) const ( diff --git a/pkg/netpol/eval/internal/k8s/pod.go b/pkg/netpol/eval/internal/k8s/pod.go index 222b523c..9f3488c5 100644 --- a/pkg/netpol/eval/internal/k8s/pod.go +++ b/pkg/netpol/eval/internal/k8s/pod.go @@ -25,8 +25,8 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "github.com/np-guard/netpol-analyzer/pkg/manifests/parser" "github.com/np-guard/netpol-analyzer/pkg/netpol/common" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/parser" ) const defaultPortsListSize = 8 diff --git a/pkg/netpol/eval/resources.go b/pkg/netpol/eval/resources.go index 6443f6e9..2dad3fde 100644 --- a/pkg/netpol/eval/resources.go +++ b/pkg/netpol/eval/resources.go @@ -13,9 +13,9 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" + "github.com/np-guard/netpol-analyzer/pkg/manifests/parser" "github.com/np-guard/netpol-analyzer/pkg/netpol/common" "github.com/np-guard/netpol-analyzer/pkg/netpol/eval/internal/k8s" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/parser" ) type ( diff --git a/pkg/netpol/manifests/fsscanner/manifests_test.go b/pkg/netpol/manifests_test.go similarity index 73% rename from pkg/netpol/manifests/fsscanner/manifests_test.go rename to pkg/netpol/manifests_test.go index fa82ad3f..cf02f052 100644 --- a/pkg/netpol/manifests/fsscanner/manifests_test.go +++ b/pkg/netpol/manifests_test.go @@ -1,4 +1,4 @@ -package fsscanner +package netpol import ( "fmt" @@ -8,13 +8,14 @@ import ( "github.com/stretchr/testify/require" "github.com/np-guard/netpol-analyzer/pkg/logger" + "github.com/np-guard/netpol-analyzer/pkg/manifests/fsscanner" + "github.com/np-guard/netpol-analyzer/pkg/manifests/parser" "github.com/np-guard/netpol-analyzer/pkg/netpol/internal/testutils" - "github.com/np-guard/netpol-analyzer/pkg/netpol/manifests/parser" ) func TestBasic(t *testing.T) { dirPath := filepath.Join(testutils.GetTestsDirWithDepth(4), "basic") - rList, errs := GetResourceInfosFromDirPath([]string{dirPath}, true, false) + rList, errs := fsscanner.GetResourceInfosFromDirPath([]string{dirPath}, true, false) require.Empty(t, errs, "expecting no errors on basic dir") // TODO: move the code below to parser pkg