Skip to content

Commit 8d7e421

Browse files
darkowlzzestroz
authored andcommitted
cmd/up/local: add option to set go linker flags (#731)
This adds a new flags to `up local` command: `--go-ldflags`. `--go-ldflags` flag is used to pass the go compiler -ldflag options to the underlying operator up local go command.
1 parent 675fb6e commit 8d7e421

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

commands/operator-sdk/cmd/up/local.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ kubernetes cluster using a kubeconfig file.
5555
upLocalCmd.Flags().StringVar(&kubeConfig, "kubeconfig", "", "The file path to kubernetes configuration file; defaults to $HOME/.kube/config")
5656
upLocalCmd.Flags().StringVar(&operatorFlags, "operator-flags", "", "The flags that the operator needs. Example: \"--flag1 value1 --flag2=value2\"")
5757
upLocalCmd.Flags().StringVar(&namespace, "namespace", "default", "The namespace where the operator watches for changes.")
58+
upLocalCmd.Flags().StringVar(&ldFlags, "go-ldflags", "", "Set Go linker options")
5859

5960
return upLocalCmd
6061
}
@@ -63,6 +64,7 @@ var (
6364
kubeConfig string
6465
operatorFlags string
6566
namespace string
67+
ldFlags string
6668
)
6769

6870
const (
@@ -100,7 +102,11 @@ func mustKubeConfig() {
100102
}
101103

102104
func upLocal() {
103-
args := []string{"run", filepath.Join(scaffold.ManagerDir, scaffold.CmdFile)}
105+
args := []string{"run"}
106+
if ldFlags != "" {
107+
args = append(args, []string{"-ldflags", ldFlags}...)
108+
}
109+
args = append(args, filepath.Join(scaffold.ManagerDir, scaffold.CmdFile))
104110
if operatorFlags != "" {
105111
extraArgs := strings.Split(operatorFlags, " ")
106112
args = append(args, extraArgs...)

0 commit comments

Comments
 (0)