canonical / snap-vault

Vault is a tool for securely accessing secrets
https://snapcraft.io/vault
Other
16 stars 10 forks source link

Build date and commit ID missing from binary #87

Open gruyaume opened 3 months ago

gruyaume commented 3 months ago

Describe the bug

The build date is missing from the vault binary. When you run vault status, you see n/a as the build date.

To Reproduce

  1. Install the vault snap: sudo snap install vault
  2. Start the vault daemon: sudo snap start vault.vaultd
  3. Run vault status
guillaume@potiron:~$ vault status
Key                Value
---                -----
Seal Type          shamir
Initialized        false
Sealed             true
Total Shares       0
Threshold          0
Unseal Progress    0/0
Unseal Nonce       n/a
Version            1.15.6
Build Date         n/a
Storage Type       file
HA Enabled         false

Here note the n/a next to Build Date.

The same can be observed when running vault --version, where we only see the vault version.

guillaume@potiron:~$ vault --version
Vault v1.15.6 (cgo)

Expected behavior

The following outputs are taken from running the same commands using the vault debs:

guillaume@potiron:~$ vault status
Key                Value
---                -----
Seal Type          shamir
Initialized        false
Sealed             true
Total Shares       0
Threshold          0
Unseal Progress    0/0
Unseal Nonce       n/a
Version            1.15.6
Build Date         2024-02-28T17:07:34Z
Storage Type       file
HA Enabled         false

And in the vault version command:

guillaume@potiron:~$ vault --version
Vault v1.15.6 (615cf6f1dce9aa91bc2035ce33b9f689952218f0), built 2024-02-28T17:07:34Z

Environment

gruyaume commented 3 months ago

I'm pretty sure this can be fixed by using the following ldflags at build time:

-ldflags "${LD_FLAGS} -X github.com/hashicorp/vault/version.GitCommit='${GIT_COMMIT}${GIT_DIRTY}' -X github.com/hashicorp/vault/version.BuildDate=${BUILD_DATE}" \

Reference:

gruyaume commented 3 months ago

Plus, whatever we do here, let's make sure we port it to the rock: