authelia/cmd/authelia-scripts/cmd_xflags.go
James Elliott 0d7b33022c
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.
2021-06-18 14:35:43 +10:00

40 lines
760 B
Go

package main
import (
"fmt"
"strings"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func init() {
xflagsCmd.Flags().StringP("build", "b", "0", "Sets the BuildNumber flag value")
xflagsCmd.Flags().StringP("extra", "e", "", "Sets the BuildExtra flag value")
}
var xflagsCmd = &cobra.Command{
Use: "xflags",
Run: runXFlags,
Short: "Generate X LDFlags for building Authelia",
}
func runXFlags(cobraCmd *cobra.Command, _ []string) {
build, err := cobraCmd.Flags().GetString("build")
if err != nil {
log.Fatal(err)
}
extra, err := cobraCmd.Flags().GetString("extra")
if err != nil {
log.Fatal(err)
}
flags, err := getXFlags("", build, extra)
if err != nil {
log.Fatal(err)
}
fmt.Println(strings.Join(flags, " "))
}