2 Commits

Author SHA1 Message Date
Francesco Renzi 33cbb7a1d9 log 2026-02-02 12:07:47 +01:00
Francesco Renzi 9cd2ceb86b static user agent 2026-02-02 11:00:34 +01:00
4 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright GitHub, Inc.
Copyright (c) 2025 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+5 -3
View File
@@ -7,6 +7,7 @@ import (
"encoding/json"
"fmt"
"io"
"log/slog"
"maps"
"net/http"
"net/url"
@@ -126,9 +127,9 @@ type ProxyFunc func(req *http.Request) (*url.URL, error)
type SystemInfo struct {
// System is the name of the scale set implementation
System string `json:"system"`
// Version is the version of the client
// Version is the version of the controller
Version string `json:"version"`
// CommitSHA is the git commit SHA of the client
// CommitSHA is the git commit SHA of the controller
CommitSHA string `json:"commit_sha"`
// ScaleSetID is the ID of the scale set
ScaleSetID int `json:"scale_set_id"`
@@ -222,7 +223,6 @@ type userAgent struct {
SystemInfo
BuildVersion string `json:"build_version"`
BuildCommitSHA string `json:"build_commit_sha"`
Kind string `json:"kind"`
}
func (c *Client) newGitHubAPIRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error) {
@@ -836,6 +836,8 @@ func (c *Client) getActionsServiceAdminConnection(ctx context.Context, rt *regis
return nil, fmt.Errorf("failed to get actions service admin connection: %w", err)
}
slog.Info("got connection", *adminConnection.ActionsServiceURL, c.userAgent)
return adminConnection, nil
}
+1 -1
View File
@@ -137,9 +137,9 @@ func (c *commonClient) setUserAgent() {
SystemInfo: c.systemInfo,
BuildVersion: buildInfo.version,
BuildCommitSHA: buildInfo.commitSHA,
Kind: "scaleset",
})
c.userAgent = string(b)
slog.Info("user agent", "useragent", c.userAgent)
}
// HTTPOption defines a functional option for configuring the Client.
-2
View File
@@ -124,7 +124,6 @@ func TestUserAgent(t *testing.T) {
SystemInfo: testSystemInfo,
BuildCommitSHA: sha,
BuildVersion: version,
Kind: "scaleset",
}
b, err := json.Marshal(wantInfo)
require.NoError(t, err, "failed to marshal expected user agent")
@@ -145,7 +144,6 @@ func TestUserAgent(t *testing.T) {
SystemInfo: userAgentInfo,
BuildCommitSHA: sha,
BuildVersion: version,
Kind: "scaleset",
}
b, err = json.Marshal(wantInfo)
require.NoError(t, err, "failed to marshal expected user agent after SetSystemInfo")