Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace curl with Mojo::UserAgent #11689

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/maintenance_smelt.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use strict;
use warnings;
use testapi;
use List::Util qw(first);
use Mojo::UserAgent;

use base "Exporter";
use Exporter;
Expand All @@ -22,10 +23,7 @@ our @EXPORT = qw(query_smelt get_incident_packages get_packagebins_in_modules re

sub query_smelt {
my $graphql = $_[0];
my $api_url = "--request POST https://smelt.suse.de/graphql/";
my $header = '--header "Content-Type: application/json"';
my $data = qq( --data '{"query": "$graphql"}');
return qx(curl $api_url $header $data 2>/dev/null );
return Mojo::UserAgent->new->post("https://smelt.suse.de/graphql/" => json => {query => "$graphql"})->result->body;
}

sub get_incident_packages {
Expand All @@ -43,7 +41,7 @@ sub get_packagebins_in_modules {
# in different modules.
my ($self) = @_;
my ($package_name, $module_ref) = ($self->{package_name}, $self->{modules});
my $response = qx(curl "https://smelt.suse.de/api/v1/basic/maintained/$package_name/" 2>/dev/null);
my $response = Mojo::UserAgent->new->get("https://smelt.suse.de/api/v1/basic/maintained/$package_name/")->result->body;
my $graph = JSON->new->utf8->decode($response);
# Get the modules to which this package provides binaries.
my @existing_modules = grep { exists($graph->{$_}) } @{$module_ref};
Expand Down