atlas-init 0.1.1__py3-none-any.whl → 0.1.4__py3-none-any.whl
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.
- atlas_init/__init__.py +3 -3
- atlas_init/atlas_init.yaml +18 -1
- atlas_init/cli.py +62 -70
- atlas_init/cli_cfn/app.py +40 -117
- atlas_init/cli_cfn/{cfn.py → aws.py} +129 -14
- atlas_init/cli_cfn/cfn_parameter_finder.py +89 -6
- atlas_init/cli_cfn/example.py +203 -0
- atlas_init/cli_cfn/files.py +63 -0
- atlas_init/cli_helper/run.py +18 -2
- atlas_init/cli_helper/tf_runner.py +4 -6
- atlas_init/cli_root/__init__.py +0 -0
- atlas_init/cli_root/trigger.py +153 -0
- atlas_init/cli_tf/app.py +211 -4
- atlas_init/cli_tf/changelog.py +103 -0
- atlas_init/cli_tf/debug_logs.py +221 -0
- atlas_init/cli_tf/debug_logs_test_data.py +253 -0
- atlas_init/cli_tf/github_logs.py +229 -0
- atlas_init/cli_tf/go_test_run.py +194 -0
- atlas_init/cli_tf/go_test_run_format.py +31 -0
- atlas_init/cli_tf/go_test_summary.py +144 -0
- atlas_init/cli_tf/hcl/__init__.py +0 -0
- atlas_init/cli_tf/hcl/cli.py +161 -0
- atlas_init/cli_tf/hcl/cluster_mig.py +348 -0
- atlas_init/cli_tf/hcl/parser.py +140 -0
- atlas_init/cli_tf/schema.py +222 -18
- atlas_init/cli_tf/schema_go_parser.py +236 -0
- atlas_init/cli_tf/schema_table.py +150 -0
- atlas_init/cli_tf/schema_table_models.py +155 -0
- atlas_init/cli_tf/schema_v2.py +599 -0
- atlas_init/cli_tf/schema_v2_api_parsing.py +298 -0
- atlas_init/cli_tf/schema_v2_sdk.py +361 -0
- atlas_init/cli_tf/schema_v3.py +222 -0
- atlas_init/cli_tf/schema_v3_sdk.py +279 -0
- atlas_init/cli_tf/schema_v3_sdk_base.py +68 -0
- atlas_init/cli_tf/schema_v3_sdk_create.py +216 -0
- atlas_init/humps.py +253 -0
- atlas_init/repos/cfn.py +6 -1
- atlas_init/repos/path.py +3 -3
- atlas_init/settings/config.py +14 -4
- atlas_init/settings/env_vars.py +16 -1
- atlas_init/settings/path.py +12 -1
- atlas_init/settings/rich_utils.py +2 -0
- atlas_init/terraform.yaml +77 -1
- atlas_init/tf/.terraform.lock.hcl +59 -83
- atlas_init/tf/always.tf +7 -0
- atlas_init/tf/main.tf +3 -0
- atlas_init/tf/modules/aws_s3/provider.tf +1 -1
- atlas_init/tf/modules/aws_vars/aws_vars.tf +2 -0
- atlas_init/tf/modules/aws_vpc/provider.tf +4 -1
- atlas_init/tf/modules/cfn/cfn.tf +47 -33
- atlas_init/tf/modules/cfn/kms.tf +54 -0
- atlas_init/tf/modules/cfn/resource_actions.yaml +1 -0
- atlas_init/tf/modules/cfn/variables.tf +31 -0
- atlas_init/tf/modules/cloud_provider/cloud_provider.tf +1 -0
- atlas_init/tf/modules/cloud_provider/provider.tf +1 -1
- atlas_init/tf/modules/cluster/cluster.tf +34 -24
- atlas_init/tf/modules/cluster/provider.tf +1 -1
- atlas_init/tf/modules/federated_vars/federated_vars.tf +3 -0
- atlas_init/tf/modules/federated_vars/provider.tf +1 -1
- atlas_init/tf/modules/project_extra/project_extra.tf +15 -1
- atlas_init/tf/modules/stream_instance/stream_instance.tf +1 -1
- atlas_init/tf/modules/vpc_peering/vpc_peering.tf +1 -1
- atlas_init/tf/modules/vpc_privatelink/versions.tf +1 -1
- atlas_init/tf/outputs.tf +11 -3
- atlas_init/tf/providers.tf +2 -1
- atlas_init/tf/variables.tf +12 -0
- atlas_init/typer_app.py +76 -0
- {atlas_init-0.1.1.dist-info → atlas_init-0.1.4.dist-info}/METADATA +36 -18
- atlas_init-0.1.4.dist-info/RECORD +91 -0
- {atlas_init-0.1.1.dist-info → atlas_init-0.1.4.dist-info}/WHEEL +1 -1
- atlas_init-0.1.1.dist-info/RECORD +0 -62
- /atlas_init/tf/modules/aws_vpc/{aws-vpc.tf → aws_vpc.tf} +0 -0
- {atlas_init-0.1.1.dist-info → atlas_init-0.1.4.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,155 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import re
|
4
|
+
from enum import StrEnum
|
5
|
+
from functools import total_ordering
|
6
|
+
|
7
|
+
from model_lib import Entity, Event
|
8
|
+
from pydantic import Field
|
9
|
+
|
10
|
+
from atlas_init.cli_tf.schema_v3 import ComputedOptionalRequired
|
11
|
+
|
12
|
+
|
13
|
+
class TFSchemaTableColumn(StrEnum):
|
14
|
+
Computability = "Computability"
|
15
|
+
Type = "Type"
|
16
|
+
Default = "Default"
|
17
|
+
PlanModifiers = "PlanModifiers"
|
18
|
+
Deprecated = "Deprecated"
|
19
|
+
|
20
|
+
|
21
|
+
class FuncCallLine(Event):
|
22
|
+
call_line_nr: int
|
23
|
+
func_name: str
|
24
|
+
args: str
|
25
|
+
func_line_start: int
|
26
|
+
func_line_end: int
|
27
|
+
|
28
|
+
|
29
|
+
class AttrRefLine(Event):
|
30
|
+
line_nr: int
|
31
|
+
attr_ref: str
|
32
|
+
|
33
|
+
|
34
|
+
_schema_type_regex = re.compile(r"schema\.\w+")
|
35
|
+
|
36
|
+
|
37
|
+
@total_ordering
|
38
|
+
class TFSchemaAttribute(Entity):
|
39
|
+
name: str
|
40
|
+
default: str = ""
|
41
|
+
plan_modifiers: list[str] = Field(default_factory=list)
|
42
|
+
|
43
|
+
line_start: int
|
44
|
+
line_end: int
|
45
|
+
indent: str = ""
|
46
|
+
lines: list[str] = Field(default_factory=list)
|
47
|
+
|
48
|
+
func_call: FuncCallLine | None = None
|
49
|
+
attr_ref_line: AttrRefLine | None = None
|
50
|
+
attribute_path: str = ""
|
51
|
+
absolute_attribute_path: str = ""
|
52
|
+
|
53
|
+
@property
|
54
|
+
def type(self) -> str:
|
55
|
+
if self.lines and (type_match := _schema_type_regex.search(self.lines[0])):
|
56
|
+
return type_match.group()
|
57
|
+
prefix = f"{self.indent}\tType:"
|
58
|
+
for line in self.lines:
|
59
|
+
if line.startswith(prefix):
|
60
|
+
schema_type = line[len(prefix) :].strip()
|
61
|
+
if schema_type.startswith("schema."):
|
62
|
+
return schema_type
|
63
|
+
return ""
|
64
|
+
|
65
|
+
@property
|
66
|
+
def computability(self) -> ComputedOptionalRequired:
|
67
|
+
if self.is_required:
|
68
|
+
return ComputedOptionalRequired.required
|
69
|
+
optional = self.is_optional
|
70
|
+
computed = self.is_computed
|
71
|
+
if optional:
|
72
|
+
if computed:
|
73
|
+
return ComputedOptionalRequired.computed_optional
|
74
|
+
return ComputedOptionalRequired.optional
|
75
|
+
if computed:
|
76
|
+
return ComputedOptionalRequired.computed
|
77
|
+
return ComputedOptionalRequired.unset
|
78
|
+
|
79
|
+
@property
|
80
|
+
def is_function_call(self) -> bool:
|
81
|
+
return self.func_call is not None
|
82
|
+
|
83
|
+
@property
|
84
|
+
def is_required(self) -> bool:
|
85
|
+
prefix = f"{self.indent}\tRequired:"
|
86
|
+
return any("true" in line and line.startswith(prefix) for line in self.lines)
|
87
|
+
|
88
|
+
@property
|
89
|
+
def is_computed(self) -> bool:
|
90
|
+
prefix = f"{self.indent}\tComputed:"
|
91
|
+
return any("true" in line and line.startswith(prefix) for line in self.lines)
|
92
|
+
|
93
|
+
@property
|
94
|
+
def is_optional(self) -> bool:
|
95
|
+
prefix = f"{self.indent}\tOptional:"
|
96
|
+
return any("true" in line and line.startswith(prefix) for line in self.lines)
|
97
|
+
|
98
|
+
@property
|
99
|
+
def start_end(self) -> tuple[int, int]:
|
100
|
+
return self.line_start, self.line_end
|
101
|
+
|
102
|
+
@property
|
103
|
+
def deprecated(self) -> str:
|
104
|
+
deprecation_attributes = ["Deprecated", "DeprecationMessage"]
|
105
|
+
for attr in deprecation_attributes:
|
106
|
+
prefix = f"{self.indent}\t{attr}:"
|
107
|
+
if found := next(
|
108
|
+
(line[len(prefix) :].strip() for line in self.lines if line.startswith(prefix)),
|
109
|
+
"",
|
110
|
+
):
|
111
|
+
return found
|
112
|
+
return ""
|
113
|
+
|
114
|
+
def as_dict(self) -> dict[TFSchemaTableColumn, str]:
|
115
|
+
return {
|
116
|
+
TFSchemaTableColumn.Computability: self.computability,
|
117
|
+
TFSchemaTableColumn.Type: self.type,
|
118
|
+
TFSchemaTableColumn.Default: self.default,
|
119
|
+
TFSchemaTableColumn.PlanModifiers: ", ".join(self.plan_modifiers),
|
120
|
+
TFSchemaTableColumn.Deprecated: self.deprecated,
|
121
|
+
}
|
122
|
+
|
123
|
+
def row(self, columns: list[TFSchemaTableColumn]) -> list[str]:
|
124
|
+
d = self.as_dict()
|
125
|
+
return [d[col] for col in columns]
|
126
|
+
|
127
|
+
def parent_attribute_names(self) -> list[str]:
|
128
|
+
parent_path = self.attribute_path.removesuffix(self.name).strip(".")
|
129
|
+
parents: list[str] = []
|
130
|
+
for parent in parent_path.split("."):
|
131
|
+
if not parent:
|
132
|
+
continue
|
133
|
+
if parent.startswith("(") and parent.endswith(")"):
|
134
|
+
parents.extend(parent.strip("()").split("|"))
|
135
|
+
else:
|
136
|
+
parents.append(parent)
|
137
|
+
|
138
|
+
return parents
|
139
|
+
|
140
|
+
def explode(self) -> list[TFSchemaAttribute]:
|
141
|
+
exploded = []
|
142
|
+
if "|" not in self.absolute_attribute_path:
|
143
|
+
return [self]
|
144
|
+
part_before, part_after = self.absolute_attribute_path.split("(", maxsplit=1)
|
145
|
+
pipe_separated_values, rest = part_after.split(")", maxsplit=1)
|
146
|
+
for value in pipe_separated_values.split("|"):
|
147
|
+
new_attr = self.model_copy(update={"absolute_attribute_path": f"{part_before}{value}{rest}"})
|
148
|
+
new_attr.absolute_attribute_path = f"{part_before}{value}{rest}"
|
149
|
+
exploded.append(new_attr)
|
150
|
+
return exploded
|
151
|
+
|
152
|
+
def __lt__(self, other) -> bool:
|
153
|
+
if not isinstance(other, TFSchemaAttribute):
|
154
|
+
raise TypeError
|
155
|
+
return self.absolute_attribute_path < other.absolute_attribute_path
|