mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
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.
This commit is contained in:
@@ -71,25 +71,26 @@ class CloudPlatform(models.AbstractModel):
|
|||||||
)
|
)
|
||||||
use_s3 = params.get_param('ir_attachment.location') == 's3://'
|
use_s3 = params.get_param('ir_attachment.location') == 's3://'
|
||||||
if environment_name in ('prod', 'integration'):
|
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_ACCESS_KEY_ID')
|
||||||
assert os.environ.get('AWS_SECRET_ACCESS_KEY')
|
assert os.environ.get('AWS_SECRET_ACCESS_KEY')
|
||||||
assert os.environ.get('AWS_BUCKETNAME')
|
assert os.environ.get('AWS_BUCKETNAME')
|
||||||
bucket_name = os.environ['AWS_BUCKETNAME']
|
bucket_name = os.environ['AWS_BUCKETNAME']
|
||||||
assert re.match(r'[a-z]+-odoo-prod', bucket_name), (
|
prod_bucket = bool(re.match(r'[a-z]+-odoo-prod', bucket_name))
|
||||||
|
if environment_name == 'prod':
|
||||||
|
assert prod_bucket, (
|
||||||
"AWS_BUCKETNAME should match '<client>-odoo-prod', "
|
"AWS_BUCKETNAME should match '<client>-odoo-prod', "
|
||||||
"we got: '%s'" % (bucket_name,)
|
"we got: '%s'" % (bucket_name,)
|
||||||
)
|
)
|
||||||
assert use_s3
|
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':
|
elif environment_name == 'test':
|
||||||
# store in DB so we don't have files local to the host
|
# store in DB so we don't have files local to the host
|
||||||
assert params.get_param('ir_attachment.location') == 'db'
|
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
|
@api.model
|
||||||
def _check_redis(self, environment_name):
|
def _check_redis(self, environment_name):
|
||||||
|
|||||||
Reference in New Issue
Block a user