atlas-init 0.1.0__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.
Files changed (74) hide show
  1. atlas_init/__init__.py +3 -3
  2. atlas_init/atlas_init.yaml +51 -34
  3. atlas_init/cli.py +76 -72
  4. atlas_init/cli_cfn/app.py +40 -117
  5. atlas_init/cli_cfn/{cfn.py → aws.py} +129 -14
  6. atlas_init/cli_cfn/cfn_parameter_finder.py +89 -6
  7. atlas_init/cli_cfn/example.py +203 -0
  8. atlas_init/cli_cfn/files.py +63 -0
  9. atlas_init/cli_helper/go.py +6 -3
  10. atlas_init/cli_helper/run.py +18 -2
  11. atlas_init/cli_helper/tf_runner.py +12 -21
  12. atlas_init/cli_root/__init__.py +0 -0
  13. atlas_init/cli_root/trigger.py +153 -0
  14. atlas_init/cli_tf/app.py +211 -4
  15. atlas_init/cli_tf/changelog.py +103 -0
  16. atlas_init/cli_tf/debug_logs.py +221 -0
  17. atlas_init/cli_tf/debug_logs_test_data.py +253 -0
  18. atlas_init/cli_tf/github_logs.py +229 -0
  19. atlas_init/cli_tf/go_test_run.py +194 -0
  20. atlas_init/cli_tf/go_test_run_format.py +31 -0
  21. atlas_init/cli_tf/go_test_summary.py +144 -0
  22. atlas_init/cli_tf/hcl/__init__.py +0 -0
  23. atlas_init/cli_tf/hcl/cli.py +161 -0
  24. atlas_init/cli_tf/hcl/cluster_mig.py +348 -0
  25. atlas_init/cli_tf/hcl/parser.py +140 -0
  26. atlas_init/cli_tf/schema.py +222 -18
  27. atlas_init/cli_tf/schema_go_parser.py +236 -0
  28. atlas_init/cli_tf/schema_table.py +150 -0
  29. atlas_init/cli_tf/schema_table_models.py +155 -0
  30. atlas_init/cli_tf/schema_v2.py +599 -0
  31. atlas_init/cli_tf/schema_v2_api_parsing.py +298 -0
  32. atlas_init/cli_tf/schema_v2_sdk.py +361 -0
  33. atlas_init/cli_tf/schema_v3.py +222 -0
  34. atlas_init/cli_tf/schema_v3_sdk.py +279 -0
  35. atlas_init/cli_tf/schema_v3_sdk_base.py +68 -0
  36. atlas_init/cli_tf/schema_v3_sdk_create.py +216 -0
  37. atlas_init/humps.py +253 -0
  38. atlas_init/repos/cfn.py +6 -1
  39. atlas_init/repos/path.py +3 -3
  40. atlas_init/settings/config.py +30 -11
  41. atlas_init/settings/env_vars.py +29 -3
  42. atlas_init/settings/path.py +12 -1
  43. atlas_init/settings/rich_utils.py +39 -2
  44. atlas_init/terraform.yaml +77 -1
  45. atlas_init/tf/.terraform.lock.hcl +125 -0
  46. atlas_init/tf/always.tf +11 -2
  47. atlas_init/tf/main.tf +3 -0
  48. atlas_init/tf/modules/aws_s3/provider.tf +1 -1
  49. atlas_init/tf/modules/aws_vars/aws_vars.tf +2 -0
  50. atlas_init/tf/modules/aws_vpc/provider.tf +4 -1
  51. atlas_init/tf/modules/cfn/cfn.tf +47 -33
  52. atlas_init/tf/modules/cfn/kms.tf +54 -0
  53. atlas_init/tf/modules/cfn/resource_actions.yaml +1 -0
  54. atlas_init/tf/modules/cfn/variables.tf +31 -0
  55. atlas_init/tf/modules/cloud_provider/cloud_provider.tf +1 -0
  56. atlas_init/tf/modules/cloud_provider/provider.tf +1 -1
  57. atlas_init/tf/modules/cluster/cluster.tf +34 -24
  58. atlas_init/tf/modules/cluster/provider.tf +1 -1
  59. atlas_init/tf/modules/federated_vars/federated_vars.tf +3 -0
  60. atlas_init/tf/modules/federated_vars/provider.tf +1 -1
  61. atlas_init/tf/modules/project_extra/project_extra.tf +15 -1
  62. atlas_init/tf/modules/stream_instance/stream_instance.tf +1 -1
  63. atlas_init/tf/modules/vpc_peering/vpc_peering.tf +1 -1
  64. atlas_init/tf/modules/vpc_privatelink/versions.tf +1 -1
  65. atlas_init/tf/outputs.tf +11 -3
  66. atlas_init/tf/providers.tf +2 -1
  67. atlas_init/tf/variables.tf +17 -0
  68. atlas_init/typer_app.py +76 -0
  69. {atlas_init-0.1.0.dist-info → atlas_init-0.1.4.dist-info}/METADATA +58 -21
  70. atlas_init-0.1.4.dist-info/RECORD +91 -0
  71. {atlas_init-0.1.0.dist-info → atlas_init-0.1.4.dist-info}/WHEEL +1 -1
  72. atlas_init-0.1.0.dist-info/RECORD +0 -61
  73. /atlas_init/tf/modules/aws_vpc/{aws-vpc.tf → aws_vpc.tf} +0 -0
  74. {atlas_init-0.1.0.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