Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

Commit

Permalink
fix: Do not use deprecated commands in examples (#72)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Pacak <[email protected]>
  • Loading branch information
danielpacak authored Dec 14, 2020
1 parent 160585c commit 538ef0d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 39 deletions.
21 changes: 10 additions & 11 deletions pkg/plugin/view/configaudit/report_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import (
"strconv"
"strings"

"github.com/aquasecurity/starboard/pkg/kube"

"github.com/aquasecurity/starboard-octant-plugin/pkg/plugin/view"
starboard "github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
"github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
"github.com/aquasecurity/starboard/pkg/kube"
"github.com/vmware-tanzu/octant/pkg/view/component"
)

func NewReport(workload kube.Object, configAuditReportsDefined bool, report *starboard.ConfigAuditReport) (flexLayout *component.FlexLayout) {
func NewReport(workload kube.Object, configAuditReportsDefined bool, report *v1alpha1.ConfigAuditReport) (flexLayout *component.FlexLayout) {
flexLayout = component.NewFlexLayout("")

flexLayout.AddSections(component.FlexLayoutSection{
Expand All @@ -35,11 +34,11 @@ func NewReport(workload kube.Object, configAuditReportsDefined bool, report *sta
"> ```\n"+
"or\n"+
"> ```\n"+
"> $ kubectl apply -f https://raw.githubusercontent.com/aquasecurity/starboard/master/kube/crd/configauditreports-crd.yaml\n"+
"> $ kubectl apply -f https://raw.githubusercontent.com/aquasecurity/starboard/master/deploy/crd/configauditreports.crd.yaml\n"+
"> ```\n"+
"\n"+
"[starboard-cli]: https://github.com/aquasecurity/starboard#starboard-cli",
starboard.ConfigAuditReportCRName,
v1alpha1.ConfigAuditReportCRName,
)),
},
})
Expand All @@ -55,12 +54,12 @@ func NewReport(workload kube.Object, configAuditReportsDefined bool, report *sta
"> Note that config audit reports are represented by instances of the `%[1]s` resource.\n"+
"> You can create such reports by running [Polaris][polaris] with [Starboard CLI][starboard-cli]:\n"+
"> ```\n"+
"> $ kubectl starboard polaris %[2]s/%[3]s --namespace %[4]s\n"+
"> $ kubectl starboard scan configauditreports %[2]s/%[3]s --namespace %[4]s\n"+
"> ```\n"+
"\n"+
"[polaris]: https://www.fairwinds.com/polaris\n"+
"[starboard-cli]: https://github.com/aquasecurity/starboard#starboard-cli",
starboard.ConfigAuditReportCRName,
v1alpha1.ConfigAuditReportCRName,
strings.ToLower(string(workload.Kind)),
workload.Name,
workload.Namespace,
Expand Down Expand Up @@ -111,13 +110,13 @@ func NewReport(workload kube.Object, configAuditReportsDefined bool, report *sta
return
}

func createCardComponent(title string, checks []starboard.Check) (x *component.Card) {
func createCardComponent(title string, checks []v1alpha1.Check) (x *component.Card) {
x = component.NewCard(component.TitleFromString(title))
x.SetBody(createChecksTable(checks))
return x
}

func createChecksTable(checks []starboard.Check) component.Component {
func createChecksTable(checks []v1alpha1.Check) component.Component {
table := component.NewTableWithRows(
"", "There are no checks!",
component.NewTableCols("Success", "ID", "Severity", "Category"),
Expand All @@ -138,7 +137,7 @@ func createChecksTable(checks []starboard.Check) component.Component {
return table
}

func NewSummary(report starboard.ConfigAuditResult) (summaryComponent *component.Summary) {
func NewSummary(report v1alpha1.ConfigAuditResult) (summaryComponent *component.Summary) {
sections := []component.SummarySection{
{Header: "danger", Content: component.NewText(strconv.Itoa(report.Summary.DangerCount))},
{Header: "warning", Content: component.NewText(strconv.Itoa(report.Summary.WarningCount))},
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugin/view/configaudit/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package configaudit
import (
"strconv"

security "github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
"github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
"github.com/vmware-tanzu/octant/pkg/view/component"
)

func NewSummarySections(summary *security.ConfigAuditSummary) []component.SummarySection {
func NewSummarySections(summary *v1alpha1.ConfigAuditSummary) []component.SummarySection {
if summary == nil {
return []component.SummarySection{}
}
Expand Down
15 changes: 7 additions & 8 deletions pkg/plugin/view/kubebench/report_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import (
"strconv"

"github.com/aquasecurity/starboard-octant-plugin/pkg/plugin/view"

starboard "github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
"github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
"github.com/vmware-tanzu/octant/pkg/view/component"
)

// NewReport creates a new view component for displaying the specified CISKubeBenchReport.
func NewReport(kubeBenchReportsDefined bool, report *starboard.CISKubeBenchReport) (flexLayout component.FlexLayout) {
func NewReport(kubeBenchReportsDefined bool, report *v1alpha1.CISKubeBenchReport) (flexLayout component.FlexLayout) {
flexLayout = *component.NewFlexLayout("CIS Kubernetes Benchmark")

if !kubeBenchReportsDefined {
Expand All @@ -26,11 +25,11 @@ func NewReport(kubeBenchReportsDefined bool, report *starboard.CISKubeBenchRepor
"> ```\n"+
"or\n"+
"> ```\n"+
"> $ kubectl apply -f https://raw.githubusercontent.com/aquasecurity/starboard/master/kube/crd/ciskubebenchreports-crd.yaml\n"+
"> $ kubectl apply -f https://raw.githubusercontent.com/aquasecurity/starboard/master/deploy/crd/ciskubebenchreports.crd.yaml\n"+
"> ```\n"+
"\n"+
"[starboard-cli]: https://github.com/aquasecurity/starboard#starboard-cli",
starboard.CISKubeBenchReportCRName,
v1alpha1.CISKubeBenchReportCRName,
)),
},
})
Expand All @@ -45,7 +44,7 @@ func NewReport(kubeBenchReportsDefined bool, report *starboard.CISKubeBenchRepor
"> Note that [kube-bench] reports are represented by instances of the `ciskubebenchreports.aquasecurity.github.io` resource.\n" +
"> You can create such a report by running [kube-bench] with [Starboard CLI][starboard-cli]:\n" +
"> ```\n" +
"> $ starboard kube-bench\n" +
"> $ kubectl starboard scan ciskubebenchreports\n" +
"> ```\n" +
"\n" +
"[kube-bench]: https://github.com/aquasecurity/kube-bench\n" +
Expand Down Expand Up @@ -83,7 +82,7 @@ func NewReport(kubeBenchReportsDefined bool, report *starboard.CISKubeBenchRepor
return
}

func createTableForSection(section starboard.CISKubeBenchSection) component.Component {
func createTableForSection(section v1alpha1.CISKubeBenchSection) component.Component {
table := component.NewTableWithRows(
fmt.Sprintf("%s %s", section.ID, section.Text), "There are no results!",
component.NewTableCols("Status", "Number", "Description", "Scored"),
Expand All @@ -105,7 +104,7 @@ func createTableForSection(section starboard.CISKubeBenchSection) component.Comp
return table
}

func NewCISKubeBenchSummary(summary starboard.CISKubeBenchSummary) (summaryComponent *component.Summary) {
func NewCISKubeBenchSummary(summary v1alpha1.CISKubeBenchSummary) (summaryComponent *component.Summary) {
summaryComponent = component.NewSummary("Summary")

summaryComponent.Add([]component.SummarySection{
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugin/view/kubehunter/report_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewReport(kubeHunterReportsDefined bool, report *starboard.KubeHunterReport
"> ```\n"+
"or\n"+
"> ```\n"+
"> $ kubectl apply -f https://raw.githubusercontent.com/aquasecurity/starboard/master/kube/crd/kubehunterreports-crd.yaml\n"+
"> $ kubectl apply -f https://raw.githubusercontent.com/aquasecurity/starboard/master/deploy/crd/kubehunterreports.crd.yaml\n"+
"> ```\n"+
"\n"+
"[starboard-cli]: https://github.com/aquasecurity/starboard#starboard-cli",
Expand All @@ -44,7 +44,7 @@ func NewReport(kubeHunterReportsDefined bool, report *starboard.KubeHunterReport
"> Note that [kube-hunter] reports are represented by instances of the `kubehunterreports.aquasecurity.github.io` resource.\n" +
"> You can create such a report by running [kube-hunter] with [Starboard CLI][starboard-cli]:\n" +
"> ```\n" +
"> $ starboard kube-hunter\n" +
"> $ kubectl starboard scan kubehunterreports\n" +
"> ```\n" +
"\n" +
"[kube-hunter]: https://github.com/aquasecurity/kube-hunter\n" +
Expand Down
25 changes: 11 additions & 14 deletions pkg/plugin/view/vulnerabilities/report_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ import (
"strconv"
"strings"

"github.com/aquasecurity/starboard/pkg/kube"

"github.com/aquasecurity/starboard-octant-plugin/pkg/plugin/view"

"github.com/aquasecurity/starboard-octant-plugin/pkg/plugin/model"

starboard "github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
"github.com/aquasecurity/starboard-octant-plugin/pkg/plugin/view"
"github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
"github.com/aquasecurity/starboard/pkg/kube"
"github.com/vmware-tanzu/octant/pkg/view/component"
)

Expand All @@ -32,11 +29,11 @@ func NewReport(workload kube.Object, vulnerabilityReportsDefined bool, reports [
"> ```\n"+
"or\n"+
"> ```\n"+
"> $ kubectl apply -f https://raw.githubusercontent.com/aquasecurity/starboard/master/kube/crd/vulnerabilityreports-crd.yaml\n"+
"> $ kubectl apply -f https://raw.githubusercontent.com/aquasecurity/starboard/master/deploy/crd/vulnerabilityreports.crd.yaml\n"+
"> ```\n"+
"\n"+
"[starboard-cli]: https://github.com/aquasecurity/starboard#starboard-cli",
starboard.VulnerabilityReportsCRName,
v1alpha1.VulnerabilityReportsCRName,
)),
},
})
Expand All @@ -52,12 +49,12 @@ func NewReport(workload kube.Object, vulnerabilityReportsDefined bool, reports [
"> Note that vulnerability reports are represented by instances of the `%[1]s` resource.\n"+
"> You can create such reports by running [Trivy][trivy] with [Starboard CLI][starboard-cli]:\n"+
"> ```\n"+
"> $ kubectl starboard find vulnerabilities %[2]s/%[3]s --namespace %[4]s\n"+
"> $ kubectl starboard scan vulnerabilityreports %[2]s/%[3]s --namespace %[4]s\n"+
"> ```\n"+
"\n"+
"[trivy]: https://github.com/aquasecurity/trivy\n"+
"[starboard-cli]: https://github.com/aquasecurity/starboard#starboard-cli",
starboard.VulnerabilityReportsCRName,
v1alpha1.VulnerabilityReportsCRName,
strings.ToLower(string(workload.Kind)),
workload.Name,
workload.Namespace,
Expand Down Expand Up @@ -97,7 +94,7 @@ func NewReport(workload kube.Object, vulnerabilityReportsDefined bool, reports [
return flexLayout
}

func getImageRef(report starboard.VulnerabilityScanResult) string {
func getImageRef(report v1alpha1.VulnerabilityScanResult) string {
imageID := report.Artifact.Tag
if imageID == "" {
imageID = report.Artifact.Digest
Expand All @@ -107,7 +104,7 @@ func getImageRef(report starboard.VulnerabilityScanResult) string {
return imageRef
}

func createVulnerabilitiesTable(containerName string, report starboard.VulnerabilityScanResult) component.Component {
func createVulnerabilitiesTable(containerName string, report v1alpha1.VulnerabilityScanResult) component.Component {
table := component.NewTableWithRows(
fmt.Sprintf("Container %s: %s", containerName, getImageRef(report)), "There are no vulnerabilities!",
component.NewTableCols("ID", "Severity", "Title", "Resource", "Installed Version", "Fixed Version"),
Expand All @@ -134,7 +131,7 @@ func createVulnerabilitiesTable(containerName string, report starboard.Vulnerabi
return table
}

func getLinkComponent(v starboard.Vulnerability) component.Component {
func getLinkComponent(v v1alpha1.Vulnerability) component.Component {
if v.PrimaryLink != "" {
return component.NewMarkdownText(view.ToMarkdownLink(v.VulnerabilityID, v.PrimaryLink))
}
Expand All @@ -144,7 +141,7 @@ func getLinkComponent(v starboard.Vulnerability) component.Component {
return component.NewText(v.VulnerabilityID)
}

func NewVulnerabilitiesSummary(title string, summary starboard.VulnerabilitySummary) *component.Summary {
func NewVulnerabilitiesSummary(title string, summary v1alpha1.VulnerabilitySummary) *component.Summary {
sections := []component.SummarySection{
{Header: "CRITICAL ", Content: component.NewText(strconv.Itoa(summary.CriticalCount))},
{Header: "HIGH ", Content: component.NewText(strconv.Itoa(summary.HighCount))},
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugin/view/vulnerabilities/summary_sections_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package vulnerabilities
import (
"strconv"

security "github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
"github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
"github.com/vmware-tanzu/octant/pkg/view/component"
)

func NewSummarySections(summary *security.VulnerabilitySummary) []component.SummarySection {
func NewSummarySections(summary *v1alpha1.VulnerabilitySummary) []component.SummarySection {
if summary == nil {
return []component.SummarySection{}
}
Expand Down

0 comments on commit 538ef0d

Please sign in to comment.