diff --git a/CHANGELOG.md b/CHANGELOG.md index d859a1339af..fa0b948d346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Fixes header file content validation when the content contains empty lines or centered text. ([#1544](https://github.com/operator-framework/operator-sdk/pull/1544)) - Generated CSV's that include a deployment install strategy will be checked for a reference to `metadata.annotations['olm.targetNamespaces']`, and if one is not found a reference will be added to the `WATCH_NAMESPACE` env var for all containers in the deployment. This is a bug because any other value that references the CSV's namespace is incorrect. ([#1396](https://github.com/operator-framework/operator-sdk/pull/1396)) +- Build `-trimpath` was not being respected. `$GOPATH` was not expanding because `exec.Cmd{}` is not executed in a shell environment. ([#1535](https://github.com/operator-framework/operator-sdk/pull/1535)) ## v0.8.1 diff --git a/cmd/operator-sdk/build/cmd.go b/cmd/operator-sdk/build/cmd.go index d5b334a9628..c02492facea 100644 --- a/cmd/operator-sdk/build/cmd.go +++ b/cmd/operator-sdk/build/cmd.go @@ -92,7 +92,8 @@ func buildFunc(cmd *cobra.Command, args []string) error { goBuildEnv = append(goBuildEnv, "CGO_ENABLED=0") } - goTrimFlags := []string{"-gcflags", "all=-trimpath=${GOPATH}", "-asmflags", "all=-trimpath=${GOPATH}"} + trimPath := os.ExpandEnv("all=-trimpath=${GOPATH}") + goTrimFlags := []string{"-gcflags", trimPath, "-asmflags", trimPath} absProjectPath := projutil.MustGetwd() projectName := filepath.Base(absProjectPath) diff --git a/internal/util/projutil/exec.go b/internal/util/projutil/exec.go index 1fde21f913a..e9d792205a2 100644 --- a/internal/util/projutil/exec.go +++ b/internal/util/projutil/exec.go @@ -113,8 +113,9 @@ func getGeneralArgs(cmd string, opts GoCmdOptions) ([]string, error) { } func setCommandFields(c *exec.Cmd, opts GoCmdOptions) { + c.Env = append(c.Env, os.Environ()...) if len(opts.Env) != 0 { - c.Env = append(os.Environ(), opts.Env...) + c.Env = append(c.Env, opts.Env...) } if opts.Dir != "" { c.Dir = opts.Dir