Skip to content

Commit 49a0718

Browse files
authored
Merge pull request #264 from shawn-hurley/issue-255
up local command: add flag operator-flags
2 parents c33722e + d81235b commit 49a0718

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

commands/operator-sdk/cmd/up/local.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os/exec"
77
"os/user"
88
"path/filepath"
9+
"strings"
910

1011
"github.com/operator-framework/operator-sdk/commands/operator-sdk/cmd/cmdutil"
1112
cmdError "github.com/operator-framework/operator-sdk/commands/operator-sdk/error"
@@ -18,20 +19,22 @@ func NewLocalCmd() *cobra.Command {
1819
upLocalCmd := &cobra.Command{
1920
Use: "local",
2021
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
2324
kubernetes cluster using a kubeconfig file.
2425
`,
2526
Run: upLocalFunc,
2627
}
2728

2829
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\"")
2931

3032
return upLocalCmd
3133
}
3234

3335
var (
34-
kubeConfig string
36+
kubeConfig string
37+
operatorFlags string
3538
)
3639

3740
const (
@@ -67,7 +70,12 @@ func mustKubeConfig() {
6770
}
6871

6972
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...)
7179
dc.Stdout = os.Stdout
7280
dc.Stderr = os.Stderr
7381
dc.Env = append(os.Environ(), fmt.Sprintf("%v=%v", k8sutil.KubeConfigEnvVar, kubeConfig))

0 commit comments

Comments
 (0)