Added more version info

This commit is contained in:
Marc Ole Bulling
2022-03-16 12:06:22 +01:00
parent 7f9037ff1f
commit 9e7fa0fa33

View File

@@ -72,6 +72,7 @@ func shutdown() {
func showVersion(passedFlags flags) {
if passedFlags.showVersion {
fmt.Println("Gokapi v" + Version)
fmt.Println()
fmt.Println("Builder: " + environment.Builder)
fmt.Println("Build Date: " + environment.BuildTime)
fmt.Println("Docker Version: " + environment.IsDocker)
@@ -81,10 +82,40 @@ func showVersion(passedFlags flags) {
} else {
fmt.Println("Go Version: unknown")
}
parseBuildSettings(info.Settings)
osExit(0)
}
}
func parseBuildSettings(infos []debug.BuildSetting) {
lookups := make(map[string]string)
lookups["-tags"] = "Build Tags"
lookups["vcs.revision"] = "Git Commit"
lookups["vcs.time"] = "Git Commit Timestamp"
lookups["GOARCH"] = "Architecture"
lookups["GOOS"] = "Operating System"
for key, value := range lookups {
result := "Not found"
for _, buildSetting := range infos {
if buildSetting.Key == key {
result = buildSetting.Value
break
}
}
fmt.Println(value + ": " + result)
}
for _, info := range infos {
if info.Key == "vcs.modified" {
if info.Value == "true" {
fmt.Println("Code has been modified after last git commit")
}
break
}
}
}
func initCloudConfig() {
cConfig, ok := cloudconfig.Load()
if ok && aws.Init(cConfig.Aws) {