1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-26 02:30:49 +00:00

rft: Move build info to pkg

This commit is contained in:
Ming Deng 2020-09-08 21:54:35 +08:00
parent 7effdb0e7d
commit bd1cfefec7
7 changed files with 30 additions and 22 deletions

View File

@ -15,12 +15,14 @@
package adapter
import (
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/server/web"
)
const (
// VERSION represent beego web framework version.
VERSION = web.VERSION
VERSION = pkg.VERSION
// DEV is for develop
DEV = web.DEV

View File

@ -23,6 +23,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/infrastructure/logs"
"github.com/astaxie/beego/pkg/server/web"
)
@ -58,13 +59,13 @@ func registerBuildInfo() {
Help: "The building information",
ConstLabels: map[string]string{
"appname": web.BConfig.AppName,
"build_version": web.BuildVersion,
"build_revision": web.BuildGitRevision,
"build_status": web.BuildStatus,
"build_tag": web.BuildTag,
"build_time": strings.Replace(web.BuildTime, "--", " ", 1),
"go_version": web.GoVersion,
"git_branch": web.GitBranch,
"build_version": pkg.BuildVersion,
"build_revision": pkg.BuildGitRevision,
"build_status": pkg.BuildStatus,
"build_tag": pkg.BuildTag,
"build_time": strings.Replace(pkg.BuildTime, "--", " ", 1),
"go_version": pkg.GoVersion,
"git_branch": pkg.GitBranch,
"start_time": time.Now().Format("2006-01-02 15:04:05"),
},
}, []string{})

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package web
package pkg
var (
BuildVersion string
@ -25,3 +25,8 @@ var (
GitBranch string
)
const (
// VERSION represent beego web framework version.
VERSION = "1.12.2"
)

View File

@ -22,9 +22,6 @@ import (
)
const (
// VERSION represent beego web framework version.
VERSION = "1.12.2"
// DEV is for develop
DEV = "dev"
// PROD is for production

View File

@ -24,6 +24,7 @@ import (
"runtime"
"strings"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/infrastructure/config"
"github.com/astaxie/beego/pkg/infrastructure/logs"
"github.com/astaxie/beego/pkg/infrastructure/session"
@ -208,7 +209,7 @@ func newBConfig() *Config {
AppName: "beego",
RunMode: PROD,
RouterCaseSensitive: true,
ServerName: "beegoServer:" + VERSION,
ServerName: "beegoServer:" + pkg.VERSION,
RecoverPanic: true,
RecoverFunc: recoverPanic,
CopyRequestBody: false,

View File

@ -23,6 +23,7 @@ import (
"strconv"
"strings"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/infrastructure/utils"
"github.com/astaxie/beego/pkg/server/web/context"
@ -91,7 +92,7 @@ func showErr(err interface{}, ctx *context.Context, stack string) {
"RequestURL": ctx.Input.URI(),
"RemoteAddr": ctx.Input.IP(),
"Stack": stack,
"BeegoVersion": VERSION,
"BeegoVersion": pkg.VERSION,
"GoVersion": runtime.Version(),
}
t.Execute(ctx.ResponseWriter, data)
@ -378,7 +379,7 @@ func responseError(rw http.ResponseWriter, r *http.Request, errCode int, errCont
t, _ := template.New("beegoerrortemp").Parse(errtpl)
data := M{
"Title": http.StatusText(errCode),
"BeegoVersion": VERSION,
"BeegoVersion": pkg.VERSION,
"Content": template.HTML(errContent),
}
t.Execute(rw, data)

View File

@ -21,6 +21,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/server/web"
"github.com/astaxie/beego/pkg/server/web/context"
)
@ -63,13 +64,13 @@ func registerBuildInfo() {
Help: "The building information",
ConstLabels: map[string]string{
"appname": web.BConfig.AppName,
"build_version": web.BuildVersion,
"build_revision": web.BuildGitRevision,
"build_status": web.BuildStatus,
"build_tag": web.BuildTag,
"build_time": strings.Replace(web.BuildTime, "--", " ", 1),
"go_version": web.GoVersion,
"git_branch": web.GitBranch,
"build_version": pkg.BuildVersion,
"build_revision": pkg.BuildGitRevision,
"build_status": pkg.BuildStatus,
"build_tag": pkg.BuildTag,
"build_time": strings.Replace(pkg.BuildTime, "--", " ", 1),
"go_version": pkg.GoVersion,
"git_branch": pkg.GitBranch,
"start_time": time.Now().Format("2006-01-02 15:04:05"),
},
}, []string{})