Skip to content

Commit

Permalink
Merge pull request #14 from eieste/development
Browse files Browse the repository at this point in the history
refactor: rename everything to tfutility
  • Loading branch information
eieste authored Nov 7, 2024
2 parents 18d8805 + 46ff329 commit bb9328a
Show file tree
Hide file tree
Showing 32 changed files with 80 additions and 81 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
- completed

jobs:
push-tfutils-image:
push-tfutility-image:
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -33,6 +33,6 @@ jobs:

- name: 'Build Inventory Image'
run: |
docker build . --tag ghcr.io/eieste/tfutils:latest
docker push ghcr.io/eieste/tfutils:latest
docker build . --tag ghcr.io/eieste/tfutility:latest
docker push ghcr.io/eieste/tfutility:latest
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ jobs:
- name: Test Install
run: |
pip3 install .;
tfutils --help
tfutility --help
6 changes: 3 additions & 3 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
- id: check-forcedremotesource
name: forcedremoutesources
description: Check if all modules hase remote sources.
entry: tfutils
entry: tfutility
args: ["forcedremotesource"]
language: python
files: (\.tf)$
- id: check-moveddate
name: forcedremoutesources
description: Check if all moved blocks has dates defined.
entry: tfutils
entry: tfutility
args: ["moveddate"]
language: python
files: (\.tf)$
- id: check-importdate
name: importdate
description: Check if all imports has dates defined
entry: tfutils
entry: tfutility
args: ["importdate"]
language: python
files: (\.tf)$
2 changes: 1 addition & 1 deletion .releaserc.prerelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ fail:
- "@semantic-release/github"


repositoryUrl: git@github.com:eieste/tfutils.git
repositoryUrl: git@github.com:eieste/tfutility.git
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM python:3.13-alpine
LABEL MAINTAINER="Stefan Eiermann <foss@ultraapp.de>"
ENV PS1="\[\e[0;33m\]|> tfutils <| \[\e[1;35m\]\W\[\e[0m\] \[\e[0m\]# "
ENV PS1="\[\e[0;33m\]|> tfutility <| \[\e[1;35m\]\W\[\e[0m\] \[\e[0m\]# "

WORKDIR /src
COPY . /src
RUN pip install --no-cache-dir -r requirements.txt \
&& python setup.py install
WORKDIR /
ENTRYPOINT ["tfutils"]
ENTRYPOINT ["tfutility"]
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ include setup.cfg
include README.md CHANGELOG.md LICENSE
include VERSION
include *.txt
recursive-include src/tfutils/templates *

recursive-include src/tfutils *
recursive-include src/tfutility/templates *
recursive-include src/tfutility *
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ clean:
find . -name '*.py[co]' -delete

virtualenv:
virtualenv --prompt '|> tfutils <| ' env
virtualenv --prompt '|> tfutility <| ' env
env/bin/pip install -r requirements-dev.txt
env/bin/python setup.py develop
@echo
Expand All @@ -14,13 +14,13 @@ virtualenv:
test:
python -m pytest \
-v \
--cov=tfutils \
--cov=tfutility \
--cov-report=term \
--cov-report=html:coverage-report \
tests/

docker: clean
docker build -t tfutils:latest .
docker build -t tfutility:latest .

