diff options
| author | James Elliott <james-d-elliott@users.noreply.github.com> | 2021-06-18 14:35:43 +1000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-18 14:35:43 +1000 | 
| commit | 0d7b33022c659444617d15c95c3cbfc66561689b (patch) | |
| tree | e06f6f06260136d18301df2bfa17b47945a5ef88 /cmd/authelia | |
| parent | ef3c2faeb5a8d4ae30fa55fdaed5718e32f11364 (diff) | |
build: add enhanced information (#2067)
This commit adjusts the build flags to include version information in the LDFLAGS using the -X options. Additionally this makes the information recorded at build time more comprehensive. All build information can now be obtained via the `authelia build` command, and the `authelia version` command is now `authelia --version`. Lastly this adjusts the Dockerfile to utilize docker cache more effectively.
Diffstat (limited to 'cmd/authelia')
| -rw-r--r-- | cmd/authelia/const.go | 21 | ||||
| -rw-r--r-- | cmd/authelia/constants.go | 7 | ||||
| -rw-r--r-- | cmd/authelia/main.go | 20 | 
3 files changed, 36 insertions, 12 deletions
diff --git a/cmd/authelia/const.go b/cmd/authelia/const.go new file mode 100644 index 000000000..296025de8 --- /dev/null +++ b/cmd/authelia/const.go @@ -0,0 +1,21 @@ +package main + +const fmtAutheliaLong = `authelia %s + +An open-source authentication and authorization server providing  +two-factor authentication and single sign-on (SSO) for your  +applications via a web portal. + +Documentation is available at: https://www.authelia.com/docs +` + +const fmtAutheliaBuild = `Last Tag: %s +State: %s +Branch: %s +Commit: %s +Build Number: %s +Build OS: %s +Build Arch: %s +Build Date: %s +Extra: %s +` diff --git a/cmd/authelia/constants.go b/cmd/authelia/constants.go deleted file mode 100644 index 14f2cf13a..000000000 --- a/cmd/authelia/constants.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -// BuildTag tag used to bootstrap Authelia binary. -var BuildTag = "__BUILD_TAG__" - -// BuildCommit commit used to bootstrap Authelia binary. -var BuildCommit = "__BUILD_COMMIT__" diff --git a/cmd/authelia/main.go b/cmd/authelia/main.go index d51b5e990..05af593e9 100644 --- a/cmd/authelia/main.go +++ b/cmd/authelia/main.go @@ -3,6 +3,7 @@ package main  import (  	"fmt"  	"os" +	"runtime"  	"github.com/sirupsen/logrus"  	"github.com/spf13/cobra" @@ -56,6 +57,8 @@ func startServer() {  		logger.Fatalf("Cannot initialize logger: %v", err)  	} +	logger.Infof("Authelia %s is starting", utils.Version()) +  	switch config.Logging.Level {  	case "error":  		logger.Info("Logging severity set to error") @@ -145,24 +148,31 @@ func startServer() {  func main() {  	logger := logging.Logger() + +	version := utils.Version() +  	rootCmd := &cobra.Command{  		Use: "authelia",  		Run: func(cmd *cobra.Command, args []string) {  			startServer()  		}, +		Version: version, +		Short:   fmt.Sprintf("authelia %s", version), +		Long:    fmt.Sprintf(fmtAutheliaLong, version),  	}  	rootCmd.Flags().StringVar(&configPathFlag, "config", "", "Configuration file") -	versionCmd := &cobra.Command{ -		Use:   "version", -		Short: "Show the version of Authelia", +	buildCmd := &cobra.Command{ +		Use:   "build", +		Short: "Show the build of Authelia",  		Run: func(cmd *cobra.Command, args []string) { -			fmt.Printf("Authelia version %s, build %s\n", BuildTag, BuildCommit) +			fmt.Printf(fmtAutheliaBuild, utils.BuildTag, utils.BuildState, utils.BuildBranch, utils.BuildCommit, +				utils.BuildNumber, runtime.GOOS, runtime.GOARCH, utils.BuildDate, utils.BuildExtra)  		},  	} -	rootCmd.AddCommand(versionCmd, commands.HashPasswordCmd, +	rootCmd.AddCommand(buildCmd, commands.HashPasswordCmd,  		commands.ValidateConfigCmd, commands.CertificatesCmd,  		commands.RSACmd)  | 
