From e286a0da1ad97227836164cddd7fd108f9520a3e Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 25 Oct 2016 10:16:26 +0200 Subject: [PATCH] Allow different bucket name than *-odoo-prod Only force it if the server-env is 'prod'. When we have no production yet, the integration will have its own bucket. --- cloud_platform/models/cloud_platform.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/cloud_platform/models/cloud_platform.py b/cloud_platform/models/cloud_platform.py index 267871a..e7d6e5a 100644 --- a/cloud_platform/models/cloud_platform.py +++ b/cloud_platform/models/cloud_platform.py @@ -71,25 +71,26 @@ class CloudPlatform(models.AbstractModel): ) use_s3 = params.get_param('ir_attachment.location') == 's3://' if environment_name in ('prod', 'integration'): + assert use_s3 + if use_s3: assert os.environ.get('AWS_ACCESS_KEY_ID') assert os.environ.get('AWS_SECRET_ACCESS_KEY') assert os.environ.get('AWS_BUCKETNAME') bucket_name = os.environ['AWS_BUCKETNAME'] - assert re.match(r'[a-z]+-odoo-prod', bucket_name), ( - "AWS_BUCKETNAME should match '-odoo-prod', " - "we got: '%s'" % (bucket_name,) - ) - assert use_s3 + prod_bucket = bool(re.match(r'[a-z]+-odoo-prod', bucket_name)) + if environment_name == 'prod': + assert prod_bucket, ( + "AWS_BUCKETNAME should match '-odoo-prod', " + "we got: '%s'" % (bucket_name,) + ) + assert not attachment_readonly + else: + # if we are using the prod bucket on another instance + # such as an integration, we must be sure to be in read only! + assert not prod_bucket or attachment_readonly elif environment_name == 'test': # store in DB so we don't have files local to the host assert params.get_param('ir_attachment.location') == 'db' - if use_s3: - # on the integration/dev, we read the filestore from the production - # s3, but we must be readonly! - if environment_name == 'prod': - assert not attachment_readonly - else: - assert attachment_readonly @api.model def _check_redis(self, environment_name):