diff --git a/Makefile b/Makefile index b7e5f99..4e0b9e5 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ ifeq (${KERNEL},Linux) GOFLAGS ?= -buildmode=pie endif -GO_LDFLAGS += -w -s -X main.version=${VERSION} +GO_LDFLAGS += -w -s -X github.com/cloudflare/origin-ca-issuer/internal/version.Version=${VERSION} GOFLAGS += -v export CGO_ENABLED diff --git a/internal/cfapi/cfapi.go b/internal/cfapi/cfapi.go index d803613..7e15d9b 100644 --- a/internal/cfapi/cfapi.go +++ b/internal/cfapi/cfapi.go @@ -8,6 +8,8 @@ import ( "net/http" "net/url" "time" + + "github.com/cloudflare/origin-ca-issuer/internal/version" ) type Interface interface { @@ -121,7 +123,7 @@ func (c *Client) Sign(ctx context.Context, req *SignRequest) (*SignResponse, err return nil, err } - r.Header.Add("User-Agent", "github.com/cloudflare/origin-ca-issuer") + r.Header.Add("User-Agent", "origin-ca-issuer/"+version.Version) if c.serviceKey != nil { r.Header.Add("X-Auth-User-Service-Key", string(c.serviceKey)) diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 0000000..415100d --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,3 @@ +package version + +var Version = "0.0.0" diff --git a/pkgs/controllers/testdata/database-failure.yaml b/pkgs/controllers/testdata/database-failure.yaml index 3188476..29bf93a 100644 --- a/pkgs/controllers/testdata/database-failure.yaml +++ b/pkgs/controllers/testdata/database-failure.yaml @@ -16,7 +16,7 @@ interactions: form: {} headers: User-Agent: - - github.com/cloudflare/origin-ca-issuer + - origin-ca-issuer/0.0.0 X-Auth-User-Service-Key: - djEuMC0weDAwQkFCMTBD url: https://api.cloudflare.com/client/v4/certificates diff --git a/pkgs/controllers/testdata/working.yaml b/pkgs/controllers/testdata/working.yaml index 83dbd45..a19bfd3 100644 --- a/pkgs/controllers/testdata/working.yaml +++ b/pkgs/controllers/testdata/working.yaml @@ -16,7 +16,7 @@ interactions: form: {} headers: User-Agent: - - github.com/cloudflare/origin-ca-issuer + - origin-ca-issuer/0.0.0 X-Auth-User-Service-Key: - djEuMC0weDAwQkFCMTBD url: https://api.cloudflare.com/client/v4/certificates @@ -62,7 +62,7 @@ interactions: form: {} headers: User-Agent: - - github.com/cloudflare/origin-ca-issuer + - origin-ca-issuer/0.0.0 Authorization: - Bearer api-token url: https://api.cloudflare.com/client/v4/certificates