Repository: aquasecurity/starboard
Pull request #419 (2021-03-05 00:03:21)

refactor: Move Polaris package under plugin

codecov[bot]: # [Codecov](https://codecov.io/gh/aquasecurity/starboard/pull/419?src=pr&el=h1) Report
> Merging [#419](https://codecov.io/gh/aquasecurity/starboard/pull/419?src=pr&el=desc) (10cf545) into [main](https://codecov.io/gh/aquasecurity/starboard/commit/3892722a21676fad46f49c0fed9823070615116f?el=desc) (3892722) will **decrease** coverage by `37.61%`.
> The diff coverage is `0.00%`.

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

```diff
@@             Coverage Diff             @@
##             main     #419       +/-   ##
===========================================
- Coverage   67.45%   29.84%   -37.62%     
===========================================
  Files          59       58        -1     
  Lines        3371     3270      -101     
===========================================
- Hits         2274      976     -1298     
- Misses        817     2233     +1416     
+ Partials      280       61      -219     
```


| [Impacted Files](https://codecov.io/gh/aquasecurity/starboard/pull/419?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pkg/cmd/scan\_configaudit.go](https://codecov.io/gh/aquasecurity/starboard/pull/419/diff?src=pr&el=tree#diff-cGtnL2NtZC9zY2FuX2NvbmZpZ2F1ZGl0Lmdv) | `0.00% <0.00%> (-55.00%)` | :arrow_down: |
| [pkg/cmd/scan\_vulnerabilities.go](https://codecov.io/gh/aquasecurity/starboard/pull/419/diff?src=pr&el=tree#diff-cGtnL2NtZC9zY2FuX3Z1bG5lcmFiaWxpdGllcy5nbw==) | `0.00% <0.00%> (-68.26%)` | :arrow_down: |
| [pkg/plugin/factory.go](https://codecov.io/gh/aquasecurity/starboard/pull/419/diff?src=pr&el=tree#diff-cGtnL3BsdWdpbi9mYWN0b3J5Lmdv) | `0.00% <ø> (ø)` | |
| [pkg/plugin/polaris/plugin.go](https://codecov.io/gh/aquasecurity/starboard/pull/419/diff?src=pr&el=tree#diff-cGtnL3BsdWdpbi9wb2xhcmlzL3BsdWdpbi5nbw==) | `91.17% <ø> (ø)` | |
| [pkg/cmd/get.go](https://codecov.io/gh/aquasecurity/starboard/pull/419/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/419/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/419/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/419/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/419/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/419/diff?src=pr&el=tree#diff-cGtnL2NtZC92ZXJzaW9uLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| ... and [37 more](https://codecov.io/gh/aquasecurity/starboard/pull/419/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/aquasecurity/starboard/pull/419?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/419?src=pr&el=footer). Last update [3892722...10cf545](https://codecov.io/gh/aquasecurity/starboard/pull/419?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/pkg/cmd/scan_configaudit.go b/pkg/cmd/scan_configaudit.go
index 64829e6..bea8d03 100644
--- a/pkg/cmd/scan_configaudit.go
+++ b/pkg/cmd/scan_configaudit.go
@@ -3,8 +3,8 @@ package cmd
 import (
 	"context"
 
-	"github.com/aquasecurity/starboard/pkg/config"
 	"github.com/aquasecurity/starboard/pkg/configauditreport"
+	"github.com/aquasecurity/starboard/pkg/plugin"
 	"github.com/aquasecurity/starboard/pkg/starboard"
 	"github.com/spf13/cobra"
 	"k8s.io/cli-runtime/pkg/genericclioptions"
@@ -62,11 +62,11 @@ func ScanConfigAuditReports(buildInfo starboard.BuildInfo, cf *genericclioptions
 		if err != nil {
 			return err
 		}
-		plugin, err := config.GetConfigAuditReportPlugin(buildInfo, starboardConfig)
+		instance, err := plugin.GetConfigAuditReportPlugin(buildInfo, starboardConfig)
 		if err != nil {
 			return err
 		}
-		scanner := configauditreport.NewScanner(scheme, kubeClientset, opts, plugin)
+		scanner := configauditreport.NewScanner(scheme, kubeClientset, opts, instance)
 		report, err := scanner.Scan(ctx, workload, gvk)
 		if err != nil {
 			return err
diff --git a/pkg/cmd/scan_vulnerabilities.go b/pkg/cmd/scan_vulnerabilities.go
index 958f63a..55332ec 100644
--- a/pkg/cmd/scan_vulnerabilities.go
+++ b/pkg/cmd/scan_vulnerabilities.go
@@ -4,7 +4,7 @@ import (
 	"context"
 	"fmt"
 
-	"github.com/aquasecurity/starboard/pkg/config"
+	"github.com/aquasecurity/starboard/pkg/plugin"
 	"github.com/aquasecurity/starboard/pkg/starboard"
 	"github.com/aquasecurity/starboard/pkg/vulnerabilityreport"
 	"github.com/spf13/cobra"
@@ -98,7 +98,7 @@ func ScanVulnerabilityReports(buildInfo starboard.BuildInfo, cf *genericclioptio
 		if err != nil {
 			return err
 		}
-		plugin, err := config.GetVulnerabilityReportPlugin(buildInfo, starboardConfig)
+		instance, err := plugin.GetVulnerabilityReportPlugin(buildInfo, starboardConfig)
 		if err != nil {
 			return err
 		}
@@ -106,7 +106,7 @@ func ScanVulnerabilityReports(buildInfo starboard.BuildInfo, cf *genericclioptio
 			scheme,
 			kubeClientset,
 			opts,
-			plugin).Scan(ctx, workload)
+			instance).Scan(ctx, workload)
 		if err != nil {
 			return err
 		}
diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go
index e8e0ad3..b65db8a 100644
--- a/pkg/operator/operator.go
+++ b/pkg/operator/operator.go
@@ -4,13 +4,13 @@ import (
 	"context"
 	"fmt"
 
-	"github.com/aquasecurity/starboard/pkg/config"
 	"github.com/aquasecurity/starboard/pkg/configauditreport"
 	"github.com/aquasecurity/starboard/pkg/ext"
 	"github.com/aquasecurity/starboard/pkg/kube"
 	"github.com/aquasecurity/starboard/pkg/kubebench"
 	"github.com/aquasecurity/starboard/pkg/operator/controller"
 	"github.com/aquasecurity/starboard/pkg/operator/etc"
+	"github.com/aquasecurity/starboard/pkg/plugin"
 	"github.com/aquasecurity/starboard/pkg/starboard"
 	"github.com/aquasecurity/starboard/pkg/vulnerabilityreport"
 	"k8s.io/client-go/kubernetes"
@@ -122,7 +122,7 @@ func Run(buildInfo starboard.BuildInfo, operatorConfig etc.Config) error {
 	logsReader := kube.NewLogsReader(kubeClientset)
 	secretsReader := kube.NewControllerRuntimeSecretsReader(mgr.GetClient())
 
-	vulnerabilityReportPlugin, err := config.GetVulnerabilityReportPlugin(buildInfo, starboardConfig)
+	vulnerabilityReportPlugin, err := plugin.GetVulnerabilityReportPlugin(buildInfo, starboardConfig)
 	if err != nil {
 		return err
 	}
@@ -141,7 +141,7 @@ func Run(buildInfo starboard.BuildInfo, operatorConfig etc.Config) error {
 		return fmt.Errorf("unable to setup vulnerabilityreport reconciler: %w", err)
 	}
 
-	configAuditReportPlugin, err := config.GetConfigAuditReportPlugin(buildInfo, starboardConfig)
+	configAuditReportPlugin, err := plugin.GetConfigAuditReportPlugin(buildInfo, starboardConfig)
 	if err != nil {
 		return err
 	}
diff --git a/pkg/plugin/doc.go b/pkg/plugin/doc.go
new file mode 100644
index 0000000..b0736c3
--- /dev/null
+++ b/pkg/plugin/doc.go
@@ -0,0 +1,1 @@
+package plugin
diff --git a/pkg/config/config.go b/pkg/plugin/factory.go
similarity index 96%
rename from pkg/config/config.go
rename to pkg/plugin/factory.go
index 2c0a5fe..a33bfd7 100644
--- a/pkg/config/config.go
+++ b/pkg/plugin/factory.go
@@ -1,4 +1,4 @@
-package config
+package plugin
 
 import (
 	"fmt"
@@ -6,7 +6,7 @@ import (
 	"github.com/aquasecurity/starboard/pkg/aqua"
 	"github.com/aquasecurity/starboard/pkg/configauditreport"
 	"github.com/aquasecurity/starboard/pkg/ext"
-	"github.com/aquasecurity/starboard/pkg/polaris"
+	"github.com/aquasecurity/starboard/pkg/plugin/polaris"
 	"github.com/aquasecurity/starboard/pkg/starboard"
 	"github.com/aquasecurity/starboard/pkg/trivy"
 	"github.com/aquasecurity/starboard/pkg/vulnerabilityreport"
diff --git a/pkg/plugin/polaris/doc.go b/pkg/plugin/polaris/doc.go
new file mode 100644
index 0000000..cf3a5bc
--- /dev/null
+++ b/pkg/plugin/polaris/doc.go
@@ -0,0 +1,2 @@
+// The polaris package provides primitives for working with Polaris.
+package polaris
diff --git a/pkg/polaris/testdata/polaris-report.json b/pkg/plugin/polaris/testdata/polaris-report.json
similarity index 100%
rename from pkg/polaris/testdata/polaris-report.json
rename to pkg/plugin/polaris/testdata/polaris-report.json
diff --git a/pkg/polaris/doc.go b/pkg/polaris/doc.go
deleted file mode 100644
index 19e62a2..0000000
--- a/pkg/polaris/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// This package provides primitives for working with Polaris.
-package polaris
diff --git a/pkg/trivy/doc.go b/pkg/trivy/doc.go
new file mode 100644
index 0000000..be75e90
--- /dev/null
+++ b/pkg/trivy/doc.go
@@ -0,0 +1,2 @@
+// The trivy package provides primitives for working with Trivy.
+package trivy


Test patch:
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
deleted file mode 100644
index d7b82b3..0000000
--- a/pkg/config/config_test.go
+++ /dev/null
@@ -1,1 +0,0 @@
-package config_test
diff --git a/pkg/plugin/factory_test.go b/pkg/plugin/factory_test.go
new file mode 100644
index 0000000..c3f71fb
--- /dev/null
+++ b/pkg/plugin/factory_test.go
@@ -0,0 +1,1 @@
+package plugin_test
diff --git a/pkg/polaris/model.go b/pkg/plugin/polaris/model.go
similarity index 100%
rename from pkg/polaris/model.go
rename to pkg/plugin/polaris/model.go
diff --git a/pkg/polaris/plugin.go b/pkg/plugin/polaris/plugin.go
similarity index 100%
rename from pkg/polaris/plugin.go
rename to pkg/plugin/polaris/plugin.go
diff --git a/pkg/polaris/plugin_test.go b/pkg/plugin/polaris/plugin_test.go
similarity index 98%
rename from pkg/polaris/plugin_test.go
rename to pkg/plugin/polaris/plugin_test.go
index e032733..e2ec42f 100644
--- a/pkg/polaris/plugin_test.go
+++ b/pkg/plugin/polaris/plugin_test.go
@@ -8,7 +8,7 @@ import (
 	"github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
 	"github.com/aquasecurity/starboard/pkg/ext"
 	"github.com/aquasecurity/starboard/pkg/kube"
-	"github.com/aquasecurity/starboard/pkg/polaris"
+	"github.com/aquasecurity/starboard/pkg/plugin/polaris"
 	"github.com/aquasecurity/starboard/pkg/starboard"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"