Skip to content

Commit 7115f86

Browse files
committed
Fix comamnd without opa
1 parent 9be0f11 commit 7115f86

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/confcom/azext_confcom/lib/fragment_references.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from azext_confcom.lib.cose import cose_get_properties
1313
from azext_confcom.lib.fragments import get_fragments_from_image
14-
from azext_confcom.lib.opa import opa_eval
14+
from azext_confcom.lib.serialization import rego_eval
1515

1616

1717
def from_image(image: str, minimum_svn: Optional[str]):
@@ -24,11 +24,7 @@ def from_image(image: str, minimum_svn: Optional[str]):
2424
payload.write(cose_properties["payload"].encode("utf-8"))
2525
payload.flush()
2626

27-
package_name = re.search(r"^package\s*(.*)$", cose_properties["payload"], re.MULTILINE).group(1)
28-
fragment_properties = opa_eval(
29-
Path(payload.name),
30-
f"data.{package_name}",
31-
)["result"][0]["expressions"][0]["value"]
27+
fragment_properties = rego_eval(payload.name)
3228

3329
yield {
3430
"feed": cose_properties["feed"],

src/confcom/azext_confcom/lib/serialization.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def fragment_serialize(fragment: Fragment):
7676
""")
7777

7878

79-
def policy_deserialize(file_path: str):
79+
def rego_eval(file_path: str):
8080

8181
with open(file_path, 'r') as f:
8282
content = f.readlines()
@@ -124,6 +124,13 @@ def _brace_delta(line: str) -> int:
124124

125125
line_idx += 1
126126

127+
return policy_json
128+
129+
130+
def policy_deserialize(file_path: str):
131+
132+
policy_json = rego_eval(file_path)
133+
127134
PolicyType = Policy if policy_json.get("package") == "policy" else Fragment
128135

129136
raw_fragments = policy_json.pop("fragments", [])

0 commit comments

Comments
 (0)