Alert transport cleanup, no_proxy support and other proxy cleanups (#14763)

* Add no_proxy and other proxy related settings
Set user agent on all http client requests
Unify http client usage

* Style fixes

* Remove useless use statements

* Correct variable, good job phpstan

* Add tests
fix https_proxy bug
add tcp:// to the config settings format

* style and lint fixes

* Remove guzzle from the direct dependencies

* Use built in Laravel testing functionality

* update baseline
This commit is contained in:
Tony Murray
2023-05-23 09:25:17 -05:00
committed by GitHub
parent 02896172bd
commit 04bb75f5f3
78 changed files with 1545 additions and 2314 deletions

View File

@@ -27,7 +27,6 @@
namespace LibreNMS\Util;
use Exception;
use Illuminate\Support\Facades\Http;
class GitHub
{
@@ -112,7 +111,7 @@ class GitHub
*/
public function getRelease($tag)
{
$release = Http::withHeaders($this->getHeaders())->get($this->github . "/releases/tags/$tag");
$release = Http::client()->withHeaders($this->getHeaders())->get($this->github . "/releases/tags/$tag");
return $release->json();
}
@@ -122,7 +121,7 @@ class GitHub
*/
public function getPullRequest()
{
$pull_request = Http::withHeaders($this->getHeaders())->get($this->github . "/pulls/{$this->pr}");
$pull_request = Http::client()->withHeaders($this->getHeaders())->get($this->github . "/pulls/{$this->pr}");
$this->pr = $pull_request->json();
}
@@ -180,7 +179,7 @@ class GitHub
}
GRAPHQL;
$prs = Http::withHeaders($this->getHeaders())->post($this->graphql, ['query' => $query]);
$prs = Http::client()->withHeaders($this->getHeaders())->post($this->graphql, ['query' => $query]);
$prs = $prs->json();
if (! isset($prs['data'])) {
var_dump($prs);
@@ -366,7 +365,7 @@ GRAPHQL;
$this->createChangelog(false);
}
$release = Http::withHeaders($this->getHeaders())->post($this->github . '/releases', [
$release = Http::client()->withHeaders($this->getHeaders())->post($this->github . '/releases', [
'tag_name' => $this->tag,
'target_commitish' => $updated_sha,
'body' => $this->markdown,
@@ -422,10 +421,10 @@ GRAPHQL;
*/
private function pushFileContents($file, $contents, $message): string
{
$existing = Http::withHeaders($this->getHeaders())->get($this->github . '/contents/' . $file);
$existing = Http::client()->withHeaders($this->getHeaders())->get($this->github . '/contents/' . $file);
$existing_sha = $existing->json()['sha'];
$updated = Http::withHeaders($this->getHeaders())->put($this->github . '/contents/' . $file, [
$updated = Http::client()->withHeaders($this->getHeaders())->put($this->github . '/contents/' . $file, [
'message' => $message,
'content' => base64_encode($contents),
'sha' => $existing_sha,