You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
In an attempt to set up different values for different environments (e.g. staging and production) I'm passing the values as environment variables and using them like so:
Traceback (most recent call last):
File "/home/runner/work/projectname/venv/bin/ecs-compose-x", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/runner/work/projectname/venv/lib/python3.12/site-packages/ecs_composex/cli.py", line 194, in main
settings = ComposeXSettings(**vars(args))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/projectname/venv/lib/python3.12/site-packages/ecs_composex/common/settings.py", line 177, in __init__
self.set_content(kwargs, content)
File "/home/runner/work/projectname/venv/lib/python3.12/site-packages/ecs_composex/common/settings.py", line 525, in set_content
content_def = ComposeDefinition(files, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/projectname/venv/lib/python3.12/site-packages/compose_x_render/compose_x_render.py", line 324, in __init__
jsonschema.validate(
File "/home/runner/work/projectname/venv/lib/python3.12/site-packages/jsonschema/validators.py", line 1332, in validate
raise error
jsonschema.exceptions.ValidationError: '1' is not of type 'integer'
Failed validating 'type' in schema['properties']['services']['patternProperties']['^[a-zA-Z0-9._-]+$']['properties']['deploy']['properties']['replicas']:
{'type': 'integer'}
On instance['services']['projectname']['deploy']['replicas']:
'1'
Describe the solution you'd like
When requiring an integer, I would like a string to attempt a string to int conversion before discarding the value for not being the correct type.
Describe alternatives you've considered
YAML does not support conditionals, so the values will have to be set outside of the YAML file. When bringing them in they are always treated as strings, for as far as I know. I do not know of a way to mitigate this.
The text was updated successfully, but these errors were encountered:
Hello @pindab0ter
The error comes from the fact that the JSON schema for this only accepts integer whereas you have set ${ECS_REPLICAS} and unfortunately, env vars == string, that's why it's upset about it.
I have found !!int. Unfortunately, the type coercion happens before the environment variable substitution happens, which means that this is not a solution.
I look forward to the update with support for both strings and ints in those fields.
Yeah okay, so lots of these values need to be casted to int() from str in case you use env vars, I see. I don't use env vars all that much in my worflows and I guess defo not for numbers 🤣
Is your feature request related to a problem? Please describe.
In an attempt to set up different values for different environments (e.g. staging and production) I'm passing the values as environment variables and using them like so:
However, this results in the following error:
Describe the solution you'd like
When requiring an integer, I would like a string to attempt a string to int conversion before discarding the value for not being the correct type.
Describe alternatives you've considered
YAML does not support conditionals, so the values will have to be set outside of the YAML file. When bringing them in they are always treated as strings, for as far as I know. I do not know of a way to mitigate this.
The text was updated successfully, but these errors were encountered: