diff --git a/rest/version.go b/rest/version.go index 77bfd7d..dc8946c 100644 --- a/rest/version.go +++ b/rest/version.go @@ -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) @@ -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").