mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2025-12-31 15:02:19 +00:00
fix: #45 Add HTTP proxy support
Signed-off-by: Devin <hoopysoup@users.noreply.github.com>
This commit is contained in:
parent
9cc1438d52
commit
2bc068a74a
1 changed files with 11 additions and 6 deletions
|
|
@ -28,21 +28,26 @@ class Release {
|
||||||
* @return {Array<Release>} Releases.
|
* @return {Array<Release>} Releases.
|
||||||
*/
|
*/
|
||||||
async function fetchReleases (githubToken) {
|
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 url = 'https://get.opentofu.org/tofu/api.json';
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
Accept: 'application/json'
|
Accept: 'application/json'
|
||||||
};
|
};
|
||||||
|
|
||||||
const resp = await fetch(url, {
|
const resp = await http.get(url, headers);
|
||||||
headers
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!resp.ok) {
|
if (resp.message.statusCode !== 200) {
|
||||||
throw new Error('failed fetching releases (' + resp.status + ')');
|
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}
|
* @type {Array}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue