tfdo 0.1.0__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.
- tfdo-0.1.0/.gitignore +40 -0
- tfdo-0.1.0/LICENSE +21 -0
- tfdo-0.1.0/PKG-INFO +11 -0
- tfdo-0.1.0/README.md +1 -0
- tfdo-0.1.0/pyproject.toml +107 -0
- tfdo-0.1.0/scripts/fix_source_links.py +56 -0
- tfdo-0.1.0/tfdo/__init__.py +14 -0
- tfdo-0.1.0/tfdo/__main__.py +4 -0
- tfdo-0.1.0/tfdo/_internal/__init__.py +1 -0
- tfdo-0.1.0/tfdo/_internal/cmd_options.py +15 -0
- tfdo-0.1.0/tfdo/_internal/core/__init__.py +1 -0
- tfdo-0.1.0/tfdo/_internal/core/cmd_apply.py +25 -0
- tfdo-0.1.0/tfdo/_internal/core/cmd_check.py +24 -0
- tfdo-0.1.0/tfdo/_internal/core/cmd_destroy.py +25 -0
- tfdo-0.1.0/tfdo/_internal/core/cmd_init.py +21 -0
- tfdo-0.1.0/tfdo/_internal/core/cmd_plan.py +28 -0
- tfdo-0.1.0/tfdo/_internal/models.py +39 -0
- tfdo-0.1.0/tfdo/_internal/settings.py +27 -0
- tfdo-0.1.0/tfdo/_internal/typer_app.py +37 -0
- tfdo-0.1.0/tfdo/cli.py +9 -0
- tfdo-0.1.0/tfdo/core.py +12 -0
- tfdo-0.1.0/tfdo/py.typed +1 -0
tfdo-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# path-sync copy -n python-template
|
|
2
|
+
|
|
3
|
+
# === DO_NOT_EDIT: path-sync gitignore ===
|
|
4
|
+
# Python bytecode
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.pyc
|
|
7
|
+
*.pyo
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv/
|
|
11
|
+
venv/
|
|
12
|
+
|
|
13
|
+
# Build artifacts
|
|
14
|
+
dist/
|
|
15
|
+
build/
|
|
16
|
+
*.egg-info/
|
|
17
|
+
|
|
18
|
+
# Coverage
|
|
19
|
+
.coverage
|
|
20
|
+
htmlcov/
|
|
21
|
+
coverage.xml
|
|
22
|
+
|
|
23
|
+
# Cache directories
|
|
24
|
+
.ruff_cache/
|
|
25
|
+
.pytest_cache/
|
|
26
|
+
.mypy_cache/
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.idea/
|
|
30
|
+
*.iml
|
|
31
|
+
.vscode/
|
|
32
|
+
|
|
33
|
+
# pkg-ext dev mode files
|
|
34
|
+
.groups-dev.yaml
|
|
35
|
+
CHANGELOG-dev.md
|
|
36
|
+
*.api-dev.yaml
|
|
37
|
+
|
|
38
|
+
# MkDocs build output
|
|
39
|
+
site/
|
|
40
|
+
# === OK_EDIT: path-sync gitignore ===
|
tfdo-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Espen Albert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tfdo-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tfdo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Terraform/OpenTofu lifecycle CLI with retry, workspaces, and CI scaffold
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.13
|
|
8
|
+
Requires-Dist: ask-shell
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# tfdo
|
tfdo-0.1.0/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# tfdo
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# path-sync copy -n python-template
|
|
2
|
+
|
|
3
|
+
# === OK_EDIT: path-sync header ===
|
|
4
|
+
[project]
|
|
5
|
+
name = "tfdo"
|
|
6
|
+
version = "0.1.0"
|
|
7
|
+
description = "Terraform/OpenTofu lifecycle CLI with retry, workspaces, and CI scaffold"
|
|
8
|
+
requires-python = ">=3.13"
|
|
9
|
+
license = "MIT"
|
|
10
|
+
license-files = ["LICENSE"]
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"ask-shell",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[project.scripts]
|
|
17
|
+
tfdo = "tfdo.cli:typer_main"
|
|
18
|
+
|
|
19
|
+
[build-system]
|
|
20
|
+
requires = ["hatchling"]
|
|
21
|
+
build-backend = "hatchling.build"
|
|
22
|
+
|
|
23
|
+
[tool.hatch.build.targets.sdist]
|
|
24
|
+
include = ["*/**/*.py", "*/py.typed", "*/**/*.tmpl"]
|
|
25
|
+
exclude = [
|
|
26
|
+
"*_examples.py",
|
|
27
|
+
"*_test.py",
|
|
28
|
+
"conftest.py",
|
|
29
|
+
"test_*.json",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
# === DO_NOT_EDIT: path-sync pkg-ext ===
|
|
33
|
+
[tool.pkg-ext]
|
|
34
|
+
tag_prefix = "v"
|
|
35
|
+
max_bump_type = "minor"
|
|
36
|
+
# === OK_EDIT: path-sync pkg-ext ===
|
|
37
|
+
|
|
38
|
+
# === DO_NOT_EDIT: path-sync ruff ===
|
|
39
|
+
[tool.ruff]
|
|
40
|
+
line-length = 120
|
|
41
|
+
target-version = "py313"
|
|
42
|
+
|
|
43
|
+
[tool.ruff.lint]
|
|
44
|
+
# E501: line too long (handled by formatter)
|
|
45
|
+
# UP006: use `type` instead of `Type` from typing module
|
|
46
|
+
# UP007: use `X | Y` instead of `Union[X, Y]`
|
|
47
|
+
# UP035: use `typing` instead of `typing_extensions`
|
|
48
|
+
# UP040: use `type` keyword instead of `TypeAlias`
|
|
49
|
+
# UP046: use type parameters on functions instead of TypeVar
|
|
50
|
+
# UP047: use type parameters instead of `Generic[T]` subclass
|
|
51
|
+
extend-ignore = ["E501", "UP006", "UP007", "UP035", "UP040", "UP046", "UP047"]
|
|
52
|
+
extend-select = ["Q", "RUF100", "C90", "UP", "I", "T", "FURB"]
|
|
53
|
+
# === OK_EDIT: path-sync ruff ===
|
|
54
|
+
|
|
55
|
+
# === DO_NOT_EDIT: path-sync pytest ===
|
|
56
|
+
[tool.pytest.ini_options]
|
|
57
|
+
addopts = "-s -vv --log-cli-level=INFO -m 'not manual'"
|
|
58
|
+
markers = ["manual: test requires manual env setup (not run in CI)"]
|
|
59
|
+
python_files = ["*_test.py", "test_*.py"]
|
|
60
|
+
asyncio_mode = "auto"
|
|
61
|
+
# === OK_EDIT: path-sync pytest ===
|
|
62
|
+
|
|
63
|
+
# === DO_NOT_EDIT: path-sync coverage ===
|
|
64
|
+
[tool.coverage.report]
|
|
65
|
+
omit = ["*_test.py"]
|
|
66
|
+
exclude_lines = ["no cov", "if __name__ == .__main__.:"]
|
|
67
|
+
# === OK_EDIT: path-sync coverage ===
|
|
68
|
+
|
|
69
|
+
# === DO_NOT_EDIT: path-sync vulture ===
|
|
70
|
+
[tool.vulture]
|
|
71
|
+
min_confidence = 80
|
|
72
|
+
ignore_names = ["mock_*", "Mock*", "*_mock"]
|
|
73
|
+
exclude = [".venv/", "*test.py"]
|
|
74
|
+
# === OK_EDIT: path-sync vulture ===
|
|
75
|
+
|
|
76
|
+
# === DO_NOT_EDIT: path-sync dev-lint ===
|
|
77
|
+
[dependency-groups]
|
|
78
|
+
dev-lint = [
|
|
79
|
+
"pyright>=1.1",
|
|
80
|
+
"ruff>=0.14",
|
|
81
|
+
"vulture>=2.14",
|
|
82
|
+
]
|
|
83
|
+
# === OK_EDIT: path-sync dev-lint ===
|
|
84
|
+
|
|
85
|
+
# === DO_NOT_EDIT: path-sync dev-test ===
|
|
86
|
+
dev-test = [
|
|
87
|
+
"pytest>=9.0",
|
|
88
|
+
"pytest-asyncio>=0.24",
|
|
89
|
+
"pytest-cov>=7.0",
|
|
90
|
+
"pytest-examples>=0.0.18",
|
|
91
|
+
"pytest-regressions>=2.6",
|
|
92
|
+
]
|
|
93
|
+
# === OK_EDIT: path-sync dev-test ===
|
|
94
|
+
|
|
95
|
+
# === DO_NOT_EDIT: path-sync dev ===
|
|
96
|
+
dev = [{include-group = "dev-lint"}, {include-group = "dev-test"}]
|
|
97
|
+
# === OK_EDIT: path-sync dev ===
|
|
98
|
+
|
|
99
|
+
# === DO_NOT_EDIT: path-sync release ===
|
|
100
|
+
release = ["pkg-ext"]
|
|
101
|
+
# === OK_EDIT: path-sync release ===
|
|
102
|
+
#
|
|
103
|
+
# === DO_NOT_EDIT: path-sync docs ===
|
|
104
|
+
docs = [
|
|
105
|
+
"mkdocs-material>=9.5",
|
|
106
|
+
]
|
|
107
|
+
# === OK_EDIT: path-sync docs ===
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# path-sync copy -n python-template
|
|
2
|
+
"""Replace relative source links with GitHub URLs in docs."""
|
|
3
|
+
|
|
4
|
+
import re
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
if len(sys.argv) < 2:
|
|
9
|
+
raise SystemExit("Usage: fix_source_links.py <REPO_URL>")
|
|
10
|
+
|
|
11
|
+
REPO_URL = sys.argv[1]
|
|
12
|
+
BRANCH = "main"
|
|
13
|
+
DOCS_DIR = Path(__file__).parent.parent / "docs"
|
|
14
|
+
|
|
15
|
+
# Pattern: [source](../../pkg_name/_internal/module.py#L81)
|
|
16
|
+
RELATIVE_SOURCE_PATTERN = re.compile(r"\[source\]\((?P<rel_path>\.\./[^)]+)\)")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def to_github_url(rel_path: str, doc_file: Path) -> str:
|
|
20
|
+
"""Convert relative path to absolute GitHub URL."""
|
|
21
|
+
resolved = (doc_file.parent / rel_path).resolve()
|
|
22
|
+
repo_root = DOCS_DIR.parent
|
|
23
|
+
try:
|
|
24
|
+
repo_relative = resolved.relative_to(repo_root)
|
|
25
|
+
except ValueError:
|
|
26
|
+
return rel_path
|
|
27
|
+
return f"{REPO_URL}/blob/{BRANCH}/{repo_relative}"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def fix_links_in_file(file_path: Path) -> bool:
|
|
31
|
+
"""Fix source links in a single file. Returns True if modified."""
|
|
32
|
+
content = file_path.read_text()
|
|
33
|
+
|
|
34
|
+
def replace_source_link(match: re.Match[str]) -> str:
|
|
35
|
+
rel_path = match.group("rel_path")
|
|
36
|
+
github_url = to_github_url(rel_path, file_path)
|
|
37
|
+
return f"[source]({github_url})"
|
|
38
|
+
|
|
39
|
+
new_content = RELATIVE_SOURCE_PATTERN.sub(replace_source_link, content)
|
|
40
|
+
if new_content != content:
|
|
41
|
+
file_path.write_text(new_content)
|
|
42
|
+
return True
|
|
43
|
+
return False
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def main() -> None:
|
|
47
|
+
modified_count = 0
|
|
48
|
+
for md_file in DOCS_DIR.rglob("*.md"):
|
|
49
|
+
if fix_links_in_file(md_file):
|
|
50
|
+
print(f"Fixed: {md_file.relative_to(DOCS_DIR)}") # noqa: T201
|
|
51
|
+
modified_count += 1
|
|
52
|
+
print(f"Modified {modified_count} file(s)") # noqa: T201
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
if __name__ == "__main__":
|
|
56
|
+
main()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Generated by pkg-ext
|
|
2
|
+
# flake8: noqa
|
|
3
|
+
from tfdo._internal.typer_app import get_settings
|
|
4
|
+
from tfdo._internal.typer_app import main_callback
|
|
5
|
+
from tfdo import core
|
|
6
|
+
from tfdo._internal.settings import TfDoSettings
|
|
7
|
+
|
|
8
|
+
VERSION = "0.1.0"
|
|
9
|
+
__all__ = [
|
|
10
|
+
"get_settings",
|
|
11
|
+
"main_callback",
|
|
12
|
+
"core",
|
|
13
|
+
"TfDoSettings",
|
|
14
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def var_file_option() -> Path | None:
|
|
7
|
+
return typer.Option(None, "--var-file", "-f", help="Path to a terraform .tfvars file")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def auto_approve_option() -> bool:
|
|
11
|
+
return typer.Option(False, "--auto-approve", help="Skip interactive approval prompts")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def init_first_option() -> bool:
|
|
15
|
+
return typer.Option(False, "--init", help="Run terraform init before the command")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import typer
|
|
5
|
+
|
|
6
|
+
from tfdo._internal import cmd_options
|
|
7
|
+
from tfdo._internal.models import ApplyInput
|
|
8
|
+
from tfdo._internal.typer_app import app, get_settings
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@app.command("apply")
|
|
14
|
+
@app.command("a")
|
|
15
|
+
def apply_cmd(
|
|
16
|
+
ctx: typer.Context,
|
|
17
|
+
auto_approve: bool = cmd_options.auto_approve_option(),
|
|
18
|
+
var_file: Path | None = cmd_options.var_file_option(),
|
|
19
|
+
init_first: bool = cmd_options.init_first_option(),
|
|
20
|
+
) -> None:
|
|
21
|
+
"""Run terraform apply."""
|
|
22
|
+
settings = get_settings(ctx)
|
|
23
|
+
input_model = ApplyInput(settings=settings, auto_approve=auto_approve, var_file=var_file, init_first=init_first)
|
|
24
|
+
logger.info(f"tfdo apply [binary={input_model.settings.binary}] -- not implemented yet")
|
|
25
|
+
raise typer.Exit(0)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
from tfdo._internal import cmd_options
|
|
6
|
+
from tfdo._internal.models import CheckInput
|
|
7
|
+
from tfdo._internal.typer_app import app, get_settings
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@app.command("check")
|
|
13
|
+
@app.command("c")
|
|
14
|
+
def check_cmd(
|
|
15
|
+
ctx: typer.Context,
|
|
16
|
+
fix: bool = typer.Option(False, "--fix", help="Auto-format instead of checking"),
|
|
17
|
+
diff: bool = typer.Option(False, "--diff", help="Show what would change"),
|
|
18
|
+
init_first: bool = cmd_options.init_first_option(),
|
|
19
|
+
) -> None:
|
|
20
|
+
"""Run terraform fmt check + validate (ruff-style)."""
|
|
21
|
+
settings = get_settings(ctx)
|
|
22
|
+
input_model = CheckInput(settings=settings, fix=fix, diff=diff, init_first=init_first)
|
|
23
|
+
logger.info(f"tfdo check [binary={input_model.settings.binary}] -- not implemented yet")
|
|
24
|
+
raise typer.Exit(0)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import typer
|
|
5
|
+
|
|
6
|
+
from tfdo._internal import cmd_options
|
|
7
|
+
from tfdo._internal.models import DestroyInput
|
|
8
|
+
from tfdo._internal.typer_app import app, get_settings
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@app.command("destroy")
|
|
14
|
+
@app.command("d")
|
|
15
|
+
def destroy_cmd(
|
|
16
|
+
ctx: typer.Context,
|
|
17
|
+
auto_approve: bool = cmd_options.auto_approve_option(),
|
|
18
|
+
var_file: Path | None = cmd_options.var_file_option(),
|
|
19
|
+
init_first: bool = cmd_options.init_first_option(),
|
|
20
|
+
) -> None:
|
|
21
|
+
"""Run terraform destroy."""
|
|
22
|
+
settings = get_settings(ctx)
|
|
23
|
+
input_model = DestroyInput(settings=settings, auto_approve=auto_approve, var_file=var_file, init_first=init_first)
|
|
24
|
+
logger.info(f"tfdo destroy [binary={input_model.settings.binary}] -- not implemented yet")
|
|
25
|
+
raise typer.Exit(0)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
from tfdo._internal.models import InitInput
|
|
6
|
+
from tfdo._internal.typer_app import app, get_settings
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@app.command("init")
|
|
12
|
+
@app.command("i")
|
|
13
|
+
def init_cmd(
|
|
14
|
+
ctx: typer.Context,
|
|
15
|
+
extra_args: list[str] = typer.Argument(default=None, help="Extra arguments forwarded to terraform init"),
|
|
16
|
+
) -> None:
|
|
17
|
+
"""Run terraform init with retry on transient errors."""
|
|
18
|
+
settings = get_settings(ctx)
|
|
19
|
+
input_model = InitInput(settings=settings, extra_args=extra_args or [])
|
|
20
|
+
logger.info(f"tfdo init [binary={input_model.settings.binary}] -- not implemented yet")
|
|
21
|
+
raise typer.Exit(0)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import typer
|
|
5
|
+
|
|
6
|
+
from tfdo._internal import cmd_options
|
|
7
|
+
from tfdo._internal.models import PlanInput
|
|
8
|
+
from tfdo._internal.typer_app import app, get_settings
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@app.command("plan")
|
|
14
|
+
@app.command("p")
|
|
15
|
+
def plan_cmd(
|
|
16
|
+
ctx: typer.Context,
|
|
17
|
+
out: Path | None = typer.Option(None, "-o", "--out", help="Write the plan to a file"),
|
|
18
|
+
json_output: bool = typer.Option(False, "--json", help="Output plan in JSON format"),
|
|
19
|
+
var_file: Path | None = cmd_options.var_file_option(),
|
|
20
|
+
init_first: bool = cmd_options.init_first_option(),
|
|
21
|
+
) -> None:
|
|
22
|
+
"""Run terraform plan."""
|
|
23
|
+
settings = get_settings(ctx)
|
|
24
|
+
input_model = PlanInput(
|
|
25
|
+
settings=settings, out=out, json_output=json_output, var_file=var_file, init_first=init_first
|
|
26
|
+
)
|
|
27
|
+
logger.info(f"tfdo plan [binary={input_model.settings.binary}] -- not implemented yet")
|
|
28
|
+
raise typer.Exit(0)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
|
|
5
|
+
from tfdo._internal.settings import TfDoSettings
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TfDoBaseInput(BaseModel):
|
|
9
|
+
settings: TfDoSettings
|
|
10
|
+
dry_run: bool = False
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class InitInput(TfDoBaseInput):
|
|
14
|
+
extra_args: list[str] = []
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PlanInput(TfDoBaseInput):
|
|
18
|
+
out: Path | None = None
|
|
19
|
+
json_output: bool = False
|
|
20
|
+
var_file: Path | None = None
|
|
21
|
+
init_first: bool = False
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ApplyInput(TfDoBaseInput):
|
|
25
|
+
auto_approve: bool = False
|
|
26
|
+
var_file: Path | None = None
|
|
27
|
+
init_first: bool = False
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class DestroyInput(TfDoBaseInput):
|
|
31
|
+
auto_approve: bool = False
|
|
32
|
+
var_file: Path | None = None
|
|
33
|
+
init_first: bool = False
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class CheckInput(TfDoBaseInput):
|
|
37
|
+
fix: bool = False
|
|
38
|
+
diff: bool = False
|
|
39
|
+
init_first: bool = False
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from typing import ClassVar
|
|
2
|
+
|
|
3
|
+
from model_lib import StaticSettings
|
|
4
|
+
from pydantic import ConfigDict, Field
|
|
5
|
+
|
|
6
|
+
ENV_PREFIX = "TFDO_"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TfDoSettings(StaticSettings):
|
|
10
|
+
model_config = ConfigDict(populate_by_name=True) # type: ignore
|
|
11
|
+
|
|
12
|
+
ENV_NAME_BINARY: ClassVar[str] = f"{ENV_PREFIX}BINARY"
|
|
13
|
+
binary: str = Field(
|
|
14
|
+
default="terraform",
|
|
15
|
+
alias=ENV_NAME_BINARY,
|
|
16
|
+
description="Terraform binary name or path (terraform, tofu, etc.)",
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
ENV_NAME_TF_VERSION: ClassVar[str] = f"{ENV_PREFIX}TF_VERSION"
|
|
20
|
+
tf_version: str | None = Field(
|
|
21
|
+
default=None,
|
|
22
|
+
alias=ENV_NAME_TF_VERSION,
|
|
23
|
+
description="When set, binary becomes 'mise x terraform@{version} -- {binary}'",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
log_level: str = Field(default="INFO", description="Log level for tfdo")
|
|
27
|
+
passthrough: bool = Field(default=False, description="Disable parsed output, pass raw ANSI from terraform")
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
|
|
3
|
+
from tfdo._internal.settings import TfDoSettings
|
|
4
|
+
|
|
5
|
+
app = typer.Typer(
|
|
6
|
+
name="tfdo",
|
|
7
|
+
help="Terraform/OpenTofu lifecycle CLI with retry, workspaces, and CI scaffold",
|
|
8
|
+
pretty_exceptions_enable=False,
|
|
9
|
+
pretty_exceptions_show_locals=False,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@app.callback()
|
|
14
|
+
def main_callback(
|
|
15
|
+
ctx: typer.Context,
|
|
16
|
+
binary: str = typer.Option(
|
|
17
|
+
"terraform", "-b", "--binary", envvar="TFDO_BINARY", help="Terraform binary name or path"
|
|
18
|
+
),
|
|
19
|
+
tf_version: str | None = typer.Option(
|
|
20
|
+
None, "-V", "--tf-version", envvar="TFDO_TF_VERSION", help="Terraform version (uses mise for version selection)"
|
|
21
|
+
),
|
|
22
|
+
log_level: str = typer.Option("INFO", "--log-level", help="Log level for tfdo"),
|
|
23
|
+
passthrough: bool = typer.Option(
|
|
24
|
+
False, "--passthrough", help="Disable parsed output, pass raw ANSI from terraform"
|
|
25
|
+
),
|
|
26
|
+
) -> None:
|
|
27
|
+
ctx.obj = TfDoSettings(
|
|
28
|
+
binary=binary,
|
|
29
|
+
tf_version=tf_version,
|
|
30
|
+
log_level=log_level,
|
|
31
|
+
passthrough=passthrough,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_settings(ctx: typer.Context) -> TfDoSettings:
|
|
36
|
+
settings: TfDoSettings = ctx.obj
|
|
37
|
+
return settings
|
tfdo-0.1.0/tfdo/cli.py
ADDED
tfdo-0.1.0/tfdo/core.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Generated by pkg-ext
|
|
2
|
+
from tfdo._internal.core.cmd_apply import apply_cmd as _apply_cmd
|
|
3
|
+
from tfdo._internal.core.cmd_check import check_cmd as _check_cmd
|
|
4
|
+
from tfdo._internal.core.cmd_destroy import destroy_cmd as _destroy_cmd
|
|
5
|
+
from tfdo._internal.core.cmd_init import init_cmd as _init_cmd
|
|
6
|
+
from tfdo._internal.core.cmd_plan import plan_cmd as _plan_cmd
|
|
7
|
+
|
|
8
|
+
apply_cmd = _apply_cmd
|
|
9
|
+
check_cmd = _check_cmd
|
|
10
|
+
destroy_cmd = _destroy_cmd
|
|
11
|
+
init_cmd = _init_cmd
|
|
12
|
+
plan_cmd = _plan_cmd
|
tfdo-0.1.0/tfdo/py.typed
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|