external-resources-io 0.0.0rc1__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.
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.1
2
+ Name: external-resources-io
3
+ Version: 0.0.0rc1
4
+ Summary: Util classes for AppSRE External Resources system
5
+ Author: Jordi Piriz
6
+ Author-email: jpiriz@redhat.com
7
+ Requires-Python: >=3.11,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Requires-Dist: pydantic (>=2.5.3,<2.6.0)
12
+ Description-Content-Type: text/markdown
13
+
14
+ # External Resources IO
15
+
16
+ Utility library to parse input data from App-Interface into External Resource modules.
17
+
@@ -0,0 +1,3 @@
1
+ # External Resources IO
2
+
3
+ Utility library to parse input data from App-Interface into External Resource modules.
@@ -0,0 +1,43 @@
1
+ from pydantic import BaseModel
2
+ from typing import Optional
3
+ import json
4
+ import base64
5
+ from typing import TypeVar, Type, Any
6
+ from collections.abc import Mapping
7
+ import os
8
+
9
+ class TerraformProvisionOptions(BaseModel):
10
+ tf_state_bucket: str
11
+ tf_state_region: str
12
+ tf_state_dynamodb_table: str
13
+ tf_state_key: str
14
+
15
+
16
+ class AppInterfaceProvision(BaseModel):
17
+ provision_provider: str # aws
18
+ provisioner: str # ter-int-dev
19
+ provider: str # aws-iam-role
20
+ identifier: str
21
+ target_cluster: str
22
+ target_namespace: str
23
+ target_secret_name: Optional[str]
24
+ module_provision_data: TerraformProvisionOptions
25
+
26
+
27
+ T = TypeVar("T", bound=BaseModel)
28
+
29
+
30
+ def parse_model(model_class: Type[T], data: Mapping[str, Any]) -> T:
31
+ input = model_class.model_validate(data)
32
+ return input
33
+
34
+
35
+ def read_input_from_file(file_path: str = "/inputs/input.json") -> dict[str, Any]:
36
+ with open(file_path, "r") as f:
37
+ return json.loads(f.read())
38
+
39
+
40
+ def read_input_from_env_var(var: str = "INPUT") -> dict[str, Any]:
41
+ b64data = os.environ[var]
42
+ str_input = base64.b64decode(b64data.encode("utf-8")).decode("utf-8")
43
+ return json.loads(str_input)
@@ -0,0 +1,23 @@
1
+ [tool.poetry]
2
+ name = "external-resources-io"
3
+ version = "0.0.0rc1"
4
+ description = "Util classes for AppSRE External Resources system"
5
+ authors = ["Jordi Piriz <jpiriz@redhat.com>"]
6
+ readme = "README.md"
7
+
8
+ [tool.poetry.dependencies]
9
+ python = "^3.11"
10
+ pydantic = "~2.5.3"
11
+
12
+ [tool.poetry.group.dev.dependencies]
13
+ pytest = "^7.4.4"
14
+
15
+ [build-system]
16
+ requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
17
+ build-backend = "poetry_dynamic_versioning.backend"
18
+
19
+ [tool.poetry-dynamic-versioning]
20
+ enable = false
21
+ vcs = "git"
22
+ latest-tag = true
23
+ format-jinja = "{% if distance==0 %}{{ base }}{% else %}{{ base }}rc{{ distance }}{% endif %}"