Use system info and build info as user agent, and expose DebugInfo (#41)
* Refactor setting and unsetting system info * detect version on init * Update client.go * Update client_test.go Co-authored-by: Copilot <[email protected]> * Update client.go Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
This commit is contained in:
@@ -59,12 +59,35 @@ func (c *Config) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// systemInfo serves as a base system info
|
||||
func systemInfo(scaleSetID int) scaleset.SystemInfo {
|
||||
return scaleset.SystemInfo{
|
||||
System: "dockerscaleset",
|
||||
Subsystem: "dockerscaleset",
|
||||
CommitSHA: "NA", // You can leverage build flags to set commit SHA
|
||||
Version: "0.1.0", // You can leverage build flags to set version
|
||||
ScaleSetID: scaleSetID,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) ScalesetClient() (*scaleset.Client, error) {
|
||||
if err := c.GitHubApp.Validate(); err == nil {
|
||||
return scaleset.NewClientWithGitHubApp(c.RegistrationURL, &c.GitHubApp)
|
||||
return scaleset.NewClientWithGitHubApp(
|
||||
scaleset.ClientWithGitHubAppConfig{
|
||||
GitHubConfigURL: c.RegistrationURL,
|
||||
GitHubAppAuth: c.GitHubApp,
|
||||
SystemInfo: systemInfo(0),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return scaleset.NewClientWithPersonalAccessToken(c.RegistrationURL, c.Token)
|
||||
return scaleset.NewClientWithPersonalAccessToken(
|
||||
scaleset.NewClientWithPersonalAccessTokenConfig{
|
||||
GitHubConfigURL: c.RegistrationURL,
|
||||
PersonalAccessToken: c.Token,
|
||||
SystemInfo: systemInfo(0),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func (c *Config) Logger() *slog.Logger {
|
||||
|
||||
@@ -92,13 +92,7 @@ func run(ctx context.Context, c Config) error {
|
||||
}
|
||||
|
||||
// Set the user agent for the scaleset client now that we have the scale set ID
|
||||
scalesetClient.SetUserAgent(scaleset.UserAgentInfo{
|
||||
System: "dockerscaleset",
|
||||
Version: "0.1.0",
|
||||
CommitSHA: "unknown",
|
||||
ScaleSetID: scaleSet.ID,
|
||||
Subsystem: scaleSet.Name,
|
||||
})
|
||||
scalesetClient.SetSystemInfo(systemInfo(scaleSet.ID))
|
||||
|
||||
defer func() {
|
||||
logger.Info(
|
||||
|
||||
Reference in New Issue
Block a user