dist: clean
rm -rf dist/*
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# TFUtils
# TfUtility

[![Validate](https://github.com/eieste/tfutils/actions/workflows/validate.yml/badge.svg)](https://github.com/eieste/tfutils/actions/workflows/validate.yml)
[![Validate](https://github.com/eieste/tfutility/actions/workflows/validate.yml/badge.svg)](https://github.com/eieste/tfutility/actions/workflows/validate.yml)


provides different tools for Terraform Developers

## Installation

```
$ pip install tfutils
$ pip install tfutility
```

# TF-Rule-Checker
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.0
0.0.1
2 changes: 1 addition & 1 deletion docs/source/code/main.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ main



.. autoclass:: tfutils.main.TfUtils
.. autoclass:: tfutility.main.TfUtility
:members:
:inherited-members:
:undoc-members:
6 changes: 3 additions & 3 deletions docs/source/code/tffile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ tffile
======


.. autoclass:: tfutils.core.tffile.TfFile
.. autoclass:: tfutility.core.tffile.TfFile
:members:
:inherited-members:
:undoc-members:


.. autoclass:: tfutils.core.tffile.TfBlock
.. autoclass:: tfutility.core.tffile.TfBlock
:members:
:inherited-members:
:undoc-members:


.. autoclass:: tfutils.core.tffile.TfUtilDecorator
.. autoclass:: tfutility.core.tffile.TfUtilDecorator
:members:
:inherited-members:
:undoc-members:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/code/tfpaths.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
tfpaths
=======

.. autoclass:: tfutils.core.tfpaths.TfPaths
.. autoclass:: tfutility.core.tfpaths.TfPaths
:members:
:inherited-members:
:undoc-members:
8 changes: 4 additions & 4 deletions docs/source/users/forcedremotesource.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Example usage
``# @forcedremotesource``


The following Code tells tfutils this module should have an remote source.
The following Code tells tfutility this module should have an remote source.
But as you can see the module has an local path

.. code-block:: hcl
Expand Down Expand Up @@ -56,7 +56,7 @@ This raises an version missing error
.. code-block:: sh
:linenos:
$ tfutils forcedremotesource test.tf
$ tfutility forcedremotesource test.tf
Command Line Arguments
Expand All @@ -67,9 +67,9 @@ Usage in Terraform


.. argparse::
:module: tfutils.main
:module: tfutility.main
:func: _get_parser_only
:prog: tfutils
:prog: tfutility
:path: forcedremotesource


Expand Down
4 changes: 2 additions & 2 deletions docs/source/users/importdate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ Terraform
}
.. argparse::
:module: tfutils.main
:module: tfutility.main
:func: _get_parser_only
:prog: tfutils
:prog: tfutility
:path: importdate


Expand Down
4 changes: 2 additions & 2 deletions docs/source/users/moveddate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Terraform
.. argparse::
:module: tfutils.main
:module: tfutility.main
:func: _get_parser_only
:prog: tfutils
:prog: tfutility
:path: moveddate
4 changes: 2 additions & 2 deletions docs/source/users/swapsource.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Terraform
.. argparse::
:module: tfutils.main
:module: tfutility.main
:func: _get_parser_only
:prog: tfutils
:prog: tfutility
:path: sourceswap
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "tfutils"
description = "TFUtils provides different tools for Terraform Developers"
name = "tfutility"
description = "TfUtility provides different tools for Terraform Developers"
dynamic = ["version"]
readme = { file = 'README.md', content-type = 'text/markdown' }
license = { file = 'LICENSE' }
Expand All @@ -13,7 +13,7 @@ dependencies = ["python-hcl2"]


[tool.setuptools]
packages = ["tfutils"]
packages = ["tfutility"]

[tool.setuptools.dynamic]
version = { file = "VERSION" }
Expand Down Expand Up @@ -44,7 +44,7 @@ exclude = '''
profile = "black"
line_length = 88
# known_third_party = ["your_third_party_lib"]
# known_first_party = "tfutils"
# known_first_party = "tfutility"

[tool.flake8]
max-line-length = 88
Expand All @@ -55,9 +55,9 @@ extend-ignore = "E203, W503"

[tool.coverage.run]
branch = true
#include = ["src/tfutils/*"]
#include = ["src/tfutility/*"]
# command_line = "-m unittest discover -s tests/"
source = ["."]

[project.scripts]
tfutils = "tfutils.main:main"
tfutility = "tfutility.main:main"
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
f.close()

setup(
name="tfutils",
name="tfutility",
version=VERSION,
description="TFUtils provides different tools for Terraform Developers",
description="TfUtility provides different tools for Terraform Developers",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
author="Stefan Eiermann",
author_email="foss@ultraapp.de",
url="https://github.com/eieste/tfutils.git",
url="https://github.com/eieste/tfutility.git",
license="AGPLv3",
packages=find_packages(),
package_dir={"": "src"},
package_data={"tfutils": ["templates/*"]},
package_data={"tfutility": ["templates/*"]},
include_package_data=True,
entry_points={"console_scripts": ["tfutils = tfutils.main:main"]},
entry_points={"console_scripts": ["tfutility = tfutility.main:main"]},
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import sys
from datetime import datetime, timedelta

from tfutils.core.base import Command
from tfutils.core.tffile import TfFile
from tfutils.core.tfpaths import TFPaths
from tfutility.core.base import Command
from tfutility.core.tffile import TfFile
from tfutility.core.tfpaths import TFPaths


class BlockDateHandler(TFPaths, Command):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
import sys

from tfutils.core.base import Command
from tfutils.core.tffile import TfFile
from tfutils.core.tfpaths import TFPaths
from tfutility.core.base import Command
from tfutility.core.tffile import TfFile
from tfutility.core.tfpaths import TFPaths


class ForcedRemoteSourceHandler(TFPaths, Command):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import re
import sys

from tfutils.core.base import Command
from tfutils.core.tffile import TfFile
from tfutils.core.tfpaths import TFPaths
from tfutility.core.base import Command
from tfutility.core.tffile import TfFile
from tfutility.core.tfpaths import TFPaths


class SWITCH_DIRECTION(enum.Enum):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/tfutils/core/base.py → src/tfutility/core/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import argparse

from tfutils.core.abstract import AbstractCommand
from tfutility.core.abstract import AbstractCommand


class Command(AbstractCommand):
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions src/tfutils/core/tffile.py → src/tfutility/core/tffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

import hcl2

from tfutils.contrib.deprecation import deprecated
from tfutility.contrib.deprecation import deprecated

# \#\s?\@([a-z]+)(\((.*)\))?

OpendTfFile = namedtuple("OpendTfFile", ("path", "lines", "parsed"))


class TfUtilDecorator:
class TfUtilityDecorator:
"""
Represents a tfutils decorator used in tf files above blocks
Represents a tfutility decorator used in tf files above blocks
"""

# Parses key="value", parameters ( used inside the decorator braces )
Expand Down Expand Up @@ -54,7 +54,7 @@ def _parse(self, data: str):
:return: A dictionary of key-value pairs
"""
result = {}
for regfind in TfUtilDecorator.PARAM_REGEX.findall(data):
for regfind in TfUtilityDecorator.PARAM_REGEX.findall(data):
result[regfind[0]] = regfind[1].strip('"')
return result

Expand All @@ -64,7 +64,7 @@ class TfBlock:
Represents a block in a terraform file
"""

# Parses an tfutils decorator inside terraform files
# Parses an tfutility decorator inside terraform files
DECORATOR_REGEX = re.compile(
r"#\s?\@([a-z]+)(\((.*)\))?",
)
Expand Down Expand Up @@ -150,7 +150,7 @@ def tffile(self):
def content(self):
return self._content

def get_decorator(self, name: str) -> TfUtilDecorator | None:
def get_decorator(self, name: str) -> TfUtilityDecorator | None:
"""
find a decorator with the given name above the current block
Expand Down Expand Up @@ -198,7 +198,7 @@ def _find_decorators(self):
found_decorator = self.get_tfile().lines[line_nr].strip()
result = TfBlock.DECORATOR_REGEX.fullmatch(found_decorator)
decorator_list.append(
TfUtilDecorator(self, result.group(1), result.group(2))
TfUtilityDecorator(self, result.group(1), result.group(2))
)
line_nr = -1

Expand Down
Loading

0 comments on commit bb9328a

Please sign in to comment.