Skip to content

Commit

Permalink
Merge pull request #11689 from asdil12/curl
Browse files Browse the repository at this point in the history
Replace curl with Mojo::UserAgent
  • Loading branch information
asdil12 committed Jan 5, 2021
2 parents 094922f + 304b6fa commit e7710fc
Showing 1 changed file with 3 additions and 5 deletions.
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

0 comments on commit e7710fc

Please sign in to comment.