cmd/up/local: add flag operator-flags
extra-flags gives the ability to pass flags to the local operator.
Fixes
@@ -6,6 +6,7 @@ import (
"os/exec"
"os/user"
"path/filepath"
+ "strings"
"github.com/operator-framework/operator-sdk/commands/operator-sdk/cmd/cmdutil"
cmdError "github.com/operator-framework/operator-sdk/commands/operator-sdk/error"
@@ -26,12 +27,14 @@ kubernetes cluster using a kubeconfig file.
}
upLocalCmd.Flags().StringVar(&kubeConfig, "kubeconfig", "", "The file path to kubernetes configuration file; defaults to $HOME/.kube/config")
+ upLocalCmd.Flags().StringVar(&operatorFlags, "operator-flags", "", "The flags that the operator needs. Example: \"--flag1 value1 --flag2=value2\"")
return upLocalCmd
}
var (
kubeConfig string
+ operatorFlags string
)
const (
@@ -67,7 +70,12 @@ func mustKubeConfig() {
}
func upLocal(projectName string) {
- dc := exec.Command(gocmd, run, filepath.Join(cmd, projectName, main))
+ args := []string{run, filepath.Join(cmd, projectName, main)}
+ if operatorFlags != "" {
+ extraArgs := strings.Split(operatorFlags, " ")
+ args = append(args, extraArgs...)
+ }
+ dc := exec.Command(gocmd, args...)
dc.Stdout = os.Stdout
dc.Stderr = os.Stderr
dc.Env = append(os.Environ(), fmt.Sprintf("%v=%v", k8sutil.KubeConfigEnvVar, kubeConfig))
