Skip to content

Commit

Permalink
Merge pull request #274 from jhernandezb/feature/up-ns-flag
Browse files Browse the repository at this point in the history
commands/operator-sdk/cmd/local: add namespace flag
  • Loading branch information
fanminshi committed May 23, 2018
2 parents 2fbaa01 + baf0f02 commit 02cf852
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Added

- Added `operator-sdk up` command to help deploy an operator. Currently supports running an operator locally against an existing cluster e.g `operator-sdk up local --kubeconfig=<path-to-kubeconfig>`. See `operator-sdk up -h` for help. [#219](https://github.com/operator-framework/operator-sdk/pull/219)
- Added `operator-sdk up` command to help deploy an operator. Currently supports running an operator locally against an existing cluster e.g `operator-sdk up local --kubeconfig=<path-to-kubeconfig> --namespace=<operator-namespace>`. See `operator-sdk up -h` for help. [#219](https://github.com/operator-framework/operator-sdk/pull/219) [#274](https://github.com/operator-framework/operator-sdk/pull/274)

### Changed

Expand Down
4 changes: 3 additions & 1 deletion commands/operator-sdk/cmd/up/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ 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\"")
upLocalCmd.Flags().StringVar(&namespace, "namespace", "default", "The namespace where the operator watches for changes.")

return upLocalCmd
}

var (
kubeConfig string
operatorFlags string
namespace string
)

const (
Expand Down Expand Up @@ -78,7 +80,7 @@ func upLocal(projectName string) {
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))
dc.Env = append(os.Environ(), fmt.Sprintf("%v=%v", k8sutil.KubeConfigEnvVar, kubeConfig), fmt.Sprintf("%v=%v", k8sutil.WatchNamespaceEnvVar, namespace))
err := dc.Run()
if err != nil {
cmdError.ExitWithError(cmdError.ExitError, fmt.Errorf("failed to run operator locally: %v", err))
Expand Down

0 comments on commit 02cf852

Please sign in to comment.