From 68588cc5bfac25fbc7ef81459a18dfb90d110336 Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 24 Jan 2024 15:56:43 +0100 Subject: [PATCH] chore: fix tesla command build --- .goreleaser-nightly.yml | 2 +- .goreleaser.yml | 2 +- Dockerfile | 6 +++--- Makefile | 2 +- vehicle/tesla-vehicle-command/identity.go | 11 +++++++++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.goreleaser-nightly.yml b/.goreleaser-nightly.yml index bebf076092..2b9673511a 100644 --- a/.goreleaser-nightly.yml +++ b/.goreleaser-nightly.yml @@ -9,7 +9,7 @@ builds: - -trimpath - -tags=release ldflags: - - -X github.com/evcc-io/evcc/server.Version={{ .Tag }} -X github.com/evcc-io/evcc/server.Commit={{ .ShortCommit }} -X github.com/evcc-io/evcc/vehicle/tesla-vehicle-command.OAuth2Config.ClientID={{ .Env.TESLA_CLIENT_ID }} -s -w + - -X github.com/evcc-io/evcc/server.Version={{ .Tag }} -X github.com/evcc-io/evcc/server.Commit={{ .ShortCommit }} -X github.com/evcc-io/evcc/vehicle/tesla-vehicle-command.TESLA_CLIENT_ID={{ .Env.TESLA_CLIENT_ID }} -s -w env: - CGO_ENABLED=0 goos: diff --git a/.goreleaser.yml b/.goreleaser.yml index 7e1a5d7f79..4316fecc06 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -11,7 +11,7 @@ builds: - -trimpath - -tags=release ldflags: - - -X github.com/evcc-io/evcc/server.Version={{ .Version }} -X github.com/evcc-io/evcc/vehicle/tesla-vehicle-command.OAuth2Config.ClientID={{ .Env.TESLA_CLIENT_ID }} -s -w + - -X github.com/evcc-io/evcc/server.Version={{ .Version }} -X github.com/evcc-io/evcc/vehicle/tesla-vehicle-command.TESLA_CLIENT_ID={{ .Env.TESLA_CLIENT_ID }} -s -w env: - CGO_ENABLED=0 goos: diff --git a/Dockerfile b/Dockerfile index f3a3b7a6d0..4d2f041ff6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,9 @@ RUN case "${TARGETVARIANT}" in \ "v7") export GOARM='7' ;; \ esac; +ARG TESLA_CLIENT_ID +ENV TESLA_CLIENT_ID=${TESLA_CLIENT_ID} + RUN RELEASE=${RELEASE} GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build @@ -77,9 +80,6 @@ COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=builder /build/evcc /usr/local/bin/evcc -ARG TESLA_CLIENT_ID -ENV TESLA_CLIENT_ID=${TESLA_CLIENT_ID} - COPY packaging/docker/bin/* /app/ # mDNS diff --git a/Makefile b/Makefile index f335452fed..f5a018ae01 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ VERSION := $(if $(TAG_NAME),$(TAG_NAME),$(SHA)) BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S') BUILD_TAGS := -tags=release TESLA_CLIENT_ID := ${TESLA_CLIENT_ID} -LD_FLAGS := -X github.com/evcc-io/evcc/server.Version=$(VERSION) -X github.com/evcc-io/evcc/server.Commit=$(COMMIT) -X github.com/evcc-io/evcc/vehicle/tesla-vehicle-command.OAuth2Config.ClientID=$(TESLA_CLIENT_ID) -s -w +LD_FLAGS := -X github.com/evcc-io/evcc/server.Version=$(VERSION) -X github.com/evcc-io/evcc/server.Commit=$(COMMIT) -X github.com/evcc-io/evcc/vehicle/tesla-vehicle-command.TESLA_CLIENT_ID=$(TESLA_CLIENT_ID) -s -w BUILD_ARGS := -trimpath -ldflags='$(LD_FLAGS)' # docker diff --git a/vehicle/tesla-vehicle-command/identity.go b/vehicle/tesla-vehicle-command/identity.go index 18c90212a1..f4bc9e4cb5 100644 --- a/vehicle/tesla-vehicle-command/identity.go +++ b/vehicle/tesla-vehicle-command/identity.go @@ -21,6 +21,17 @@ var OAuth2Config = &oauth2.Config{ const userAgent = "evcc/evcc-io" +var TESLA_CLIENT_ID, TESLA_CLIENT_SECRET string + +func init() { + if TESLA_CLIENT_ID != "" { + OAuth2Config.ClientID = TESLA_CLIENT_ID + } + if TESLA_CLIENT_SECRET != "" { + OAuth2Config.ClientSecret = TESLA_CLIENT_SECRET + } +} + type Identity struct { oauth2.TokenSource log *util.Logger