summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2022-08-04 11:16:59 -0600
committerGitHub <noreply@github.com>2022-08-04 11:16:59 -0600
commit17ae5acaba536e98cfa86ddcd6967801f1fa1bbe (patch)
treefab5bd3d28ad46e14bb8916b95059de816db75ec /cmd
parent1960a0dc117dd30fb507b390ddf93b2ef371b9ad (diff)
cmd: Use newly-available version information (#4931)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/commandfuncs.go21
-rw-r--r--cmd/main.go26
2 files changed, 8 insertions, 39 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go
index a4b7bdf..67015f7 100644
--- a/cmd/commandfuncs.go
+++ b/cmd/commandfuncs.go
@@ -331,30 +331,17 @@ func cmdReload(fl Flags) (int, error) {
}
func cmdVersion(_ Flags) (int, error) {
- fmt.Println(CaddyVersion())
+ _, full := caddy.Version()
+ fmt.Println(full)
return caddy.ExitCodeSuccess, nil
}
-func cmdBuildInfo(fl Flags) (int, error) {
+func cmdBuildInfo(_ Flags) (int, error) {
bi, ok := debug.ReadBuildInfo()
if !ok {
return caddy.ExitCodeFailedStartup, fmt.Errorf("no build information")
}
-
- fmt.Printf("go_version: %s\n", runtime.Version())
- fmt.Printf("go_os: %s\n", runtime.GOOS)
- fmt.Printf("go_arch: %s\n", runtime.GOARCH)
- fmt.Printf("path: %s\n", bi.Path)
- fmt.Printf("main: %s %s %s\n", bi.Main.Path, bi.Main.Version, bi.Main.Sum)
- fmt.Println("dependencies:")
-
- for _, goMod := range bi.Deps {
- fmt.Printf("%s %s %s", goMod.Path, goMod.Version, goMod.Sum)
- if goMod.Replace != nil {
- fmt.Printf(" => %s %s %s", goMod.Replace.Path, goMod.Replace.Version, goMod.Replace.Sum)
- }
- fmt.Println()
- }
+ fmt.Println(bi)
return caddy.ExitCodeSuccess, nil
}
diff --git a/cmd/main.go b/cmd/main.go
index e5a4edf..e932b6b 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -38,8 +38,8 @@ import (
func init() {
// set a fitting User-Agent for ACME requests
- goModule := caddy.GoModule()
- cleanModVersion := strings.TrimPrefix(goModule.Version, "v")
+ version, _ := caddy.Version()
+ cleanModVersion := strings.TrimPrefix(version, "v")
certmagic.UserAgent = "Caddy/" + cleanModVersion
// by using Caddy, user indicates agreement to CA terms
@@ -441,11 +441,12 @@ func parseEnvFile(envInput io.Reader) (map[string]string, error) {
}
func printEnvironment() {
+ _, version := caddy.Version()
fmt.Printf("caddy.HomeDir=%s\n", caddy.HomeDir())
fmt.Printf("caddy.AppDataDir=%s\n", caddy.AppDataDir())
fmt.Printf("caddy.AppConfigDir=%s\n", caddy.AppConfigDir())
fmt.Printf("caddy.ConfigAutosavePath=%s\n", caddy.ConfigAutosavePath)
- fmt.Printf("caddy.Version=%s\n", CaddyVersion())
+ fmt.Printf("caddy.Version=%s\n", version)
fmt.Printf("runtime.GOOS=%s\n", runtime.GOOS)
fmt.Printf("runtime.GOARCH=%s\n", runtime.GOARCH)
fmt.Printf("runtime.Compiler=%s\n", runtime.Compiler)
@@ -462,25 +463,6 @@ func printEnvironment() {
}
}
-// CaddyVersion returns a detailed version string, if available.
-func CaddyVersion() string {
- goModule := caddy.GoModule()
- ver := goModule.Version
- if goModule.Sum != "" {
- ver += " " + goModule.Sum
- }
- if goModule.Replace != nil {
- ver += " => " + goModule.Replace.Path
- if goModule.Replace.Version != "" {
- ver += "@" + goModule.Replace.Version
- }
- if goModule.Replace.Sum != "" {
- ver += " " + goModule.Replace.Sum
- }
- }
- return ver
-}
-
// StringSlice is a flag.Value that enables repeated use of a string flag.
type StringSlice []string