Skip to content

Commit

Permalink
Merge pull request #264 from shawn-hurley/issue-255
Browse files Browse the repository at this point in the history
up local command: add flag operator-flags
  • Loading branch information
fanminshi committed May 18, 2018
2 parents c33722e + d81235b commit 49a0718
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions commands/operator-sdk/cmd/up/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -18,20 +19,22 @@ func NewLocalCmd() *cobra.Command {
upLocalCmd := &cobra.Command{
Use: "local",
Short: "Launches the operator locally",
Long: `The operator-sdk up local command launches the operator on the local machine
by building the operator binary with the ability to access a
Long: `The operator-sdk up local command launches the operator on the local machine
by building the operator binary with the ability to access a
kubernetes cluster using a kubeconfig file.
`,
Run: upLocalFunc,
}

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
kubeConfig string
operatorFlags string
)

const (
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 49a0718

Please sign in to comment.