-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement /api/v1/version for rekor-server (#569)
* rekor-server: Implement /api/v1/version This implements a version endpoint for rekor. This helps figure out the version the server is currently running. It could later be used to implement version compatibility with CLI utilities. Example: λ rekor main» curl -s localhost:3000/api/v1/version | jq { "builddate": "'2021-12-27T13:20:32Z'", "commit": "12d1a47c7ac986932a2734cb855c642ac01ffde4", "treestate": "dirty", "version": "v0.4.0-15-g12d1a47-dirty" } This removes some duplication of the build flags and inserts them into /pkg/api which is then reused across the utilities. Signed-off-by: Morten Linderud <[email protected]> Signed-off-by: Morten Linderud <[email protected]> * Generated files Signed-off-by: Morten Linderud <[email protected]>
- Loading branch information
Showing
19 changed files
with
1,079 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// Copyright 2021 The Sigstore Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package api | ||
|
||
import ( | ||
"github.com/go-openapi/runtime/middleware" | ||
"github.com/sigstore/rekor/pkg/generated/models" | ||
"github.com/sigstore/rekor/pkg/generated/restapi/operations/server" | ||
) | ||
|
||
// Base version information. | ||
// | ||
// This is the fallback data used when version information from git is not | ||
// provided via go ldflags (e.g. via Makefile). | ||
var ( | ||
// Output of "git describe". The prerequisite is that the branch should be | ||
// tagged using the correct versioning strategy. | ||
GitVersion string = "devel" | ||
// SHA1 from git, output of $(git rev-parse HEAD) | ||
GitCommit = "unknown" | ||
// State of git tree, either "clean" or "dirty" | ||
GitTreeState = "unknown" | ||
// Build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
BuildDate = "unknown" | ||
) | ||
|
||
func GetRekorVersionHandler(params server.GetRekorVersionParams) middleware.Responder { | ||
ver := &models.RekorVersion{ | ||
Version: &GitVersion, | ||
Commit: &GitCommit, | ||
Treestate: &GitTreeState, | ||
Builddate: &BuildDate, | ||
} | ||
return server.NewGetRekorVersionOK().WithPayload(ver) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.