updating prerequisites to support custom kubeconfig

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
This commit is contained in:
Matthias Bertschy
2025-03-18 10:02:17 +01:00
parent a089831720
commit 97c83a652b
3 changed files with 9 additions and 4 deletions

View File

@@ -13,12 +13,14 @@ import (
)
func GetPreReqCmd(ks meta.IKubescape) *cobra.Command {
var kubeconfigPath *string
// preReqCmd represents the prerequisites command
preReqCmd := &cobra.Command{
Use: "prerequisites",
Short: "Check prerequisites for installing Kubescape Operator",
Run: func(cmd *cobra.Command, args []string) {
clientSet, inCluster := common.BuildKubeClient()
clientSet, inCluster := common.BuildKubeClient(*kubeconfigPath)
if clientSet == nil {
logger.L().Fatal("Could not create kube client. Exiting.")
}
@@ -42,5 +44,8 @@ func GetPreReqCmd(ks meta.IKubescape) *cobra.Command {
common.GenerateOutput(finalReport, inCluster)
},
}
kubeconfigPath = preReqCmd.PersistentFlags().String("kubeconfig", "", "Path to the kubeconfig file. If not set, in-cluster config is used or $HOME/.kube/config if outside a cluster.")
return preReqCmd
}

2
go.mod
View File

@@ -34,7 +34,7 @@ require (
github.com/kubescape/opa-utils v0.0.287
github.com/kubescape/rbac-utils v0.0.21-0.20230806101615-07e36f555520
github.com/kubescape/regolibrary/v2 v2.0.1
github.com/kubescape/sizing-checker v0.0.0-20250225194755-bed52921170a
github.com/kubescape/sizing-checker v0.0.0-20250316121643-6a57be537b60
github.com/maruel/natural v1.1.1
github.com/matthyx/go-gitlog v0.0.0-20231005131906-9ffabe3c5bcd
github.com/mattn/go-isatty v0.0.20

4
go.sum
View File

@@ -1189,8 +1189,8 @@ github.com/kubescape/rbac-utils v0.0.21-0.20230806101615-07e36f555520 h1:SqlwF8G
github.com/kubescape/rbac-utils v0.0.21-0.20230806101615-07e36f555520/go.mod h1:wuxMUSDzGUyWd25IJfBzEJ/Udmw2Vy7npj+MV3u3GrU=
github.com/kubescape/regolibrary/v2 v2.0.1 h1:7lKj171gslgTbbcmmGVHk34AZNqxForOXZIINoQfdzQ=
github.com/kubescape/regolibrary/v2 v2.0.1/go.mod h1:s0/Mi9PYw7s91vIf1VJTkuu1Blsl5ZLpYn5UA7yk/vM=
github.com/kubescape/sizing-checker v0.0.0-20250225194755-bed52921170a h1:qduF+/rE+UY1saBlfmSM1b594qgByqCCHzw5s4es5X8=
github.com/kubescape/sizing-checker v0.0.0-20250225194755-bed52921170a/go.mod h1:xCg5Fh96STR7zQ3Tj2jrHi6oIMCwdwfr7ir5n1nJBQw=
github.com/kubescape/sizing-checker v0.0.0-20250316121643-6a57be537b60 h1:qkdDbR8o6GG9ptLJoCqmYCbvnWXmiw02t7/44yo6hqw=
github.com/kubescape/sizing-checker v0.0.0-20250316121643-6a57be537b60/go.mod h1:xCg5Fh96STR7zQ3Tj2jrHi6oIMCwdwfr7ir5n1nJBQw=
github.com/kubescape/tablewriter v0.0.6-0.20231106230230-aac7d2659c94 h1:uhabZUyrxo60JQrzGCQOp1gsJz06+6+PeDBTvXiKD7k=
github.com/kubescape/tablewriter v0.0.6-0.20231106230230-aac7d2659c94/go.mod h1:clwQfF3MN2cpaf7R6hc84aB6fQsRr+bnm66pXXSNAv8=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=