@@ -10,6 +10,7 @@ import (
1010 "net/http"
1111 "os"
1212 "path/filepath"
13+ "rules-cli/internal/utils"
1314 "strings"
1415)
1516
@@ -68,6 +69,8 @@ func (c *Client) GetRule(name, version string) (*RuleInfo, error) {
6869 req .Header .Set ("Authorization" , fmt .Sprintf ("Bearer %s" , c .AuthToken ))
6970 }
7071
72+ utils .SetUserAgent (req )
73+
7174 client := & http.Client {}
7275 resp , err := client .Do (req )
7376 if err != nil {
@@ -110,6 +113,8 @@ func (c *Client) DownloadRule(name, version, formatDir string) error {
110113 req .Header .Set ("Authorization" , fmt .Sprintf ("Bearer %s" , c .AuthToken ))
111114 }
112115
116+ utils .SetUserAgent (req )
117+
113118 client := & http.Client {}
114119 resp , err := client .Do (req )
115120 if err != nil {
@@ -167,6 +172,8 @@ func (c *Client) PublishRule(ownerSlug, ruleSlug, content string, visibility str
167172 req .Header .Set ("Content-Type" , "application/json" )
168173 req .Header .Set ("Authorization" , fmt .Sprintf ("Bearer %s" , c .AuthToken ))
169174
175+ utils .SetUserAgent (req )
176+
170177 client := & http.Client {}
171178 resp , err := client .Do (req )
172179 if err != nil {
@@ -193,6 +200,7 @@ func (c *Client) downloadFromGitHub(repoPath string, formatDir string) error {
193200 return fmt .Errorf ("failed to create request: %w" , err )
194201 }
195202 req .Header .Set ("Accept" , "application/vnd.github.v3+json" )
203+ utils .SetUserAgent (req )
196204
197205 // Send request
198206 client := & http.Client {}
@@ -303,4 +311,4 @@ func (c *Client) downloadFromGitHub(repoPath string, formatDir string) error {
303311 }
304312
305313 return nil
306- }
314+ }
0 commit comments