mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-21 23:00:42 -08:00
feat(flag): replace '--slow' with '--parallel' (#5572)
Signed-off-by: knqyf263 <knqyf263@gmail.com>
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/samber/lo"
|
||||
"golang.org/x/xerrors"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
@@ -52,12 +51,6 @@ var (
|
||||
Default: "",
|
||||
Usage: "specify k8s version to validate outdated api by it (example: 1.21.0)",
|
||||
}
|
||||
ParallelFlag = Flag{
|
||||
Name: "parallel",
|
||||
ConfigName: "kubernetes.parallel",
|
||||
Default: 5,
|
||||
Usage: "number (between 1-20) of goroutines enabled for parallel scanning",
|
||||
}
|
||||
TolerationsFlag = Flag{
|
||||
Name: "tolerations",
|
||||
ConfigName: "kubernetes.tolerations",
|
||||
@@ -97,7 +90,6 @@ type K8sFlagGroup struct {
|
||||
KubeConfig *Flag
|
||||
Components *Flag
|
||||
K8sVersion *Flag
|
||||
Parallel *Flag
|
||||
Tolerations *Flag
|
||||
AllNamespaces *Flag
|
||||
NodeCollectorNamespace *Flag
|
||||
@@ -111,7 +103,6 @@ type K8sOptions struct {
|
||||
KubeConfig string
|
||||
Components []string
|
||||
K8sVersion string
|
||||
Parallel int
|
||||
Tolerations []corev1.Toleration
|
||||
AllNamespaces bool
|
||||
NodeCollectorNamespace string
|
||||
@@ -126,7 +117,6 @@ func NewK8sFlagGroup() *K8sFlagGroup {
|
||||
KubeConfig: &KubeConfigFlag,
|
||||
Components: &ComponentsFlag,
|
||||
K8sVersion: &K8sVersionFlag,
|
||||
Parallel: &ParallelFlag,
|
||||
Tolerations: &TolerationsFlag,
|
||||
AllNamespaces: &AllNamespaces,
|
||||
NodeCollectorNamespace: &NodeCollectorNamespace,
|
||||
@@ -146,7 +136,6 @@ func (f *K8sFlagGroup) Flags() []*Flag {
|
||||
f.KubeConfig,
|
||||
f.Components,
|
||||
f.K8sVersion,
|
||||
f.Parallel,
|
||||
f.Tolerations,
|
||||
f.AllNamespaces,
|
||||
f.NodeCollectorNamespace,
|
||||
@@ -160,14 +149,7 @@ func (f *K8sFlagGroup) ToOptions() (K8sOptions, error) {
|
||||
if err != nil {
|
||||
return K8sOptions{}, err
|
||||
}
|
||||
var parallel int
|
||||
if f.Parallel != nil {
|
||||
parallel = getInt(f.Parallel)
|
||||
// check parallel flag is a valid number between 1-20
|
||||
if parallel < 1 || parallel > 20 {
|
||||
return K8sOptions{}, xerrors.Errorf("unable to parse parallel value, please ensure that the value entered is a valid number between 1-20.")
|
||||
}
|
||||
}
|
||||
|
||||
exludeNodeLabels := make(map[string]string)
|
||||
exludeNodes := getStringSlice(f.ExcludeNodes)
|
||||
for _, exludeNodeValue := range exludeNodes {
|
||||
@@ -184,7 +166,6 @@ func (f *K8sFlagGroup) ToOptions() (K8sOptions, error) {
|
||||
KubeConfig: getString(f.KubeConfig),
|
||||
Components: getStringSlice(f.Components),
|
||||
K8sVersion: getString(f.K8sVersion),
|
||||
Parallel: parallel,
|
||||
Tolerations: tolerations,
|
||||
AllNamespaces: getBool(f.AllNamespaces),
|
||||
NodeCollectorNamespace: getString(f.NodeCollectorNamespace),
|
||||
|
||||
Reference in New Issue
Block a user