Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions cmd/operator-sdk/up/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ kubernetes cluster using a kubeconfig file.
upLocalCmd.Flags().StringVar(&operatorFlags, "operator-flags", "", "The flags that the operator needs. Example: \"--flag1 value1 --flag2=value2\"")
upLocalCmd.Flags().StringVar(&namespace, "namespace", "", "The namespace where the operator watches for changes.")
upLocalCmd.Flags().StringVar(&ldFlags, "go-ldflags", "", "Set Go linker options")
upLocalCmd.Flags().BoolVar(&enableRaceDetector, "race", false, "Enables the go runtime's race detector when compiling the operator")
upLocalCmd.Flags().BoolVar(&enableDelve, "enable-delve", false, "Start the operator using the delve debugger")
switch projutil.GetOperatorType() {
case projutil.OperatorTypeAnsible:
Expand All @@ -72,6 +73,7 @@ var (
operatorFlags string
namespace string
ldFlags string
enableRaceDetector bool
enableDelve bool
ansibleOperatorFlags *aoflags.AnsibleOperatorFlags
helmOperatorFlags *hoflags.HelmOperatorFlags
Expand Down
1 change: 1 addition & 0 deletions doc/cli/operator-sdk_up_local.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ operator-sdk up local [flags]
--kubeconfig string The file path to kubernetes configuration file; defaults to location specified by $KUBECONFIG with a fallback to $HOME/.kube/config if not set
--namespace string The namespace where the operator watches for changes.
--operator-flags string The flags that the operator needs. Example: "--flag1 value1 --flag2=value2"
--race Enables the go runtime's race detector when compiling the operator
```

### SEE ALSO
Expand Down
6 changes: 6 additions & 0 deletions internal/util/projutil/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type GoCmdOptions struct {
Env []string
// Dir is the dir to run "go {cmd}" in; exec.Command.Dir is set to this value.
Dir string
// Race is to add the -race flag when compiling the operator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An extra flag is not needed. -race can be appended directly to GoCmdOptions.Args in the caller.

Race bool
}

// GoTestOptions is the set of options for "go test".
Expand Down Expand Up @@ -129,6 +131,10 @@ func (opts GoCmdOptions) getGeneralArgsWithCmd(cmd string) ([]string, error) {
}
}

if opts.Race {
bargs = append(bargs, "-race")
}

if opts.PackagePath != "" {
bargs = append(bargs, opts.PackagePath)
}
Expand Down