mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
Require AWS_BUCKETNAME for prod, integration and labs environments only
AWS_BUCKETNAME is only needed in order to write on the bucket, but
read-only access should be allowed for other environments.
Fixes bug introduced by 6c3b610610
This commit is contained in:
@@ -110,13 +110,19 @@ class CloudPlatform(models.AbstractModel):
|
|||||||
"SWIFT_PASSWORD environment variable is required when "
|
"SWIFT_PASSWORD environment variable is required when "
|
||||||
"ir_attachment.location is 'swift'."
|
"ir_attachment.location is 'swift'."
|
||||||
)
|
)
|
||||||
container_name = os.environ['SWIFT_WRITE_CONTAINER']
|
container_name = os.environ.get('SWIFT_WRITE_CONTAINER', '')
|
||||||
if environment_name in ('integration', 'prod'):
|
if environment_name in ('prod', 'integration', 'labs'):
|
||||||
assert container_name, (
|
assert container_name, (
|
||||||
"SWIFT_WRITE_CONTAINER must not be empty for prod "
|
"SWIFT_WRITE_CONTAINER environment variable is required when "
|
||||||
"and integration"
|
"ir_attachment.location is 'swift'.\n"
|
||||||
|
"Normally, 'swift' is activated on labs, integration "
|
||||||
|
"and production, but should not be used in dev environment"
|
||||||
|
" (or using a dedicated dev bucket, never using the "
|
||||||
|
"integration/prod bucket).\n"
|
||||||
|
"If you don't actually need a bucket, change the"
|
||||||
|
" 'ir_attachment.location' parameter."
|
||||||
)
|
)
|
||||||
prod_container = bool(re.match(r'[a-z]+-odoo-prod',
|
prod_container = bool(re.match(r'[a-z0-9-]+-odoo-prod',
|
||||||
container_name))
|
container_name))
|
||||||
if environment_name == 'prod':
|
if environment_name == 'prod':
|
||||||
assert prod_container, (
|
assert prod_container, (
|
||||||
@@ -158,21 +164,19 @@ class CloudPlatform(models.AbstractModel):
|
|||||||
"AWS_SECRET_ACCESS_KEY environment variable is required when "
|
"AWS_SECRET_ACCESS_KEY environment variable is required when "
|
||||||
"ir_attachment.location is 's3'."
|
"ir_attachment.location is 's3'."
|
||||||
)
|
)
|
||||||
assert os.environ.get('AWS_BUCKETNAME'), (
|
bucket_name = os.environ.get('AWS_BUCKETNAME', '')
|
||||||
"AWS_BUCKETNAME environment variable is required when "
|
if environment_name in ('prod', 'integration', 'labs'):
|
||||||
"ir_attachment.location is 's3'.\n"
|
|
||||||
"Normally, 's3' is activated on integration and production, "
|
|
||||||
"but should not be used in dev environment (or at least "
|
|
||||||
"not with a dev bucket, but never the "
|
|
||||||
"integration/prod bucket)."
|
|
||||||
)
|
|
||||||
bucket_name = os.environ['AWS_BUCKETNAME']
|
|
||||||
if environment_name in ('integration', 'prod'):
|
|
||||||
assert bucket_name, (
|
assert bucket_name, (
|
||||||
"AWS_BUCKETNAME must not be empty for prod "
|
"AWS_BUCKETNAME environment variable is required when "
|
||||||
"and integration"
|
"ir_attachment.location is 's3'.\n"
|
||||||
|
"Normally, 's3' is activated on labs, integration "
|
||||||
|
"and production, but should not be used in dev environment"
|
||||||
|
" (or using a dedicated dev bucket, never using the "
|
||||||
|
"integration/prod bucket).\n"
|
||||||
|
"If you don't actually need a bucket, change the"
|
||||||
|
" 'ir_attachment.location' parameter."
|
||||||
)
|
)
|
||||||
prod_bucket = bool(re.match(r'[a-z0-9]+-odoo-prod', bucket_name))
|
prod_bucket = bool(re.match(r'[a-z-0-9]+-odoo-prod', bucket_name))
|
||||||
if environment_name == 'prod':
|
if environment_name == 'prod':
|
||||||
assert prod_bucket, (
|
assert prod_bucket, (
|
||||||
"AWS_BUCKETNAME should match '<client>-odoo-prod', "
|
"AWS_BUCKETNAME should match '<client>-odoo-prod', "
|
||||||
|
|||||||
Reference in New Issue
Block a user