mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-21 14:50:53 -08:00
Co-authored-by: afdesk <work@afdesk.com> Co-authored-by: DmitriyLewen <91113035+DmitriyLewen@users.noreply.github.com>
27 lines
680 B
Go
27 lines
680 B
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/aquasecurity/trivy-kubernetes/pkg/k8s"
|
|
"github.com/aquasecurity/trivy-kubernetes/pkg/trivyk8s"
|
|
"github.com/aquasecurity/trivy/pkg/flag"
|
|
"github.com/aquasecurity/trivy/pkg/log"
|
|
|
|
"golang.org/x/xerrors"
|
|
)
|
|
|
|
// clusterRun runs scan on kubernetes cluster
|
|
func clusterRun(ctx context.Context, opts flag.Options, cluster k8s.Cluster) error {
|
|
if err := validateReportArguments(opts); err != nil {
|
|
return err
|
|
}
|
|
|
|
artifacts, err := trivyk8s.New(cluster, log.Logger).ListArtifacts(ctx)
|
|
if err != nil {
|
|
return xerrors.Errorf("get k8s artifacts error: %w", err)
|
|
}
|
|
|
|
return run(ctx, opts, cluster.GetCurrentContext(), artifacts)
|
|
}
|