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:
@@ -100,7 +100,8 @@ 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.get('SWIFT_WRITE_CONTAINER')
|
container_name = os.environ.get('SWIFT_WRITE_CONTAINER', '')
|
||||||
|
if environment_name in ('prod', 'integration', 'labs'):
|
||||||
assert container_name, (
|
assert container_name, (
|
||||||
"SWIFT_WRITE_CONTAINER environment variable is required when "
|
"SWIFT_WRITE_CONTAINER environment variable is required when "
|
||||||
"ir_attachment.location is 'swift'.\n"
|
"ir_attachment.location is 'swift'.\n"
|
||||||
@@ -111,8 +112,6 @@ class CloudPlatform(models.AbstractModel):
|
|||||||
"If you don't actually need a bucket, change the"
|
"If you don't actually need a bucket, change the"
|
||||||
" 'ir_attachment.location' parameter."
|
" 'ir_attachment.location' parameter."
|
||||||
)
|
)
|
||||||
prod_container = bool(re.match(r'[a-z0-9-]+-odoo-prod',
|
|
||||||
container_name))
|
|
||||||
# A bucket name is defined under the following format
|
# A bucket name is defined under the following format
|
||||||
# <client>-odoo-<env>
|
# <client>-odoo-<env>
|
||||||
#
|
#
|
||||||
@@ -120,6 +119,8 @@ class CloudPlatform(models.AbstractModel):
|
|||||||
# structure
|
# structure
|
||||||
if os.environ.get('SWIFT_WRITE_CONTAINER_UNSTRUCTURED'):
|
if os.environ.get('SWIFT_WRITE_CONTAINER_UNSTRUCTURED'):
|
||||||
return
|
return
|
||||||
|
prod_container = bool(re.match(r'[a-z0-9-]+-odoo-prod',
|
||||||
|
container_name))
|
||||||
if environment_name == 'prod':
|
if environment_name == 'prod':
|
||||||
assert prod_container, (
|
assert prod_container, (
|
||||||
"SWIFT_WRITE_CONTAINER should match '<client>-odoo-prod', "
|
"SWIFT_WRITE_CONTAINER should match '<client>-odoo-prod', "
|
||||||
@@ -163,7 +164,8 @@ 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'."
|
||||||
)
|
)
|
||||||
bucket_name = os.environ.get('AWS_BUCKETNAME')
|
bucket_name = os.environ.get('AWS_BUCKETNAME', '')
|
||||||
|
if environment_name in ('prod', 'integration', 'labs'):
|
||||||
assert bucket_name, (
|
assert bucket_name, (
|
||||||
"AWS_BUCKETNAME environment variable is required when "
|
"AWS_BUCKETNAME environment variable is required when "
|
||||||
"ir_attachment.location is 's3'.\n"
|
"ir_attachment.location is 's3'.\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user