mirror of
https://github.com/openbao/openbao.git
synced 2026-06-01 18:57:37 +02:00
Change BuildDate to CommitDate to avoid confusion (#2678)
Signed-off-by: hashworks <mail@hashworks.net>
This commit is contained in:
committed by
GitHub
parent
c973c7693e
commit
873e6e3f44
+4
-1
@@ -104,7 +104,7 @@ type SealStatusResponse struct {
|
||||
Progress int `json:"progress"`
|
||||
Nonce string `json:"nonce"`
|
||||
Version string `json:"version"`
|
||||
BuildDate string `json:"build_date"`
|
||||
CommitDate string `json:"commit_date"`
|
||||
Migration bool `json:"migration"`
|
||||
ClusterName string `json:"cluster_name,omitempty"`
|
||||
ClusterID string `json:"cluster_id,omitempty"`
|
||||
@@ -113,6 +113,9 @@ type SealStatusResponse struct {
|
||||
StorageType string `json:"storage_type,omitempty"`
|
||||
// unused in OpenBao, but present for compatibility
|
||||
Warnings []string `json:"warnings,omitempty"`
|
||||
// Deprecated: Use CommitDate instead.
|
||||
// This field remains for backwards-compatibility with OpenBao < v2.6.0.
|
||||
BuildDate string `json:"build_date"`
|
||||
}
|
||||
|
||||
type UnsealOpts struct {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
```release-note:change
|
||||
packaging: Renamed misleading ldflags definition `BuildDate` to `CommitDate`. Build systems need to adjust their pipelines to reflect this change.
|
||||
```
|
||||
|
||||
```release-note:change
|
||||
sys/seal-status: Renamed misleading `build_date` response field to `commit_date`.
|
||||
```
|
||||
|
||||
```release-note:change
|
||||
sys/version-history: Renamed misleading `build_date` response field to `commit_date`.
|
||||
```
|
||||
+2
-2
@@ -318,8 +318,8 @@ func (t TableFormatter) OutputSealStatusStruct(ui cli.Ui, data interface{}) erro
|
||||
out = append(out, fmt.Sprintf("Version | %s", status.Version))
|
||||
}
|
||||
|
||||
if status.BuildDate != "" {
|
||||
out = append(out, fmt.Sprintf("Build Date | %s", status.BuildDate))
|
||||
if status.CommitDate != "" {
|
||||
out = append(out, fmt.Sprintf("Commit Date | %s", status.CommitDate))
|
||||
}
|
||||
|
||||
if status.StorageType != "" {
|
||||
|
||||
@@ -118,7 +118,7 @@ Unseal Progress 3/1
|
||||
Unseal Nonce nonce
|
||||
Seal Migration in Progress true
|
||||
Version version
|
||||
Build Date build date
|
||||
Commit Date commit date
|
||||
Storage Type storage type
|
||||
Cluster Name cluster name
|
||||
Cluster ID cluster id
|
||||
@@ -149,7 +149,7 @@ Unseal Progress 3/1
|
||||
Unseal Nonce nonce
|
||||
Seal Migration in Progress true
|
||||
Version version
|
||||
Build Date build date
|
||||
Commit Date commit date
|
||||
Storage Type type
|
||||
HA Enabled false`
|
||||
|
||||
@@ -176,7 +176,7 @@ func getMockStatusData(emptyFields bool) SealStatusOutput {
|
||||
Progress: 3,
|
||||
Nonce: "nonce",
|
||||
Version: "version",
|
||||
BuildDate: "build date",
|
||||
CommitDate: "commit date",
|
||||
Migration: true,
|
||||
ClusterName: "cluster name",
|
||||
ClusterID: "cluster id",
|
||||
@@ -206,7 +206,7 @@ func getMockStatusData(emptyFields bool) SealStatusOutput {
|
||||
Progress: 3,
|
||||
Nonce: "nonce",
|
||||
Version: "version",
|
||||
BuildDate: "build date",
|
||||
CommitDate: "commit date",
|
||||
Migration: true,
|
||||
ClusterName: "",
|
||||
ClusterID: "",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@@ -103,7 +104,7 @@ func (c *VersionHistoryCommand) Run(args []string) int {
|
||||
return 2
|
||||
}
|
||||
|
||||
table := []string{"Version | Installation Time | Build Date"}
|
||||
table := []string{"Version | Installation Time | Commit Date"}
|
||||
columnConfig := columnize.DefaultConfig()
|
||||
|
||||
for _, versionRaw := range keys {
|
||||
@@ -122,7 +123,10 @@ func (c *VersionHistoryCommand) Run(args []string) int {
|
||||
return 2
|
||||
}
|
||||
|
||||
table = append(table, fmt.Sprintf("%s | %s | %s", version, versionInfo["timestamp_installed"], versionInfo["build_date"]))
|
||||
// Fallback: Use build_date for backwards-compatibility with OpenBao < v2.6.0.
|
||||
commitDate := cmp.Or(versionInfo["commit_date"], versionInfo["build_date"])
|
||||
|
||||
table = append(table, fmt.Sprintf("%s | %s | %s", version, versionInfo["timestamp_installed"], commitDate))
|
||||
}
|
||||
|
||||
c.UI.Warn("")
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ builds:
|
||||
- ui
|
||||
- hsm
|
||||
ldflags:
|
||||
- -X github.com/openbao/openbao/version.fullVersion={{.Version}} -X github.com/openbao/openbao/version.GitCommit={{.Commit}} -X github.com/openbao/openbao/version.BuildDate={{ .Date }} -X github.com/openbao/openbao/version.VersionMetadata=hsm
|
||||
- -X github.com/openbao/openbao/version.fullVersion={{.Version}} -X github.com/openbao/openbao/version.GitCommit={{.Commit}} -X github.com/openbao/openbao/version.CommitDate={{ .Date }} -X github.com/openbao/openbao/version.VersionMetadata=hsm
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- >-
|
||||
|
||||
@@ -16,7 +16,7 @@ builds:
|
||||
tags:
|
||||
- ui
|
||||
ldflags:
|
||||
- -X github.com/openbao/openbao/version.fullVersion={{.Version}} -X github.com/openbao/openbao/version.GitCommit={{.Commit}} -X github.com/openbao/openbao/version.BuildDate={{ .Date }}
|
||||
- -X github.com/openbao/openbao/version.fullVersion={{.Version}} -X github.com/openbao/openbao/version.GitCommit={{.Commit}} -X github.com/openbao/openbao/version.CommitDate={{ .Date }}
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
|
||||
@@ -16,7 +16,7 @@ builds:
|
||||
tags:
|
||||
- ui
|
||||
ldflags:
|
||||
- -X github.com/openbao/openbao/version.fullVersion={{.Version}} -X github.com/openbao/openbao/version.GitCommit={{.Commit}} -X github.com/openbao/openbao/version.BuildDate={{ .Date }}
|
||||
- -X github.com/openbao/openbao/version.fullVersion={{.Version}} -X github.com/openbao/openbao/version.GitCommit={{.Commit}} -X github.com/openbao/openbao/version.CommitDate={{ .Date }}
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestSysSealStatus(t *testing.T) {
|
||||
"recovery_seal": false,
|
||||
"initialized": true,
|
||||
"migration": false,
|
||||
"build_date": version.BuildDate,
|
||||
"commit_date": version.CommitDate,
|
||||
}
|
||||
testResponseStatus(t, resp, 200)
|
||||
testResponseBody(t, resp, &actual)
|
||||
@@ -130,7 +130,7 @@ func TestSysUnseal(t *testing.T) {
|
||||
"recovery_seal": false,
|
||||
"initialized": true,
|
||||
"migration": false,
|
||||
"build_date": version.BuildDate,
|
||||
"commit_date": version.CommitDate,
|
||||
}
|
||||
if i == len(keys)-1 {
|
||||
expected["sealed"] = false
|
||||
@@ -369,7 +369,7 @@ func TestSysUnseal_Reset(t *testing.T) {
|
||||
"recovery_seal": false,
|
||||
"initialized": true,
|
||||
"migration": false,
|
||||
"build_date": version.BuildDate,
|
||||
"commit_date": version.CommitDate,
|
||||
}
|
||||
testResponseStatus(t, resp, 200)
|
||||
testResponseBody(t, resp, &actual)
|
||||
@@ -409,7 +409,7 @@ func TestSysUnseal_Reset(t *testing.T) {
|
||||
"type": "shamir",
|
||||
"recovery_seal": false,
|
||||
"initialized": true,
|
||||
"build_date": version.BuildDate,
|
||||
"commit_date": version.CommitDate,
|
||||
"migration": false,
|
||||
}
|
||||
testResponseStatus(t, resp, 200)
|
||||
|
||||
+3
-3
@@ -28,7 +28,7 @@ BUILD_TAGS="${BUILD_TAGS:-"openbao"}"
|
||||
GIT_COMMIT="$(git rev-parse HEAD)"
|
||||
GIT_DIRTY="$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)"
|
||||
|
||||
BUILD_DATE="$(git show --no-show-signature -s --format=%cd --date=format:"%Y-%m-%dT%H:%M:%SZ" HEAD)"
|
||||
COMMIT_DATE="$(git show --no-show-signature -s --format=%cd --date=format:"%Y-%m-%dT%H:%M:%SZ" HEAD)"
|
||||
|
||||
GOPATH=${GOPATH:-$(${GO_CMD} env GOPATH)}
|
||||
case $(uname) in
|
||||
@@ -47,7 +47,7 @@ mkdir -p bin/
|
||||
echo "==> Building bao..."
|
||||
${GO_CMD} build \
|
||||
-gcflags "${GCFLAGS}" \
|
||||
-ldflags "${LD_FLAGS} -X github.com/openbao/openbao/version.GitCommit='${GIT_COMMIT}${GIT_DIRTY}' -X github.com/openbao/openbao/version.BuildDate=${BUILD_DATE}" \
|
||||
-ldflags "${LD_FLAGS} -X github.com/openbao/openbao/version.GitCommit='${GIT_COMMIT}${GIT_DIRTY}' -X github.com/openbao/openbao/version.CommitDate=${COMMIT_DATE}" \
|
||||
-o "bin/bao" \
|
||||
-tags "${BUILD_TAGS}" \
|
||||
.
|
||||
@@ -66,7 +66,7 @@ if [ "$1" == "plugin" ]; then
|
||||
dirname="$(basename "$dir")"
|
||||
${GO_CMD} build \
|
||||
-gcflags "${GCFLAGS}" \
|
||||
-ldflags "${LD_FLAGS} -X github.com/openbao/openbao/version.GitCommit='${GIT_COMMIT}${GIT_DIRTY}' -X github.com/openbao/openbao/version.BuildDate=${BUILD_DATE}" \
|
||||
-ldflags "${LD_FLAGS} -X github.com/openbao/openbao/version.GitCommit='${GIT_COMMIT}${GIT_DIRTY}' -X github.com/openbao/openbao/version.CommitDate=${COMMIT_DATE}" \
|
||||
-o "bin/$etype-$plugin_name-$dirname" \
|
||||
-tags "${BUILD_TAGS}" \
|
||||
github.com/openbao/openbao/$dir
|
||||
|
||||
+2
-2
@@ -1296,7 +1296,7 @@ func (c *Core) handleVersionTimeStamps(ctx context.Context) error {
|
||||
vaultVersion := &VaultVersion{
|
||||
TimestampInstalled: currentTime,
|
||||
Version: version.Version,
|
||||
BuildDate: version.BuildDate,
|
||||
CommitDate: version.CommitDate,
|
||||
}
|
||||
|
||||
isUpdated, err := c.storeVersionEntry(ctx, vaultVersion, false)
|
||||
@@ -1304,7 +1304,7 @@ func (c *Core) handleVersionTimeStamps(ctx context.Context) error {
|
||||
return fmt.Errorf("error storing vault version: %w", err)
|
||||
}
|
||||
if isUpdated {
|
||||
c.logger.Info("Recorded vault version", "vault version", version.Version, "upgrade time", currentTime, "build date", version.BuildDate)
|
||||
c.logger.Info("Recorded vault version", "vault version", version.Version, "upgrade time", currentTime, "commit date", version.CommitDate)
|
||||
}
|
||||
|
||||
// Finally, repopulate the version history cache
|
||||
|
||||
@@ -4330,7 +4330,7 @@ type SealStatusResponse struct {
|
||||
type CoreSealStatusResponse struct {
|
||||
SealStatusResponse
|
||||
Version string `json:"version"`
|
||||
BuildDate string `json:"build_date"`
|
||||
CommitDate string `json:"commit_date"`
|
||||
Migration bool `json:"migration"`
|
||||
ClusterName string `json:"cluster_name,omitempty"`
|
||||
ClusterID string `json:"cluster_id,omitempty"`
|
||||
@@ -4368,7 +4368,7 @@ func (core *Core) GetSealStatus(ctx context.Context, lock bool) (*CoreSealStatus
|
||||
},
|
||||
StorageType: core.StorageType(),
|
||||
Version: version.GetVersion().VersionNumber(),
|
||||
BuildDate: version.BuildDate,
|
||||
CommitDate: version.CommitDate,
|
||||
}
|
||||
|
||||
if sealConfig == nil {
|
||||
@@ -4547,7 +4547,7 @@ func (b *SystemBackend) handleVersionHistoryList(ctx context.Context, req *logic
|
||||
|
||||
entry := map[string]interface{}{
|
||||
"timestamp_installed": v.TimestampInstalled.Format(time.RFC3339),
|
||||
"build_date": v.BuildDate,
|
||||
"commit_date": v.CommitDate,
|
||||
"previous_version": nil,
|
||||
}
|
||||
|
||||
|
||||
@@ -1218,7 +1218,7 @@ func (b *SystemBackend) rekeyPaths() []*framework.Path {
|
||||
Type: framework.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"build_date": {
|
||||
"commit_date": {
|
||||
Type: framework.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
@@ -1366,7 +1366,7 @@ func (b *SystemBackend) statusPaths() []*framework.Path {
|
||||
Type: framework.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"build_date": {
|
||||
"commit_date": {
|
||||
Type: framework.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
|
||||
@@ -24,10 +24,10 @@ const (
|
||||
type VaultVersion struct {
|
||||
TimestampInstalled time.Time
|
||||
Version string
|
||||
BuildDate string
|
||||
CommitDate string `json:"BuildDate"` // Pinned to BuildDate to remain backwards-compatible
|
||||
}
|
||||
|
||||
// storeVersionEntry will store the version, timestamp, and build date to storage
|
||||
// storeVersionEntry will store the version, timestamp, and commit date to storage
|
||||
// only if no entry for that version already exists in storage. Version
|
||||
// timestamps were initially stored in local time. UTC should be used. Existing
|
||||
// entries can be overwritten via the force flag. A bool will be returned
|
||||
|
||||
+8
-8
@@ -9,11 +9,11 @@ import (
|
||||
)
|
||||
|
||||
type VersionInfo struct {
|
||||
Revision string `json:"revision,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
VersionPrerelease string `json:"version_prerelease,omitempty"`
|
||||
VersionMetadata string `json:"version_metadata,omitempty"`
|
||||
BuildDate string `json:"build_date,omitempty"`
|
||||
Revision string
|
||||
Version string
|
||||
VersionPrerelease string
|
||||
VersionMetadata string
|
||||
CommitDate string
|
||||
}
|
||||
|
||||
func GetVersion() *VersionInfo {
|
||||
@@ -32,7 +32,7 @@ func GetVersion() *VersionInfo {
|
||||
Version: ver,
|
||||
VersionPrerelease: rel,
|
||||
VersionMetadata: md,
|
||||
BuildDate: BuildDate,
|
||||
CommitDate: CommitDate,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ func (c *VersionInfo) FullVersionNumber(rev bool) string {
|
||||
fmt.Fprintf(&versionString, " (%s)", c.Revision)
|
||||
}
|
||||
|
||||
if c.BuildDate != "" {
|
||||
fmt.Fprintf(&versionString, ", built %s", c.BuildDate)
|
||||
if c.CommitDate != "" {
|
||||
fmt.Fprintf(&versionString, ", committed %s", c.CommitDate)
|
||||
}
|
||||
|
||||
return versionString.String()
|
||||
|
||||
+10
-1
@@ -12,7 +12,10 @@ var (
|
||||
GitCommit string
|
||||
GitDescribe string
|
||||
|
||||
// The compilation date. This will be filled in by the compiler.
|
||||
// The date of the commit. This will be filled in by the compiler.
|
||||
CommitDate string
|
||||
|
||||
// Deprecated, backwards-compatibility only: Replaced by CommitDate
|
||||
BuildDate string
|
||||
|
||||
// Whether cgo is enabled or not; set at build time
|
||||
@@ -23,3 +26,9 @@ var (
|
||||
Version, VersionPrerelease, _ = strings.Cut(strings.TrimSpace(fullVersion), "-")
|
||||
VersionMetadata = ""
|
||||
)
|
||||
|
||||
func init() {
|
||||
if CommitDate == "" {
|
||||
CommitDate = BuildDate
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ The "t" parameter is the threshold, and "n" is the number of shares.
|
||||
"progress": 2,
|
||||
"nonce": "",
|
||||
"version": "1.11.0",
|
||||
"build_date": "2022-05-03T08:34:11Z",
|
||||
"commit_date": "2022-05-03T08:34:11Z",
|
||||
"migration": false,
|
||||
"recovery_seal": false,
|
||||
"storage_type": "file"
|
||||
@@ -55,7 +55,7 @@ Sample response when OpenBao is unsealed.
|
||||
"progress": 0,
|
||||
"nonce": "",
|
||||
"version": "1.11.0",
|
||||
"build_date": "2022-05-03T08:34:11Z",
|
||||
"commit_date": "2022-05-03T08:34:11Z",
|
||||
"migration": false,
|
||||
"cluster_name": "openbao-cluster-336172e1",
|
||||
"cluster_id": "f94053ad-d80e-4270-2006-2efd67d0910a",
|
||||
|
||||
@@ -12,7 +12,7 @@ This endpoint returns the version history of the OpenBao. The response will cont
|
||||
|
||||
- `keys`: a list of installed versions in chronological order based on the time installed
|
||||
- `key_info`: a map indexed by the versions found in the `keys` list containing the following subkeys:
|
||||
- `build_date`: the time (in UTC) at which the OpenBao binary used to run the OpenBao server was built.
|
||||
- `commit_date`: the time (in UTC) of the commit which the OpenBao binary used to run the OpenBao server was built at
|
||||
- `previous_version`: the version installed prior to this version or `null` if no prior version exists
|
||||
- `timestamp_installed`: the time (in UTC) at which the version was installed
|
||||
|
||||
@@ -35,22 +35,22 @@ $ curl \
|
||||
"keys": ["1.9.0", "1.9.1", "1.9.2", "1.11.0"],
|
||||
"key_info": {
|
||||
"1.9.0": {
|
||||
"build_date": null,
|
||||
"commit_date": null,
|
||||
"previous_version": null,
|
||||
"timestamp_installed": "2021-11-18T10:23:16Z"
|
||||
},
|
||||
"1.9.1": {
|
||||
"build_date": null,
|
||||
"commit_date": null,
|
||||
"previous_version": "1.9.0",
|
||||
"timestamp_installed": "2021-12-13T11:09:52Z"
|
||||
},
|
||||
"1.9.2": {
|
||||
"build_date": null,
|
||||
"commit_date": null,
|
||||
"previous_version": "1.9.1",
|
||||
"timestamp_installed": "2021-12-23T10:56:37Z"
|
||||
},
|
||||
"1.11.0": {
|
||||
"build_date": "2022-05-03T08:34:11Z",
|
||||
"commit_date": "2022-05-03T08:34:11Z",
|
||||
"previous_version": null,
|
||||
"timestamp_installed": "2022-05-03T13:16:04Z"
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ Key Threshold: 3
|
||||
Unseal Progress: 0
|
||||
Unseal Nonce:
|
||||
Version: x.y.z
|
||||
Build Date: 2022-05-03T08:34:11Z
|
||||
Commit Date: 2022-05-03T08:34:11Z
|
||||
Cluster Name: openbao-cluster-49ffd45f
|
||||
Cluster ID: d2dad792-fb99-1c8d-452e-528d073ba205
|
||||
|
||||
|
||||
@@ -7,11 +7,15 @@ description: |-
|
||||
|
||||
The `version-history` command prints the historical list of installed OpenBao versions in chronological order.
|
||||
|
||||
:::note
|
||||
Versions prior to 2.6 used "Build Date" instead of "Commit Date".
|
||||
:::
|
||||
|
||||
```shell-session
|
||||
Note: Version tracking was added in 1.9.0. Earlier versions have not been tracked.
|
||||
The Build Date will only be available for versions 1.11.0 or greater.
|
||||
The Commit Date will only be available for versions 1.11.0 or greater.
|
||||
|
||||
Version Installation Time Build Date
|
||||
Version Installation Time Commit Date
|
||||
------- ----------------- ----------
|
||||
1.9.0 2021-11-18T10:23:16Z
|
||||
1.9.1 2022-12-13T11:09:52Z
|
||||
|
||||
@@ -73,7 +73,7 @@ definitions](https://pkg.go.dev/cmd/link) as appropriate:
|
||||
| :-------- | :---- |
|
||||
| `github.com/openbao/openbao/version.fullVersion` | Version number of OpenBao; typically this matches the upstream version. Must be semver (`<major>.<minor>.<patch>`). Required. |
|
||||
| `github.com/openbao/openbao/version.GitCommit` | Git commit for reference; string. Required. |
|
||||
| `github.com/openbao/openbao/version.BuildDate` | Build timestamp string in the format `%Y-%m-%dT%H:%M:%SZ` (UTC). Usually this is the date of the commit. Required. |
|
||||
| `github.com/openbao/openbao/version.CommitDate` | Date of the commit in the format `%Y-%m-%dT%H:%M:%SZ` (UTC). Not the date of the build to preserve reproducibility. Required. |
|
||||
| `github.com/openbao/openbao/version.VersionMetadata` | Custom version information; string. Optional. |
|
||||
|
||||
### Known tags
|
||||
@@ -115,7 +115,7 @@ For instance, our upstream release invokes Go as follows:
|
||||
|
||||
```
|
||||
CGO_ENABLED=0 go build \
|
||||
-ldflags "-X github.com/openbao/openbao/version.fullVersion=v2.1.0 -X github.com/openbao/openbao/version.GitCommit=93609bf0c73a18dd81ac8c7d21b95cbde1e4887c -X github.com/openbao/openbao/version.BuildDate=2024-11-29T15:34:50Z"
|
||||
-ldflags "-X github.com/openbao/openbao/version.fullVersion=v2.1.0 -X github.com/openbao/openbao/version.GitCommit=93609bf0c73a18dd81ac8c7d21b95cbde1e4887c -X github.com/openbao/openbao/version.CommitDate=2024-11-29T15:34:50Z"
|
||||
.
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user