Introduce buildinfo.pm, update sample config update TODO
+ Add buildinfo.pm - api for slackbuild env metadata * Update .psgi files * update sample config * update TODO - remove checked-in milestones
This commit is contained in:
4
TODO
4
TODO
@@ -5,12 +5,10 @@
|
||||
* paste/link shortener
|
||||
* shortener api for goo.gl or same services
|
||||
* paste api for some pastebins
|
||||
* image downloader
|
||||
* repo uploader
|
||||
* metagen.pm: make metadata files in atomic way
|
||||
* metagen.pm: validate metadata
|
||||
* simple monitoring api (common metrics: cpu, mem, swap, la, etc)
|
||||
* jabber bot: send memos to offline participants when they return
|
||||
* announce youtube video title
|
||||
* common bot functions move to separate module
|
||||
* bot bridge telegram-irc-jabber
|
||||
* anounce html page title
|
||||
@@ -46,4 +46,8 @@
|
||||
"myslack" : "/var/www/repo/myslack",
|
||||
"stuff" : "/var/www/repo/stuff"
|
||||
},
|
||||
"buildinfo" : {
|
||||
"backports" : "/path/to/myslack.json",
|
||||
"thrirdparty" : "/path/to/stuff.json"
|
||||
}
|
||||
}
|
||||
|
||||
66
lib/buildinfo.pm
Normal file
66
lib/buildinfo.pm
Normal file
@@ -0,0 +1,66 @@
|
||||
package buildinfo;
|
||||
|
||||
use strict;
|
||||
use warnings "all";
|
||||
use vars qw/$VERSION/;
|
||||
use conf;
|
||||
use JSON::PP;
|
||||
use Data::Dumper;
|
||||
|
||||
use Exporter qw(import);
|
||||
our @EXPORT = qw(buildinfo);
|
||||
|
||||
$VERSION = "1.0";
|
||||
|
||||
my $c = loadConf();
|
||||
|
||||
sub buildinfo($) {
|
||||
my $repo = shift;
|
||||
my ($status, $content, $msg) = ('400', 'text/plain', "Bad Request?\n");
|
||||
|
||||
return ($status, $content, $msg) unless ($repo =~ /\//);
|
||||
|
||||
my ($config, $package) = split(/\//, $repo);
|
||||
|
||||
unless (defined($c->{buildinfo}->{$config})) {
|
||||
$msg = "Config repo $config is not defined in config.\n";
|
||||
return ($status, $content, $msg);
|
||||
}
|
||||
|
||||
open (JSON, "<", $c->{buildinfo}->{$config}) or do {
|
||||
$status = '500';
|
||||
$msg = "Unable to open $c->{buildinfo}->{$config}; $!\n";
|
||||
return ($status, $content, $msg);
|
||||
};
|
||||
|
||||
my $sep = $/;
|
||||
my $json = <JSON>;
|
||||
close JSON;
|
||||
$/ = $sep;
|
||||
|
||||
my $j = eval { decode_json($json) } or do {
|
||||
$status = '500';
|
||||
$msg = "Error during decoding $c->{buildinfo}->{$config}; $@\n";
|
||||
return ($status, $content, $msg);
|
||||
};
|
||||
|
||||
unless (defined($j->{$package})) {
|
||||
$msg = "$package is not defined in config for $config.\n";
|
||||
return ($status, $content, $msg);
|
||||
}
|
||||
|
||||
$json = JSON::PP->new->pretty->canonical->indent_length(4)->encode($j->{$package}) or do {
|
||||
$status = '500';
|
||||
$msg = "Unable to encode json.\n";
|
||||
return ($status, $content, $msg);
|
||||
};
|
||||
|
||||
$status = '200';
|
||||
$content = 'application/json';
|
||||
$msg = $json;
|
||||
return ($status, $content, $msg);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# vim: set ft=perl noet ai ts=4 sw=4 sts=4:
|
||||
@@ -5,7 +5,7 @@ use warnings "all";
|
||||
use lib qw(./lib ./vendor_perl ./vendor_perl/lib/perl5);
|
||||
use conf;
|
||||
use jabberbot;
|
||||
use telegrambot;
|
||||
use ircbot;
|
||||
use threads;
|
||||
|
||||
my $CONF = loadConf();
|
||||
@@ -14,7 +14,7 @@ if ($CONF->{api}->{prefix} eq '/') { $CONF->{api}->{prefix} = ''; }
|
||||
my $prefix = $CONF->{api}->{prefix};
|
||||
|
||||
threads->create('run_jabberbot')->detach;
|
||||
threads->create('run_telegrambot')->detach;
|
||||
threads->create('run_ircbot')->detach;
|
||||
|
||||
my $app = sub {
|
||||
my $env = shift;
|
||||
|
||||
@@ -13,7 +13,7 @@ open (C, $conf) || die "No such file $conf\n";
|
||||
$jstr = <C>;
|
||||
close C;
|
||||
|
||||
my $c = decode_json($jstr);
|
||||
my $c = JSON::PP->new->decode($jstr);
|
||||
|
||||
my $j = JSON::PP->new->pretty->canonical->indent_length(4);
|
||||
print $j->encode($c);
|
||||
|
||||
@@ -6,6 +6,7 @@ use lib qw(./lib ./vendor_perl ./vendor_perl/lib/perl5);
|
||||
use conf;
|
||||
use upload;
|
||||
use metagen;
|
||||
use buildinfo;
|
||||
|
||||
my $CONF = loadConf();
|
||||
|
||||
@@ -38,9 +39,14 @@ my $app = sub {
|
||||
if (defined($env->{HTTP_REPO})) {
|
||||
($status, $content, $msg) = metagen($env->{HTTP_REPO});
|
||||
}
|
||||
} elsif ($env->{PATH_INFO} eq "$prefix/buildinfo") {
|
||||
if (defined($env->{HTTP_REPO})) {
|
||||
($status, $content, $msg) = buildinfo($env->{HTTP_REPO});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return [
|
||||
$status,
|
||||
[ 'Content-Type' => $content, 'Content-Length' => length($msg) ],
|
||||
|
||||
Reference in New Issue
Block a user