-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for complex variables (lists, nested objects) (#427)
* * fully remove the no longer functioning "allow_import" variable on the create incarnation endpoint * remove support for fvars file * add support for complex template variables (lists, nested objects) * proper handling of template variables with defaults in incarnations (default values will not be fixed anymore - if a default is not specified explictly when creating an incarnation, it will be changed on an incarnation update, if the default changed in the template) * fixed handling of legacy incarnations and default values for nested variables * fixed incorrect responses from the API * avoid storing additionally provided template variables in the incarnation state ... if they are not defined in the template interface * updated docs and fixed a small bug
- Loading branch information
Showing
43 changed files
with
1,864 additions
and
1,454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
alembic/versions/2023_11_04-00ee97d0b7a3_adding_column_for_keeping_track_of_full_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""adding column for keeping track of full template data | ||
Revision ID: 00ee97d0b7a3 | ||
Revises: 001f927357ef | ||
Create Date: 2023-11-04 16:14:57.823773+00:00 | ||
""" | ||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "00ee97d0b7a3" | ||
down_revision = "001f927357ef" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column("change", sa.Column("template_data_full", sa.String(), nullable=True)) | ||
op.execute("UPDATE change SET template_data_full = requested_data") | ||
|
||
with op.batch_alter_table("change") as batch_op: | ||
batch_op.alter_column("template_data_full", nullable=False) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("change", "template_data_full") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from pydantic import ValidationError | ||
|
||
from foxops.errors import FoxopsUserError | ||
|
||
|
||
class ProvidedTemplateDataInvalidError(FoxopsUserError): | ||
def get_readable_error_messages(self) -> list[str]: | ||
if not isinstance(self.__cause__, ValidationError): | ||
raise RuntimeError( | ||
"exception was not chained. Must be raised (raise ... from ...) " "with a ValidationError as cause" | ||
) | ||
|
||
validation_error = self.__cause__ | ||
|
||
error_messages: list[str] = [] | ||
for e in validation_error.errors(): | ||
match e: | ||
case {"type": "missing"}: | ||
location = ".".join(map(lambda x: str(x), e["loc"])) | ||
error_messages.append(f"'{location}' - no value was provided for this required template variable") | ||
case _: | ||
error_messages.append(str(e)) | ||
|
||
return error_messages |
Oops, something went wrong.