Added access token to collect header if supplied

This commit is contained in:
David J. Allen 2024-03-15 17:43:53 -06:00
parent 09c5af44b9
commit be1d473950
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC

View file

@ -50,6 +50,7 @@ type QueryParams struct {
IpmitoolPath string
OutputPath string
ForceUpdate bool
AccessToken string
}
func NewClient(l *log.Logger, q *QueryParams) (*bmclib.Client, error) {
@ -209,6 +210,11 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
headers := make(map[string]string)
headers["Content-Type"] = "application/json"
// use access token in authorization header if we have it
if q.AccessToken != "" {
headers["Authorization"] = "Bearer " + q.AccessToken
}
body, err := json.MarshalIndent(data, "", " ")
if err != nil {
l.Log.Errorf("could not marshal JSON: %v", err)