foxops 2.5.2__tar.gz → 2.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {foxops-2.5.2 → foxops-2.6.0}/PKG-INFO +1 -1
- {foxops-2.5.2 → foxops-2.6.0}/pyproject.toml +1 -1
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/__main__.py +19 -1
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/models/template_config.py +45 -2
- {foxops-2.5.2 → foxops-2.6.0}/LICENSE +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/README.md +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/__main__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/engine.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/repositories/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/repositories/change/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/repositories/change/errors.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/repositories/change/model.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/repositories/change/repository.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/repositories/incarnation/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/repositories/incarnation/errors.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/repositories/incarnation/model.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/repositories/incarnation/repository.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/database/schema.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/dependencies.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/custom_filters.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/errors.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/initialization.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/models/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/models/incarnation_state.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/patching/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/patching/git_diff_patch.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/rendering.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/engine/update.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/error_handlers.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/errors.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/external/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/external/git.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/hosters/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/hosters/gitlab.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/hosters/local.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/hosters/types.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/logger.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/middlewares.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/models/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/models/change.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/models/errors.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/models/incarnation.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/openapi.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/routers/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/routers/auth.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/routers/changes.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/routers/incarnations.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/routers/not_found.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/routers/version.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/services/__init__.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/services/change.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/services/incarnation.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/settings.py +0 -0
- {foxops-2.5.2 → foxops-2.6.0}/src/foxops/utils.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import copy
|
|
3
3
|
import logging
|
|
4
|
+
import re
|
|
4
5
|
from pathlib import Path
|
|
5
6
|
from subprocess import PIPE, check_output
|
|
6
7
|
from typing import Annotated, Any, Optional
|
|
@@ -67,11 +68,28 @@ def parse_template_data_arguments(raw_template_data: list[str]) -> TemplateData:
|
|
|
67
68
|
# descend into the correct sub-dict of the template data object
|
|
68
69
|
current_level = template_data
|
|
69
70
|
for key_element in key_elements[:-1]:
|
|
70
|
-
|
|
71
|
+
if match := re.match(r"(.+)\[(\d+)\]$", key_element):
|
|
72
|
+
list_key = match.group(1)
|
|
73
|
+
index = int(match.group(2))
|
|
74
|
+
|
|
75
|
+
current_level = current_level.setdefault(list_key, [])
|
|
76
|
+
while len(current_level) <= index:
|
|
77
|
+
current_level.append({})
|
|
78
|
+
current_level = current_level[index]
|
|
79
|
+
else:
|
|
80
|
+
current_level = current_level.setdefault(key_element, {})
|
|
71
81
|
|
|
72
82
|
# now we can inject the value to the "current level"
|
|
73
83
|
if key_elements[-1].endswith("[]"): # in case we need to append to a list
|
|
74
84
|
current_level.setdefault(key_elements[-1][:-2], []).append(value)
|
|
85
|
+
elif match := re.match(r"(.+)\[(\d+)\]$", key_elements[-1]):
|
|
86
|
+
list_key = match.group(1)
|
|
87
|
+
index = int(match.group(2))
|
|
88
|
+
|
|
89
|
+
current_level = current_level.setdefault(list_key, [])
|
|
90
|
+
while len(current_level) <= index:
|
|
91
|
+
current_level.append(None)
|
|
92
|
+
current_level[index] = value
|
|
75
93
|
else: # or we just want to add a "flat" value
|
|
76
94
|
current_level[key_elements[-1]] = value
|
|
77
95
|
|
|
@@ -13,6 +13,7 @@ from pydantic import (
|
|
|
13
13
|
BaseModel,
|
|
14
14
|
BeforeValidator,
|
|
15
15
|
Field,
|
|
16
|
+
TypeAdapter,
|
|
16
17
|
ValidationError,
|
|
17
18
|
create_model,
|
|
18
19
|
)
|
|
@@ -90,15 +91,33 @@ class StringListVariableDefinition(BaseListVariableDefinition):
|
|
|
90
91
|
return list[str]
|
|
91
92
|
|
|
92
93
|
|
|
94
|
+
ListVariableDefinition = Annotated[
|
|
95
|
+
Union[
|
|
96
|
+
StringListVariableDefinition,
|
|
97
|
+
"ObjectListVariableDefinition",
|
|
98
|
+
],
|
|
99
|
+
Field(discriminator="element_type"),
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def validate_variable_type(v: Any) -> Any:
|
|
104
|
+
if isinstance(v, dict):
|
|
105
|
+
t = v.get("type")
|
|
106
|
+
allowed_types = {"string", "str", "integer", "int", "boolean", "bool", "list", "object"}
|
|
107
|
+
if t not in allowed_types:
|
|
108
|
+
raise ValueError(f"Invalid variable type: '{t}'. Allowed types are: {', '.join(sorted(allowed_types))}")
|
|
109
|
+
return v
|
|
110
|
+
|
|
111
|
+
|
|
93
112
|
VariableDefinition = Annotated[
|
|
94
113
|
Union[
|
|
95
114
|
StringVariableDefinition,
|
|
96
115
|
IntegerVariableDefinition,
|
|
97
116
|
BooleanVariableDefinition,
|
|
98
|
-
|
|
117
|
+
ListVariableDefinition,
|
|
99
118
|
"ObjectVariableDefinition",
|
|
100
119
|
],
|
|
101
|
-
|
|
120
|
+
BeforeValidator(validate_variable_type),
|
|
102
121
|
]
|
|
103
122
|
|
|
104
123
|
|
|
@@ -117,6 +136,30 @@ def valid_variable_names(v: dict[str, Any]) -> dict[str, Any]:
|
|
|
117
136
|
VariableDefinitions = Annotated[dict[str, VariableDefinition], AfterValidator(valid_variable_names)]
|
|
118
137
|
|
|
119
138
|
|
|
139
|
+
class ObjectListVariableDefinition(BaseListVariableDefinition):
|
|
140
|
+
element_type: Literal["object"] = "object"
|
|
141
|
+
children: VariableDefinitions
|
|
142
|
+
default: list[dict[str, Any]] | None = None
|
|
143
|
+
|
|
144
|
+
def pydantic_field_default(self) -> Any:
|
|
145
|
+
if self.default is None:
|
|
146
|
+
return ...
|
|
147
|
+
|
|
148
|
+
return TypeAdapter(self.pydantic_field_model()).validate_python(self.default)
|
|
149
|
+
|
|
150
|
+
def pydantic_field_model(self) -> Any:
|
|
151
|
+
fields: dict[str, Any] = {
|
|
152
|
+
name: (child.pydantic_field_model(), child.pydantic_field_default())
|
|
153
|
+
for name, child in self.children.items()
|
|
154
|
+
}
|
|
155
|
+
object_model = create_model("ObjectVariable", **fields)
|
|
156
|
+
|
|
157
|
+
# `create_model` function returns a class dynamically at runtime
|
|
158
|
+
# this dynamic behavior is intentional
|
|
159
|
+
# mypy doesn't recognize the dynamic model as a valid type for generics
|
|
160
|
+
return list[object_model] # type: ignore[valid-type]
|
|
161
|
+
|
|
162
|
+
|
|
120
163
|
class ObjectVariableDefinition(BaseVariableDefinition):
|
|
121
164
|
type: Literal["object"] = "object"
|
|
122
165
|
children: VariableDefinitions
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|