cloudflare/cloudflared
Publicmirrored from https://github.com/cloudflare/cloudflaredAvailable
cmd/cloudflared/buildinfo/build_info.go
33lines · modecode
| 1 | package buildinfo |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "runtime" |
| 6 | |
| 7 | "github.com/rs/zerolog" |
| 8 | ) |
| 9 | |
| 10 | type BuildInfo struct { |
| 11 | GoOS string `json:"go_os"` |
| 12 | GoVersion string `json:"go_version"` |
| 13 | GoArch string `json:"go_arch"` |
| 14 | CloudflaredVersion string `json:"cloudflared_version"` |
| 15 | } |
| 16 | |
| 17 | func GetBuildInfo(cloudflaredVersion string) *BuildInfo { |
| 18 | return &BuildInfo{ |
| 19 | GoOS: runtime.GOOS, |
| 20 | GoVersion: runtime.Version(), |
| 21 | GoArch: runtime.GOARCH, |
| 22 | CloudflaredVersion: cloudflaredVersion, |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | func (bi *BuildInfo) Log(log *zerolog.Logger) { |
| 27 | log.Info().Msgf("Version %s", bi.CloudflaredVersion) |
| 28 | log.Info().Msgf("GOOS: %s, GOVersion: %s, GoArch: %s", bi.GoOS, bi.GoVersion, bi.GoArch) |
| 29 | } |
| 30 | |
| 31 | func (bi *BuildInfo) OSArch() string { |
| 32 | return fmt.Sprintf("%s_%s", bi.GoOS, bi.GoArch) |
| 33 | } |
| 34 | |