outposts: send build hash as part of hello

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-12 19:02:04 +02:00
parent 37b57ac28f
commit 901cea1453
4 changed files with 22 additions and 9 deletions

View File

@ -1,7 +1,6 @@
package ak package ak
import ( import (
"fmt"
"math/rand" "math/rand"
"net/url" "net/url"
"os" "os"
@ -43,7 +42,7 @@ type APIController struct {
// NewAPIController initialise new API Controller instance from URL and API token // NewAPIController initialise new API Controller instance from URL and API token
func NewAPIController(akURL url.URL, token string) *APIController { func NewAPIController(akURL url.URL, token string) *APIController {
transport := httptransport.New(akURL.Host, client.DefaultBasePath, []string{akURL.Scheme}) transport := httptransport.New(akURL.Host, client.DefaultBasePath, []string{akURL.Scheme})
transport.Transport = SetUserAgent(getTLSTransport(), fmt.Sprintf("authentik-proxy@%s", pkg.VERSION)) transport.Transport = SetUserAgent(getTLSTransport(), pkg.UserAgent())
// create the transport // create the transport
auth := httptransport.BearerToken(token) auth := httptransport.BearerToken(token)

View File

@ -23,7 +23,7 @@ func (ac *APIController) initWS(akURL url.URL, outpostUUID strfmt.UUID) {
header := http.Header{ header := http.Header{
"Authorization": []string{authHeader}, "Authorization": []string{authHeader},
"User-Agent": []string{fmt.Sprintf("authentik-proxy@%s", pkg.VERSION)}, "User-Agent": []string{pkg.UserAgent()},
} }
value, set := os.LookupEnv("AUTHENTIK_INSECURE") value, set := os.LookupEnv("AUTHENTIK_INSECURE")
@ -46,8 +46,9 @@ func (ac *APIController) initWS(akURL url.URL, outpostUUID strfmt.UUID) {
msg := websocketMessage{ msg := websocketMessage{
Instruction: WebsocketInstructionHello, Instruction: WebsocketInstructionHello,
Args: map[string]interface{}{ Args: map[string]interface{}{
"version": pkg.VERSION, "version": pkg.VERSION,
"uuid": ac.instanceUUID.String(), "buildHash": pkg.BUILD(),
"uuid": ac.instanceUUID.String(),
}, },
} }
err := ws.WriteJSON(msg) err := ws.WriteJSON(msg)
@ -100,8 +101,9 @@ func (ac *APIController) startWSHealth() {
aliveMsg := websocketMessage{ aliveMsg := websocketMessage{
Instruction: WebsocketInstructionHello, Instruction: WebsocketInstructionHello,
Args: map[string]interface{}{ Args: map[string]interface{}{
"version": pkg.VERSION, "version": pkg.VERSION,
"uuid": ac.instanceUUID.String(), "buildHash": pkg.BUILD(),
"uuid": ac.instanceUUID.String(),
}, },
} }
err := ac.wsConn.WriteJSON(aliveMsg) err := ac.wsConn.WriteJSON(aliveMsg)

View File

@ -33,8 +33,7 @@ func doGlobalSetup(config map[string]interface{}) {
default: default:
log.SetLevel(log.DebugLevel) log.SetLevel(log.DebugLevel)
} }
buildHash := os.Getenv("GIT_BUILD_HASH") log.WithField("buildHash", pkg.BUILD()).WithField("version", pkg.VERSION).Info("Starting authentik outpost")
log.WithField("buildHash", buildHash).WithField("version", pkg.VERSION).Info("Starting authentik outpost")
var dsn string var dsn string
if config[ConfigErrorReportingEnabled].(bool) { if config[ConfigErrorReportingEnabled].(bool) {

View File

@ -1,3 +1,16 @@
package pkg package pkg
import (
"fmt"
"os"
)
const VERSION = "2021.5.1-rc7" const VERSION = "2021.5.1-rc7"
func BUILD() string {
return os.Getenv("GIT_BUILD_HASH")
}
func UserAgent() string {
return fmt.Sprintf("authentik-outpost@%s (%s)", VERSION, BUILD())
}