summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Config
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-08-11 17:16:38 +0200
committerByron Jones <glob@mozilla.com>2015-08-11 17:17:00 +0200
commit99bec2e52b174c1e8774ebf12da5963330d47af9 (patch)
treeee9f39a742eb6739be38355eac4af3399d17fb01 /Bugzilla/Config
parentdd7cd13b7cecaa92caebd3c4930154b2de35ff29 (diff)
downloadbugzilla-99bec2e52b174c1e8774ebf12da5963330d47af9.tar.gz
bugzilla-99bec2e52b174c1e8774ebf12da5963330d47af9.tar.xz
Bug 1160929 - add support for storing attachments in s3
Diffstat (limited to 'Bugzilla/Config')
-rw-r--r--Bugzilla/Config/Attachment.pm104
1 files changed, 72 insertions, 32 deletions
diff --git a/Bugzilla/Config/Attachment.pm b/Bugzilla/Config/Attachment.pm
index cf87f4c89..20cde0b01 100644
--- a/Bugzilla/Config/Attachment.pm
+++ b/Bugzilla/Config/Attachment.pm
@@ -38,42 +38,82 @@ use Bugzilla::Config::Common;
our $sortkey = 400;
sub get_param_list {
- my $class = shift;
- my @param_list = (
- {
- name => 'allow_attachment_display',
- type => 'b',
- default => 0
- },
+ my $class = shift;
+ my @param_list = (
+ {
+ name => 'allow_attachment_display',
+ type => 'b',
+ default => 0
+ },
+ {
+ name => 'attachment_base',
+ type => 't',
+ default => '',
+ checker => \&check_urlbase
+ },
+ {
+ name => 'allow_attachment_deletion',
+ type => 'b',
+ default => 0
+ },
+ {
+ name => 'maxattachmentsize',
+ type => 't',
+ default => '1000',
+ checker => \&check_maxattachmentsize
+ },
+ {
+ name => 'attachment_storage',
+ type => 's',
+ choices => ['database', 'filesystem', 's3'],
+ default => 'database',
+ checker => \&check_storage
+ },
+ {
+ name => 's3_bucket',
+ type => 't',
+ default => '',
+ },
+ {
+ name => 'aws_access_key_id',
+ type => 't',
+ default => '',
+ },
+ {
+ name => 'aws_secret_access_key',
+ type => 't',
+ default => '',
+ },
+ );
+ return @param_list;
+}
- {
- name => 'attachment_base',
- type => 't',
- default => '',
- checker => \&check_urlbase
- },
+sub check_params {
+ my ($class, $params) = @_;
+ return unless $params->{attachment_storage} eq 's3';
- {
- name => 'allow_attachment_deletion',
- type => 'b',
- default => 0
- },
+ if ($params->{s3_bucket} eq ''
+ || $params->{aws_access_key_id} eq ''
+ || $params->{aws_secret_access_key} eq ''
+ ) {
+ return "You must set s3_bucket, aws_access_key_id, and aws_secret_access_key when attachment_storage is set to S3";
+ }
+ return '';
+}
- {
- name => 'maxattachmentsize',
- type => 't',
- default => '1000',
- checker => \&check_maxattachmentsize
- },
+sub check_storage {
+ my ($value, $param) = (@_);
+ my $check_multi = check_multi($value, $param);
+ return $check_multi if $check_multi;
- {
- name => 'attachment_storage',
- type => 's',
- choices => ['database', 'filesystem'],
- default => 'database',
- checker => \&check_multi
- } );
- return @param_list;
+ if ($value eq 's3') {
+ return Bugzilla->feature('s3')
+ ? ''
+ : 'The perl modules required for S3 support are not installed';
+ }
+ else {
+ return '';
+ }
}
1;