Skip to content

Commit

Permalink
Allow providing a release version. (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 authored Jul 8, 2024
1 parent 0f0eca0 commit 74e4064
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions rest/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,31 @@ import (

// name this struct "version", so go-swagger will generate a type named "version"
type version struct {
Name string `json:"name"`
Version string `json:"version"`
BuildDate string `json:"builddate"`
Revision string `json:"revision"`
Gitsha1 string `json:"gitsha1"`
MinimumClientVersion string `json:"min_client_version"`
Name string `json:"name"`
Version string `json:"version"`
BuildDate string `json:"builddate"`
Revision string `json:"revision"`
Gitsha1 string `json:"gitsha1"`
MinimumClientVersion string `json:"min_client_version"`
ReleaseVersion *string `json:"release_version" optional:"true"`
}

type VersionOpts struct {
BasePath string
MinClientVersion string
ReleaseVersion *string
}

// NewVersion returns a webservice which returns version information. The given
// name should be a descriptive name of the module.
func NewVersion(name string, basePath string, minClientVersion string) *restful.WebService {
func NewVersion(name string, opts *VersionOpts) *restful.WebService {
if opts.BasePath == "" {
opts.BasePath = "/"
}

ws := new(restful.WebService)
ws.
Path(basePath + "v1/version").
Path(opts.BasePath + "v1/version").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)

Expand All @@ -36,8 +47,10 @@ func NewVersion(name string, basePath string, minClientVersion string) *restful.
Revision: v.Revision,
BuildDate: v.BuildDate,
Gitsha1: v.GitSHA1,
MinimumClientVersion: minClientVersion,
MinimumClientVersion: opts.MinClientVersion,
ReleaseVersion: opts.ReleaseVersion,
}

ws.Route(
ws.GET("/").
Doc("returns the current version information of this module").
Expand Down

0 comments on commit 74e4064

Please sign in to comment.