Skip to content

Commit a5c69e3

Browse files
committed
feat: update scan command to receive parameters
Signed-off-by: freedisch <freeproduc@gmail.com>
1 parent 3426715 commit a5c69e3

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

scbctl/cmd/scans.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"context"
88
"errors"
99
"fmt"
10+
"strings"
1011

1112
v1 "github.com/secureCodeBox/secureCodeBox/operator/apis/execution/v1"
1213
kubernetes "github.com/secureCodeBox/secureCodeBox/scbctl/pkg"
@@ -43,16 +44,27 @@ var ScanCmd = &cobra.Command{
4344
}
4445

4546
scanName := args[0]
46-
target := args[1]
47+
paramIndex := cmd.ArgsLenAtDash()
48+
if paramIndex == -1 {
49+
return errors.New("You must use '--' to separate scan parameters")
50+
}
51+
4752

53+
parameters := args[paramIndex:]
54+
55+
4856
fmt.Println("🎬 Initializing Kubernetes client")
4957

5058
kubeclient, namespace, err := clientProvider.GetClient(kubeconfigArgs)
5159
if err != nil {
5260
return fmt.Errorf("Error initializing Kubernetes client: %s", err)
5361
}
5462

55-
fmt.Printf("🆕 Creating a new scan with name '%s' and target '%s'\n", scanName, target)
63+
if namespaceFlag, err := cmd.Flags().GetString("namespace"); err == nil && namespaceFlag != "" {
64+
namespace = namespaceFlag
65+
}
66+
67+
fmt.Printf("🆕 Creating a new scan with name '%s' and target '%s'\n", scanName, strings.Join(parameters, " "))
5668

5769
scan := &v1.Scan{
5870
TypeMeta: metav1.TypeMeta{
@@ -65,9 +77,7 @@ var ScanCmd = &cobra.Command{
6577
},
6678
Spec: v1.ScanSpec{
6779
ScanType: scanName,
68-
Parameters: []string{
69-
target,
70-
},
80+
Parameters: parameters,
7181
},
7282
}
7383

scbctl/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ var rootCmd = &cobra.Command{
2626
func init() {
2727
utilruntime.Must(v1.AddToScheme(scheme))
2828
rootCmd.AddCommand(cmd.ScanCmd)
29-
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
30-
3129
kubeconfigArgs.AddFlags(rootCmd.PersistentFlags())
3230
}
3331
func main() {

0 commit comments

Comments
 (0)