fix: set the client user agent

The code already existed for setting the UserAgent header, but a value
was never passed to the client. This change will now set a string
matching the following format

```
faas-cli/<build version>
```

For example:

```
faas-cli/0.14.6-5-ga9c2b10f
```

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
This commit is contained in:
Lucas Roesler
2022-10-24 20:12:08 +02:00
committed by Alex Ellis
parent 81ea36ae7d
commit 29953f1836
2 changed files with 9 additions and 8 deletions

View File

@@ -11,6 +11,8 @@ import (
gopath "path"
"strings"
"time"
"github.com/openfaas/faas-cli/version"
)
// Client an API client to perform all operations
@@ -51,6 +53,7 @@ func NewClient(auth ClientAuth, gatewayURL string, transport http.RoundTripper,
ClientAuth: auth,
httpClient: client,
GatewayURL: baseURL,
UserAgent: fmt.Sprintf("faas-cli/%s", version.BuildVersion()),
}, nil
}

View File

@@ -1,7 +1,5 @@
package version
const UserAgent = "OpenFaaS CLI"
var (
Version, GitCommit string
)