| 145 | } |
| 146 | |
| 147 | func (p *githubPlugin) request(contentURL string) (*http.Request, error) { |
| 148 | req, err := http.NewRequest(http.MethodGet, contentURL, nil) |
| 149 | if err != nil { |
| 150 | return nil, err |
| 151 | } |
| 152 | |
| 153 | // Add github token to request if available |
| 154 | ghToken := os.Getenv("GITHUB_TOKEN") |
| 155 | |
| 156 | if ghToken != "" { |
| 157 | authValue := fmt.Sprintf("token %s", ghToken) |
| 158 | req.Header.Add("Authorization", authValue) |
| 159 | slog.Debug( |
| 160 | "GITHUB_TOKEN env var found, adding to request's auth header", |
| 161 | "headerValue", |
| 162 | getRedactedAuthHeader(req), |
| 163 | ) |
| 164 | } |
| 165 | |
| 166 | return req, nil |
| 167 | } |
| 168 | |
| 169 | func (p *githubPlugin) LockfileKey() string { |
| 170 | return p.ref.String() |