Skip to content

Commit 815bfb7

Browse files
committed
Fix merge conflict
1 parent ebd36ff commit 815bfb7

File tree

19 files changed

+362
-680
lines changed

19 files changed

+362
-680
lines changed

src/confcom/azext_confcom/command/containers_from_vn2.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,15 @@ def vn2_container_env_rules(template: dict, container: dict, template_variables:
5353
env_var.get('valueFrom').get("secretKeyRef", None)
5454
)
5555
yield {
56-
"name": env_var.get('name'),
57-
"value": template_variables[var_ref.get("name")][var_ref.get("key")],
56+
"pattern": f"{env_var.get('name')}={template_variables[var_ref.get('name')][var_ref.get('key')]}",
5857
"strategy": "string",
5958
"required": False,
6059
}
6160

6261
elif "fieldRef" in env_var.get('valueFrom'):
6362
# Existing behaviour is to wildcard this, there is a correct implementation below
6463
yield {
65-
"name": env_var.get('name'),
66-
"value": ".*",
64+
"pattern": f"{env_var.get('name')}=.*",
6765
"strategy": "re2",
6866
"required": False,
6967
}
@@ -156,17 +154,21 @@ def containers_from_vn2(
156154
"name": container_name,
157155
"command": template_container.get("command", []) + template_container.get("args", []),
158156
"env_rules": (
159-
config.OPENGCS_ENV_RULES
160-
+ config.FABRIC_ENV_RULES
161-
+ config.MANAGED_IDENTITY_ENV_RULES
162-
+ config.ENABLE_RESTART_ENV_RULE
163-
+ config.VIRTUAL_NODE_ENV_RULES
157+
[
158+
{
159+
"pattern": rule.get("pattern") or f"{rule.get('name')}={rule.get('value')}",
160+
"strategy": rule.get("strategy", "string"),
161+
"required": rule.get("required", False),
162+
} for rule in (
163+
config.OPENGCS_ENV_RULES
164+
+ config.FABRIC_ENV_RULES
165+
+ config.MANAGED_IDENTITY_ENV_RULES
166+
+ config.ENABLE_RESTART_ENV_RULE
167+
+ config.VIRTUAL_NODE_ENV_RULES
168+
)]
164169
+ list(vn2_container_env_rules(template_doc, template_container, variables))
165170
),
166-
"mounts": (
167-
VN2_MOUNTS
168-
+ vn2_container_mounts(template_doc, template_container)
169-
),
171+
"mounts": vn2_container_mounts(template_doc, template_container),
170172
}
171173

172174
# Parse security context

src/confcom/azext_confcom/custom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def containers_from_vn2(
570570
template: str,
571571
container_name: str,
572572
) -> None:
573-
_containers_from_vn2(
573+
print(_containers_from_vn2(
574574
template=template,
575575
container_name=container_name,
576-
)
576+
))

src/confcom/azext_confcom/lib/containers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55

6+
from dataclasses import asdict
67
from azext_confcom.lib.images import get_image_layers, get_image_config
78
from azext_confcom.lib.platform import ACI_MOUNTS, VN2_MOUNTS
89

@@ -21,9 +22,8 @@ def merge_containers(*args) -> dict:
2122
"mounts",
2223
"signals",
2324
}:
24-
if key not in merged_container:
25-
merged_container[key] = []
26-
merged_container[key] += value
25+
existing = merged_container.get(key) or []
26+
merged_container[key] = list(existing) + list(value or [])
2727
else:
2828
merged_container[key] = value
2929

@@ -33,7 +33,7 @@ def merge_containers(*args) -> dict:
3333
def from_image(image: str, platform: str) -> dict:
3434

3535
mounts = {
36-
"aci": ACI_MOUNTS,
36+
"aci": [asdict(mount) for mount in ACI_MOUNTS],
3737
"vn2": VN2_MOUNTS,
3838
}.get(platform, None)
3939

src/confcom/azext_confcom/lib/policy.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ class ContainerRuleLegacy:
5252
@dataclass
5353
class ContainerExecProcesses:
5454
command: List[str]
55-
signals: Optional[List[str]] = OrderlessField(default=None)
56-
allow_stdio_access: bool = True
55+
signals: Optional[List[int]] = OrderlessField(default=None)
5756

5857

5958
@dataclass()
@@ -98,7 +97,7 @@ class Container:
9897
name: Optional[str] = None
9998
no_new_privileges: bool = False
10099
seccomp_profile_sha256: str = ""
101-
signals: List[str] = OrderlessField(default_factory=list)
100+
signals: List[int] = OrderlessField(default_factory=list)
102101
user: ContainerUser = Field(default_factory=ContainerUser)
103102
working_dir: str = "/"
104103

src/confcom/azext_confcom/tests/latest/test_confcom_acipolicygen_arm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_acipolicygen(sample_directory, generated_policy_path):
6767
parameters_path = os.path.join(SAMPLES_ROOT, sample_directory, "parameters.json")
6868
if not os.path.isfile(parameters_path):
6969
parameters_path = None
70-
flags = POLICYGEN_ARGS[generated_policy_path]
70+
flags = POLICYGEN_ARGS[generated_policy_path].copy()
7171

7272
with open(os.path.join(SAMPLES_ROOT, sample_directory, generated_policy_path), "r", encoding="utf-8") as f:
7373
expected_policy = f.read()

