Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove gox in favor of go build. #16353

Merged
merged 3 commits into from
Jul 20, 2022
Merged

Remove gox in favor of go build. #16353

merged 3 commits into from
Jul 20, 2022

Conversation

swenson
Copy link
Contributor

@swenson swenson commented Jul 19, 2022

gox hasn't had a release to update it in many years, so is missing
support for many modern systems, like darwin/arm64.

In any case, we only use it for dev builds, where we don't even use
the ability of it to build for multiple platforms. Release builds use
go build now.

So, this switches to go build everywhere.

I pulled this down and tested it in Windows as well. (Side note: I
couldn't get gox to work in Windows, so couldn't build before this
change.)

@swenson swenson requested review from mladlow and a team July 19, 2022 18:09
@@ -1,6 +1,5 @@
# Multi-stage builder to avoid polluting users environment with wrong
# architecture binaries. Since this binary is used in an alpine container,
# we're explicitly compiling for 'linux/amd64'
# architecture binaries.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this comment about linux/amd64 as I was able to successfully get this to work on linux/arm64 on my Mac as well (but not Dockerfile.ui due to problems with the debian distro).

@mpalmi
Copy link
Contributor

mpalmi commented Jul 19, 2022

This looks good to me. Nothing really jumped out at me and I was able to build locally (darwin/arm64).

Just in case you missed this reference, should we update the website content to remove the gox recommendation for building plugins?

➜  vault (5c61957f39) rg "gox" website/
website/content/docs/secrets/databases/custom.mdx
211:build with [gox](https://github.com/mitchellh/gox) for cross platform builds.

@swenson
Copy link
Contributor Author

swenson commented Jul 19, 2022

Ah, thanks, I had missed that reference in the docs. Will remove.

Copy link
Contributor

@tomhjp tomhjp left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@benashz benashz left a comment

Choose a reason for hiding this comment

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

LGTM!

-tags="${BUILD_TAGS}" \
-gocmd="${GO_CMD}" \
-ldflags "${LD_FLAGS} -X github.com/hashicorp/vault/sdk/version.GitCommit='${GIT_COMMIT}${GIT_DIRTY}' -X github.com/hashicorp/vault/sdk/version.BuildDate=${BUILD_DATE}" \
-o "bin/vault" \
Copy link
Collaborator

Choose a reason for hiding this comment

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

This bit will probably be missed:

    rm -f ${MAIN_GOPATH}/bin/vault
    cp ${F} ${MAIN_GOPATH}/bin/

Can you do something equivalent? People are used to the newly built being in their path.
Also the rm is important on macos, something to do with their binary scanning/validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

go build does this under the hood already: golang/go@cf7aa58 (thanks to mitchellh for the link).

I'll re-add the bit to copy into the GOPATH.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It does that for the build target, but if we're copying into GOPATH, that binary will still be vulnerable to the same problem, I think. Happy to test it once you've made the change if you like.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept the rm for the copy into GOPATH. It should be committed now if you would like to test.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I just tested with a manual cp, and it gets sigkilled.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Tested your branch, works!

@@ -207,8 +207,7 @@ func Run() error {
## Running your plugin

The above main package, once built, will supply you with a binary of your
plugin. We also recommend if you are planning on distributing your plugin to
build with [gox](https://github.com/mitchellh/gox) for cross platform builds.
plugin.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might not include this bit, our removal of gox from vault doesn't necessarily have implications for plugins.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@ncabatoff
Copy link
Collaborator

Looks good modulo my comments above. When this is merged, please email team-vault to inform them of this change. The only user-facing impact I see is that those who are used to using XC_OSARCH for cross platform builds will now want to use GOOS/GOARCH instead, but if you've noticed anything else you could mention that too.

Christopher Swenson added 3 commits July 20, 2022 10:16
`gox` hasn't had a release to update it in many years, so is missing
support for many modern systems, like `darwin/arm64`.

In any case, we only use it for dev builds, where we don't even use
the ability of it to build for multiple platforms. Release builds use
`go build` now.

So, this switches to `go build` everywhere.

I pulled this down and tested it in Windows as well. (Side note: I
couldn't get `gox` to work in Windows, so couldn't build before this
change.)
@swenson
Copy link
Contributor Author

swenson commented Jul 20, 2022

Thanks everyone!

@swenson swenson merged commit fa91af9 into main Jul 20, 2022
@swenson swenson deleted the remove-gox branch July 20, 2022 17:44
fairclothjm added a commit to hashicorp/vault-plugin-database-snowflake that referenced this pull request Mar 16, 2023
gox is no longer maintained and releases are done with `go build` now.
See hashicorp/vault#16353 where we removed gox
in Vault.
fairclothjm added a commit to hashicorp/vault-plugin-secrets-ad that referenced this pull request Mar 16, 2023
gox is no longer maintained and releases are done with now.
See hashicorp/vault#16353 where we removed gox in Vault.
fairclothjm added a commit to hashicorp/vault-plugin-secrets-terraform that referenced this pull request Mar 16, 2023
gox is no longer maintained and releases are done with `go build` now.
See hashicorp/vault#16353 where we removed gox in Vault.
fairclothjm added a commit to hashicorp/vault-plugin-database-snowflake that referenced this pull request Mar 16, 2023
gox is no longer maintained and releases are done with `go build` now.
See hashicorp/vault#16353 where we removed gox
in Vault.
fairclothjm added a commit to hashicorp/vault-plugin-secrets-ad that referenced this pull request Mar 16, 2023
gox is no longer maintained and releases are done with now.
See hashicorp/vault#16353 where we removed gox in Vault.
fairclothjm added a commit to hashicorp/vault-plugin-secrets-terraform that referenced this pull request Mar 16, 2023
gox is no longer maintained and releases are done with `go build` now.
See hashicorp/vault#16353 where we removed gox in Vault.
fairclothjm added a commit to hashicorp/vault-plugin-database-snowflake that referenced this pull request Mar 16, 2023
* Remove gox in favor of go build

gox is no longer maintained and releases are done with `go build` now.
See hashicorp/vault#16353 where we removed gox
in Vault.

* revert accidental commit of snowflake.go file

* update readme link

* re-revert snowflake.go; confusion bc branch needed rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants