Repository: aquasecurity/starboard
Pull request #346 (2021-01-16 21:08:51)

refactor: Move aqua package
Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>

codecov[bot]: # [Codecov](https://codecov.io/gh/aquasecurity/starboard/pull/346?src=pr&el=h1) Report
> Merging [#346](https://codecov.io/gh/aquasecurity/starboard/pull/346?src=pr&el=desc) (7cef088) into [main](https://codecov.io/gh/aquasecurity/starboard/commit/8f29f722909f53806327ed4b71d848f3ecaf720c?el=desc) (8f29f72) will **decrease** coverage by `35.24%`.
> The diff coverage is `0.00%`.

[![Impacted file tree graph](https://codecov.io/gh/aquasecurity/starboard/pull/346/graphs/tree.svg?width=650&height=150&src=pr&token=qqTGKAJ0Wb)](https://codecov.io/gh/aquasecurity/starboard/pull/346?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##             main     #346       +/-   ##
===========================================
- Coverage   66.16%   30.92%   -35.25%     
===========================================
  Files          57       53        -4     
  Lines        2843     2626      -217     
===========================================
- Hits         1881      812     -1069     
- Misses        721     1754     +1033     
+ Partials      241       60      -181     
```


| [Impacted Files](https://codecov.io/gh/aquasecurity/starboard/pull/346?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pkg/aqua/client/client.go](https://codecov.io/gh/aquasecurity/starboard/pull/346/diff?src=pr&el=tree#diff-cGtnL2FxdWEvY2xpZW50L2NsaWVudC5nbw==) | `66.66% <ø> (ø)` | |
| [pkg/config/config.go](https://codecov.io/gh/aquasecurity/starboard/pull/346/diff?src=pr&el=tree#diff-cGtnL2NvbmZpZy9jb25maWcuZ28=) | `0.00% <0.00%> (ø)` | |
| [pkg/trivy/plugin.go](https://codecov.io/gh/aquasecurity/starboard/pull/346/diff?src=pr&el=tree#diff-cGtnL3RyaXZ5L3BsdWdpbi5nbw==) | `72.32% <ø> (ø)` | |
| [pkg/cmd/get.go](https://codecov.io/gh/aquasecurity/starboard/pull/346/diff?src=pr&el=tree#diff-cGtnL2NtZC9nZXQuZ28=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/find.go](https://codecov.io/gh/aquasecurity/starboard/pull/346/diff?src=pr&el=tree#diff-cGtnL2NtZC9maW5kLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/root.go](https://codecov.io/gh/aquasecurity/starboard/pull/346/diff?src=pr&el=tree#diff-cGtnL2NtZC9yb290Lmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/scan.go](https://codecov.io/gh/aquasecurity/starboard/pull/346/diff?src=pr&el=tree#diff-cGtnL2NtZC9zY2FuLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/polaris.go](https://codecov.io/gh/aquasecurity/starboard/pull/346/diff?src=pr&el=tree#diff-cGtnL2NtZC9wb2xhcmlzLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/version.go](https://codecov.io/gh/aquasecurity/starboard/pull/346/diff?src=pr&el=tree#diff-cGtnL2NtZC92ZXJzaW9uLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/kube\_bench.go](https://codecov.io/gh/aquasecurity/starboard/pull/346/diff?src=pr&el=tree#diff-cGtnL2NtZC9rdWJlX2JlbmNoLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| ... and [31 more](https://codecov.io/gh/aquasecurity/starboard/pull/346/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/aquasecurity/starboard/pull/346?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/aquasecurity/starboard/pull/346?src=pr&el=footer). Last update [8f29f72...7cef088](https://codecov.io/gh/aquasecurity/starboard/pull/346?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/cmd/scanner-aqua/main.go b/cmd/scanner-aqua/main.go
index a6b92e0..d3fabf3 100644
--- a/cmd/scanner-aqua/main.go
+++ b/cmd/scanner-aqua/main.go
@@ -6,9 +6,9 @@ import (
 	"os"
 
 	"github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
-	"github.com/aquasecurity/starboard/pkg/operator/aqua/client"
-	"github.com/aquasecurity/starboard/pkg/operator/aqua/scanner/api"
-	"github.com/aquasecurity/starboard/pkg/operator/aqua/scanner/cli"
+	"github.com/aquasecurity/starboard/pkg/aqua/client"
+	"github.com/aquasecurity/starboard/pkg/aqua/scanner/api"
+	"github.com/aquasecurity/starboard/pkg/aqua/scanner/cli"
 	"github.com/spf13/cobra"
 )
 
diff --git a/pkg/operator/aqua/client/types.go b/pkg/aqua/client/types.go
similarity index 100%
rename from pkg/operator/aqua/client/types.go
rename to pkg/aqua/client/types.go
diff --git a/pkg/operator/aqua/scanner.go b/pkg/aqua/plugin.go
similarity index 96%
rename from pkg/operator/aqua/scanner.go
rename to pkg/aqua/plugin.go
index 0044867..301a0b6 100644
--- a/pkg/operator/aqua/scanner.go
+++ b/pkg/aqua/plugin.go
@@ -26,9 +26,9 @@ type scanner struct {
 	config      Config
 }
 
-// NewScanner constructs a new vulnerability scanner Plugin, which is using
-// the Aqua to scan container images of Kubernetes workloads.
-func NewScannerPlugin(
+// NewPlugin constructs a new vulnerabilityreport.Plugin, which is using
+// the Aqua Enterprise to scan container images of Kubernetes workloads.
+func NewPlugin(
 	idGenerator ext.IDGenerator,
 	buildInfo starboard.BuildInfo,
 	config Config,
diff --git a/pkg/operator/aqua/scanner/api/scanner.go b/pkg/aqua/scanner/api/scanner.go
similarity index 98%
rename from pkg/operator/aqua/scanner/api/scanner.go
rename to pkg/aqua/scanner/api/scanner.go
index 72c1a13..c82ad5f 100644
--- a/pkg/operator/aqua/scanner/api/scanner.go
+++ b/pkg/aqua/scanner/api/scanner.go
@@ -4,11 +4,10 @@ import (
 	"strings"
 	"time"
 
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
 	"github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
-	"github.com/aquasecurity/starboard/pkg/operator/aqua/client"
+	"github.com/aquasecurity/starboard/pkg/aqua/client"
 	"github.com/google/go-containerregistry/pkg/name"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
 const (
diff --git a/pkg/operator/aqua/scanner/cli/scanner.go b/pkg/aqua/scanner/cli/scanner.go
similarity index 98%
rename from pkg/operator/aqua/scanner/cli/scanner.go
rename to pkg/aqua/scanner/cli/scanner.go
index 99da8af..dcc8b65 100644
--- a/pkg/operator/aqua/scanner/cli/scanner.go
+++ b/pkg/aqua/scanner/cli/scanner.go
@@ -8,11 +8,10 @@ import (
 	"os/exec"
 	"time"
 
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
 	"github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
-	"github.com/aquasecurity/starboard/pkg/operator/aqua/client"
+	"github.com/aquasecurity/starboard/pkg/aqua/client"
 	"github.com/google/go-containerregistry/pkg/name"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
 type Scanner struct {
diff --git a/pkg/operator/aqua/scanner/cli/types.go b/pkg/aqua/scanner/cli/types.go
similarity index 100%
rename from pkg/operator/aqua/scanner/cli/types.go
rename to pkg/aqua/scanner/cli/types.go
diff --git a/pkg/operator/aqua/scanner/testdata/aqua_csp_report/with_vulnerabilities.json b/pkg/aqua/scanner/testdata/aqua_csp_report/with_vulnerabilities.json
similarity index 100%
rename from pkg/operator/aqua/scanner/testdata/aqua_csp_report/with_vulnerabilities.json
rename to pkg/aqua/scanner/testdata/aqua_csp_report/with_vulnerabilities.json
diff --git a/pkg/operator/aqua/scanner/testdata/aqua_csp_report/without_vulnerabilities.json b/pkg/aqua/scanner/testdata/aqua_csp_report/without_vulnerabilities.json
similarity index 100%
rename from pkg/operator/aqua/scanner/testdata/aqua_csp_report/without_vulnerabilities.json
rename to pkg/aqua/scanner/testdata/aqua_csp_report/without_vulnerabilities.json
diff --git a/pkg/config/config.go b/pkg/config/config.go
index be89065..ed5b838 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -3,8 +3,8 @@ package config
 import (
 	"fmt"
 
+	"github.com/aquasecurity/starboard/pkg/aqua"
 	"github.com/aquasecurity/starboard/pkg/ext"
-	"github.com/aquasecurity/starboard/pkg/operator/aqua"
 	"github.com/aquasecurity/starboard/pkg/starboard"
 	"github.com/aquasecurity/starboard/pkg/trivy"
 	"github.com/aquasecurity/starboard/pkg/vulnerabilityreport"
@@ -25,9 +25,9 @@ func GetVulnerabilityReportPlugin(buildInfo starboard.BuildInfo, config starboar
 	}
 	switch scanner {
 	case starboard.Trivy:
-		return trivy.NewScannerPlugin(ext.NewGoogleUUIDGenerator(), config), nil
+		return trivy.NewPlugin(ext.NewGoogleUUIDGenerator(), config), nil
 	case starboard.Aqua:
-		return aqua.NewScannerPlugin(ext.NewGoogleUUIDGenerator(), buildInfo, config), nil
+		return aqua.NewPlugin(ext.NewGoogleUUIDGenerator(), buildInfo, config), nil
 	}
 	return nil, fmt.Errorf("unsupported vulnerability scanner plugin: %s", scanner)
 }
diff --git a/pkg/trivy/scanner.go b/pkg/trivy/plugin.go
similarity index 98%
rename from pkg/trivy/scanner.go
rename to pkg/trivy/plugin.go
index 17db38f..0d588f7 100644
--- a/pkg/trivy/scanner.go
+++ b/pkg/trivy/plugin.go
@@ -43,7 +43,7 @@ type Config interface {
 	GetTrivyServerURL() (string, error)
 }
 
-// NewScanner constructs a new vulnerabilityreport.Plugin, which is using an
+// NewPlugin constructs a new vulnerabilityreport.Plugin, which is using an
 // official Trivy container image to scan Kubernetes workloads.
 //
 // This Plugin supports both starboard.Standalone and starboard.ClientServer
@@ -51,7 +51,7 @@ type Config interface {
 //
 // The starboard.ClientServer mode is usually more performant, however it
 // requires a Trivy server accessible at the configurable URL.
-func NewScannerPlugin(idGenerator ext.IDGenerator, config Config) vulnerabilityreport.Plugin {
+func NewPlugin(idGenerator ext.IDGenerator, config Config) vulnerabilityreport.Plugin {
 	return &scanner{
 		idGenerator: idGenerator,
 		config:      config,


Test patch:
diff --git a/pkg/operator/aqua/client/auth.go b/pkg/aqua/client/auth.go
similarity index 100%
rename from pkg/operator/aqua/client/auth.go
rename to pkg/aqua/client/auth.go
diff --git a/pkg/operator/aqua/client/client.go b/pkg/aqua/client/client.go
similarity index 100%
rename from pkg/operator/aqua/client/client.go
rename to pkg/aqua/client/client.go
diff --git a/pkg/operator/aqua/client/client_integration_test.go b/pkg/aqua/client/client_integration_test.go
similarity index 100%
rename from pkg/operator/aqua/client/client_integration_test.go
rename to pkg/aqua/client/client_integration_test.go
diff --git a/pkg/operator/aqua/client/client_suite_test.go b/pkg/aqua/client/client_suite_test.go
similarity index 100%
rename from pkg/operator/aqua/client/client_suite_test.go
rename to pkg/aqua/client/client_suite_test.go
diff --git a/pkg/operator/aqua/client/client_test.go b/pkg/aqua/client/client_test.go
similarity index 98%
rename from pkg/operator/aqua/client/client_test.go
rename to pkg/aqua/client/client_test.go
index 5e4d7a5..9ce7a0b 100644
--- a/pkg/operator/aqua/client/client_test.go
+++ b/pkg/aqua/client/client_test.go
@@ -3,7 +3,7 @@ package client_test
 import (
 	"net/http"
 
-	"github.com/aquasecurity/starboard/pkg/operator/aqua/client"
+	"github.com/aquasecurity/starboard/pkg/aqua/client"
 	. "github.com/onsi/ginkgo"
 	. "github.com/onsi/gomega"
 	. "github.com/onsi/gomega/ghttp"
diff --git a/pkg/trivy/scanner_test.go b/pkg/trivy/plugin_test.go
similarity index 98%
rename from pkg/trivy/scanner_test.go
rename to pkg/trivy/plugin_test.go
index ea15438..6811206 100644
--- a/pkg/trivy/scanner_test.go
+++ b/pkg/trivy/plugin_test.go
@@ -276,7 +276,7 @@ func TestScanner_GetScanJobSpec(t *testing.T) {
 
 	for _, tc := range testCases {
 		t.Run(tc.name, func(t *testing.T) {
-			jobSpec, secrets, err := trivy.NewScannerPlugin(ext.NewSimpleIDGenerator(), tc.config).
+			jobSpec, secrets, err := trivy.NewPlugin(ext.NewSimpleIDGenerator(), tc.config).
 				GetScanJobSpec(tc.workloadSpec, nil)
 			require.NoError(t, err)
 			assert.Empty(t, secrets)