Skip to content

Commit

Permalink
finishing updated providers
Browse files Browse the repository at this point in the history
- added -lockfile=readonly to terraform init
  - this cleans up the terraform init output significantly
  - this required ensuring the handling of the provider lockfile
    was exact in all cases
- Add thorough tests
  - added google-beta provider test
  - fixed testconf related to improper google-beta provider config
- Removed commented out / empty files
- Updated pyproject.toml to reflect post 1.2.0 group config
  - this minimizes the modules installed with base poetry install
  - to install dev deps you must `poetry install --with dev`
- removed unused dependencies from old plugin package
  - requests
  - markupsafe
  - tenacity
- updated tfworker.util.terraform to only include public functions
  - split all private/helper methods into terraform_helpers.py
  • Loading branch information
ephur committed Jun 17, 2024
1 parent 321cca0 commit 1bc275a
Show file tree
Hide file tree
Showing 23 changed files with 926 additions and 794 deletions.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[settings]
known_third_party = atlassian,boto3,botocore,click,deepdiff,google,hcl2,jinja2,mergedeep,moto,pytest,yaml
known_third_party = atlassian,boto3,botocore,click,deepdiff,google,hcl2,jinja2,mergedeep,moto,pydantic,pytest,yaml
profile = black
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ dep-test: init
poetry run coverage report --fail-under=60 -m --skip-empty

clean:
rm -rf build dist .eggs terraform_worker.egg-info
find . -name *.pyc -exec rm {} \;
@echo "removing python temporary and build files "
@rm -rf build dist .eggs terraform_worker.egg-info
@find . -name *.pyc -exec rm {} \;
@find . -name __pycache__ -type d -exec rmdir {} \;
31 changes: 8 additions & 23 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 9 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,22 @@ python = "^3.10"
boto3 = "^1.34"
click = "^8.1"
jinja2 = "^3.1"
tenacity = "^8.2.2"
requests = "^2.28"
google-cloud-storage = "^2.7"
google-cloud-storage = "^2.17"
python-hcl2 = "^4.3"
lark = "^1.1"
pyyaml = "^6.0"
markupsafe = "^2.1"
mergedeep = "^1.3"
setuptools = "^70.0"
atlassian-python-api = "^3.41"
pydantic = "^2.7"

[tool.poetry.dev-dependencies]
[tool.poetry.scripts]
worker = 'tfworker.cli:cli'

[tool.poetry.group.dev]
optional = true

[tool.poetry.group.dev.dependencies]
pytest-timeout = "2.3.1"
ipython = "^8.24"
pytest = "^8.2"
black = "^24.4"
Expand All @@ -59,12 +62,6 @@ moto = {extras = ["sts","dynamodb", "s3"], version = "^5.0"}
deepdiff = "^7.0"
Sphinx = "^7.3"

[tool.poetry.scripts]
worker = 'tfworker.cli:cli'

[tool.poetry.group.dev.dependencies]
pytest-timeout = "2.3.1"

[tool.pytest.ini_options]
addopts = "--capture=sys --cov=tfworker --cov-report="

Expand Down
7 changes: 0 additions & 7 deletions tests/commands/test_terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import pathlib
from contextlib import contextmanager
from typing import Tuple
from unittest import mock
from unittest.mock import MagicMock, patch
Expand All @@ -27,12 +26,6 @@
from tfworker.handlers import HandlerError


# context manager to allow testing exceptions in parameterized tests
@contextmanager
def does_not_raise():
yield


def mock_pipe_exec(
args: str,
stdin: str = None,
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/test_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ terraform:
vars:
region: {{ aws_region }}

google_beta:
google-beta:
requirements:
version: 3.38.0

Expand Down
21 changes: 0 additions & 21 deletions tests/providers/test_aws.py

This file was deleted.

8 changes: 8 additions & 0 deletions tests/providers/test_google_beta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def test_google_hcl(basec):
render = basec.providers["google-beta"].hcl()
expected_render = """provider "google-beta" {
region = "us-west-2"
credentials = file("/home/test/test-creds.json")
}"""

assert render == expected_render
154 changes: 0 additions & 154 deletions tests/test_plugins.py

This file was deleted.

8 changes: 0 additions & 8 deletions tests/util/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from contextlib import contextmanager
from unittest import mock

import pytest

from tfworker.util.system import get_platform, get_version, pipe_exec, strip_ansi, which


# context manager to allow testing exceptions in parameterized tests
@contextmanager
def does_not_raise():
yield


def mock_pipe_exec(args, stdin=None, cwd=None, env=None):
return (0, "".encode(), "".encode())

Expand Down
Loading

0 comments on commit 1bc275a

Please sign in to comment.