6
6
"os/exec"
7
7
"os/user"
8
8
"path/filepath"
9
+ "strings"
9
10
10
11
"github.com/operator-framework/operator-sdk/commands/operator-sdk/cmd/cmdutil"
11
12
cmdError "github.com/operator-framework/operator-sdk/commands/operator-sdk/error"
@@ -18,20 +19,22 @@ func NewLocalCmd() *cobra.Command {
18
19
upLocalCmd := & cobra.Command {
19
20
Use : "local" ,
20
21
Short : "Launches the operator locally" ,
21
- Long : `The operator-sdk up local command launches the operator on the local machine
22
- by building the operator binary with the ability to access a
22
+ Long : `The operator-sdk up local command launches the operator on the local machine
23
+ by building the operator binary with the ability to access a
23
24
kubernetes cluster using a kubeconfig file.
24
25
` ,
25
26
Run : upLocalFunc ,
26
27
}
27
28
28
29
upLocalCmd .Flags ().StringVar (& kubeConfig , "kubeconfig" , "" , "The file path to kubernetes configuration file; defaults to $HOME/.kube/config" )
30
+ upLocalCmd .Flags ().StringVar (& operatorFlags , "operator-flags" , "" , "The flags that the operator needs. Example: \" --flag1 value1 --flag2=value2\" " )
29
31
30
32
return upLocalCmd
31
33
}
32
34
33
35
var (
34
- kubeConfig string
36
+ kubeConfig string
37
+ operatorFlags string
35
38
)
36
39
37
40
const (
@@ -67,7 +70,12 @@ func mustKubeConfig() {
67
70
}
68
71
69
72
func upLocal (projectName string ) {
70
- dc := exec .Command (gocmd , run , filepath .Join (cmd , projectName , main ))
73
+ args := []string {run , filepath .Join (cmd , projectName , main )}
74
+ if operatorFlags != "" {
75
+ extraArgs := strings .Split (operatorFlags , " " )
76
+ args = append (args , extraArgs ... )
77
+ }
78
+ dc := exec .Command (gocmd , args ... )
71
79
dc .Stdout = os .Stdout
72
80
dc .Stderr = os .Stderr
73
81
dc .Env = append (os .Environ (), fmt .Sprintf ("%v=%v" , k8sutil .KubeConfigEnvVar , kubeConfig ))
0 commit comments