Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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