fix: #45 Add HTTP proxy support

Signed-off-by: Devin <hoopysoup@users.noreply.github.com>
This commit is contained in:
Devin 2025-09-21 08:50:10 -07:00 committed by GitHub
parent 9cc1438d52
commit 2bc068a74a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,21 +28,26 @@ class Release {
* @return {Array<Release>} Releases.
*/
async function fetchReleases (githubToken) {
const hc = require('@actions/http-client');
const userAgent = 'opentofu/setup-opentofu';
const http = new hc.HttpClient(userAgent);
const url = 'https://get.opentofu.org/tofu/api.json';
const headers = {
Accept: 'application/json'
};
const resp = await fetch(url, {
headers
});
const resp = await http.get(url, headers);
if (!resp.ok) {
throw new Error('failed fetching releases (' + resp.status + ')');
if (resp.message.statusCode !== 200) {
throw new Error('failed fetching releases (' + resp.message.statusCode + ')');
}
body = await resp.readBody();
const releasesMeta = JSON.parse(body);
const releasesMeta = await resp.json();
/**
* @type {Array}
*/