Skip to content

Commit 90f8114

Browse files
authored
Merge pull request #19 from Teifun2/18-unifi-bouncer-not-checked-in-console
[improvement] Add UserAgent for proper version management in Hubs
2 parents 92e85b7 + 121e984 commit 90f8114

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

.github/workflows/container-release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ jobs:
4747
KO_DOCKER_REPO: ghcr.io/teifun2
4848
TAGS: ${{ steps.meta.outputs.tags }}
4949
LABELS: ${{ steps.meta.outputs.labels }}
50+
VERSION: ${{ steps.meta.outputs.version }}
5051
PLATFORMS: linux/amd64,linux/arm64,linux/arm
5152
run: |
5253
PTAGS=`echo $TAGS | sed 's/cs-unifi-bouncer://g'`
5354
export SOURCE_DATE_EPOCH=$(date +%s)
55+
export GOFLAGS="-ldflags=-X=main.version=$VERSION"
5456
ko build -B --image-label "$LABELS" -t "$PTAGS" --platform=$PLATFORMS .

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ type unifiAddrList struct {
2828
modified bool
2929
}
3030

31+
// This variable is set by the build process with ldflags
32+
var version = "unknown"
33+
3134
func main() {
35+
log.Info().Msg("Starting cs-unifi-bouncer with version: " + version)
3236

3337
// zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
3438
initConfig()
@@ -38,6 +42,7 @@ func main() {
3842
APIUrl: crowdsecBouncerURL,
3943
TickerInterval: crowdsecUpdateInterval,
4044
Origins: crowdsecOrigins,
45+
UserAgent: fmt.Sprintf("cs-unifi-bouncer/%s", version),
4146
}
4247
if err := bouncer.Init(); err != nil {
4348
log.Fatal().Err(err).Msg("Bouncer init failed")

0 commit comments

Comments
 (0)