src/confcom/samples/vn2/basic_command_args/containers.inc.rego

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,124 +7,104 @@
77
],
88
"env_rules": [
99
{
10-
"name": "APP_MODE",
1110
"required": false,
1211
"strategy": "string",
13-
"value": "production"
12+
"pattern": "APP_MODE=production"
1413
},
1514
{
16-
"name": "PATH",
1715
"required": false,
1816
"strategy": "string",
19-
"value": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
17+
"pattern": "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
2018
},
2119
{
22-
"name": "TERM",
2320
"required": false,
2421
"strategy": "string",
25-
"value": "xterm"
22+
"pattern": "TERM=xterm"
2623
},
2724
{
28-
"name": "(?i)(FABRIC)_.+",
2925
"required": false,
3026
"strategy": "re2",
31-
"value": ".+"
27+
"pattern": "(?i)(FABRIC)_.+=.+"
3228
},
3329
{
34-
"name": "HOSTNAME",
3530
"required": false,
3631
"strategy": "re2",
37-
"value": ".+"
32+
"pattern": "HOSTNAME=.+"
3833
},
3934
{
40-
"name": "T(E)?MP",
4135
"required": false,
4236
"strategy": "re2",
43-
"value": ".+"
37+
"pattern": "T(E)?MP=.+"
4438
},
4539
{
46-
"name": "FabricPackageFileName",
4740
"required": false,
4841
"strategy": "re2",
49-
"value": ".+"
42+
"pattern": "FabricPackageFileName=.+"
5043
},
5144
{
52-
"name": "HostedServiceName",
5345
"required": false,
5446
"strategy": "re2",
55-
"value": ".+"
47+
"pattern": "HostedServiceName=.+"
5648
},
5749
{
58-
"name": "IDENTITY_API_VERSION",
5950
"required": false,
6051
"strategy": "re2",
61-
"value": ".+"
52+
"pattern": "IDENTITY_API_VERSION=.+"
6253
},
6354
{
64-
"name": "IDENTITY_HEADER",
6555
"required": false,
6656
"strategy": "re2",
67-
"value": ".+"
57+
"pattern": "IDENTITY_HEADER=.+"
6858
},
6959
{
70-
"name": "IDENTITY_SERVER_THUMBPRINT",
7160
"required": false,
7261
"strategy": "re2",
73-
"value": ".+"
62+
"pattern": "IDENTITY_SERVER_THUMBPRINT=.+"
7463
},
7564
{
76-
"name": "azurecontainerinstance_restarted_by",
7765
"required": false,
7866
"strategy": "re2",
79-
"value": ".+"
67+
"pattern": "azurecontainerinstance_restarted_by=.+"
8068
},
8169
{
82-
"name": "[A-Z0-9_]+_SERVICE_HOST",
8370
"required": false,
8471
"strategy": "re2",
85-
"value": ".+"
72+
"pattern": "[A-Z0-9_]+_SERVICE_HOST=.+"
8673
},
8774
{
88-
"name": "[A-Z0-9_]+_SERVICE_PORT",
8975
"required": false,
9076
"strategy": "re2",
91-
"value": ".+"
77+
"pattern": "[A-Z0-9_]+_SERVICE_PORT=.+"
9278
},
9379
{
94-
"name": "[A-Z0-9_]+_SERVICE_PORT_[A-Z0-9_]+",
9580
"required": false,
9681
"strategy": "re2",
97-
"value": ".+"
82+
"pattern": "[A-Z0-9_]+_SERVICE_PORT_[A-Z0-9_]+=.+"
9883
},
9984
{
100-
"name": "[A-Z0-9_]+_PORT",
10185
"required": false,
10286
"strategy": "re2",
103-
"value": ".+"
87+
"pattern": "[A-Z0-9_]+_PORT=.+"
10488
},
10589
{
106-
"name": "[A-Z0-9_]+_PORT_[0-9]+_TCP",
10790
"required": false,
10891
"strategy": "re2",
109-
"value": ".+"
92+
"pattern": "[A-Z0-9_]+_PORT_[0-9]+_TCP=.+"
11093
},
11194
{
112-
"name": "[A-Z0-9_]+_PORT_[0-9]+_TCP_PROTO",
11395
"required": false,
11496
"strategy": "re2",
115-
"value": ".+"
97+
"pattern": "[A-Z0-9_]+_PORT_[0-9]+_TCP_PROTO=.+"
11698
},
11799
{
118-
"name": "[A-Z0-9_]+_PORT_[0-9]+_TCP_PORT",
119100
"required": false,
120101
"strategy": "re2",
121-
"value": ".+"
102+
"pattern": "[A-Z0-9_]+_PORT_[0-9]+_TCP_PORT=.+"
122103
},
123104
{
124-
"name": "[A-Z0-9_]+_PORT_[0-9]+_TCP_ADDR",
125105
"required": false,
126106
"strategy": "re2",
127-
"value": ".+"
107+
"pattern": "[A-Z0-9_]+_PORT_[0-9]+_TCP_ADDR=.+"
128108
}
129109
],
130110
"id": "mcr.microsoft.com/azurelinux/distroless/base@sha256:1e77d97e1e39f22ed9c52f49b3508b4c1044cec23743df9098ac44e025f654f2",

0 commit comments

Comments
 (0)