feat: config outdated-api result filtered by k8s version (#3578)

Signed-off-by: chenk <hen.keinan@gmail.com>
Co-authored-by: knqyf263 <knqyf263@gmail.com>
This commit is contained in:
chenk
2023-02-22 15:41:37 +02:00
committed by GitHub
parent 9af436b999
commit 92eaf636ca
8 changed files with 370 additions and 18 deletions

View File

@@ -32,6 +32,12 @@ var (
},
Usage: "specify which components to scan",
}
K8sVersionFlag = Flag{
Name: "k8s-version",
ConfigName: "kubernetes.k8s.version",
Value: "",
Usage: "specify k8s version to validate outdated api by it (example: 1.21.0)",
}
)
type K8sFlagGroup struct {
@@ -39,6 +45,7 @@ type K8sFlagGroup struct {
Namespace *Flag
KubeConfig *Flag
Components *Flag
K8sVersion *Flag
}
type K8sOptions struct {
@@ -46,6 +53,7 @@ type K8sOptions struct {
Namespace string
KubeConfig string
Components []string
K8sVersion string
}
func NewK8sFlagGroup() *K8sFlagGroup {
@@ -54,6 +62,7 @@ func NewK8sFlagGroup() *K8sFlagGroup {
Namespace: &K8sNamespaceFlag,
KubeConfig: &KubeConfigFlag,
Components: &ComponentsFlag,
K8sVersion: &K8sVersionFlag,
}
}
@@ -67,6 +76,7 @@ func (f *K8sFlagGroup) Flags() []*Flag {
f.Namespace,
f.KubeConfig,
f.Components,
f.K8sVersion,
}
}
@@ -76,5 +86,6 @@ func (f *K8sFlagGroup) ToOptions() K8sOptions {
Namespace: getString(f.Namespace),
KubeConfig: getString(f.KubeConfig),
Components: getStringSlice(f.Components),
K8sVersion: getString(f.K8sVersion),
}
}