Skip to content

Commit 532a4ea

Browse files
authored
Merge pull request #4 from Prodesire/feat/0.5.0
Current version 0.5.0 using Terraform 1.3.0
2 parents 773f480 + f9c43a3 commit 532a4ea

File tree

12 files changed

+67
-32
lines changed

12 files changed

+67
-32
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ jobs:
99
build:
1010
strategy:
1111
matrix:
12-
os: [ ubuntu-latest, windows-latest, macos-latest ]
13-
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10' ]
12+
os: [ ubuntu-20.04, windows-latest, macos-latest ]
13+
python-version: [ '3.7.9', '3.8.10', '3.9.13', '3.10.11', '3.11.5' ]
1414
runs-on: ${{ matrix.os }}
1515
steps:
1616
- name: Check out repository code
1717
uses: actions/checkout@v2
1818
- name: Set up GoLang
1919
uses: actions/setup-go@v2
2020
with:
21-
go-version: '1.17'
21+
go-version: '1.18'
2222
- name: Set up Python ${{ matrix.python-version }}
2323
uses: actions/setup-python@v2
2424
with:

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ jobs:
66
test:
77
strategy:
88
matrix:
9-
os: [ ubuntu-latest, windows-latest, macos-latest ]
10-
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10' ]
9+
os: [ ubuntu-20.04, windows-latest, macos-latest ]
10+
python-version: [ '3.7.9', '3.8.10', '3.9.13', '3.10.11', '3.11.5' ]
1111
runs-on: ${{ matrix.os }}
1212
steps:
1313
- name: Check out repository code
1414
uses: actions/checkout@v2
1515
- name: Set up GoLang
1616
uses: actions/setup-go@v2
1717
with:
18-
go-version: '1.17'
18+
go-version: '1.18'
1919
- name: Set up Python ${{ matrix.python-version }}
2020
uses: actions/setup-python@v2
2121
with:

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ test: clean-pyc
2828
build:
2929
$(PY3) -m poetry build -f wheel
3030

31+
build-all:
32+
$(PY3) -m poetry env use python3.7
33+
$(PY3) -m poetry build -f wheel
34+
$(PY3) -m poetry env use python3.8
35+
$(PY3) -m poetry build -f wheel
36+
$(PY3) -m poetry env use python3.9
37+
$(PY3) -m poetry build -f wheel
38+
$(PY3) -m poetry env use python3.10
39+
$(PY3) -m poetry build -f wheel
40+
$(PY3) -m poetry env use python3.11
41+
$(PY3) -m poetry build -f wheel
42+
3143
publish:
3244
$(PY3) -m poetry publish
3345

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![libterraform](https://img.shields.io/pypi/v/libterraform.svg)](https://pypi.python.org/pypi/libterraform)
44
[![libterraform](https://img.shields.io/pypi/l/libterraform.svg)](https://pypi.python.org/pypi/libterraform)
55
[![libterraform](https://img.shields.io/pypi/pyversions/libterraform.svg)](https://pypi.python.org/pypi/libterraform)
6-
[![Test](https://github.com/Prodesire/py-libterraform/actions/workflows/test.yml/badge.svg)](https://github.com/Prodesire/py-libterraform/actions/workflows/release.yml)
6+
[![Test](https://github.com/Prodesire/py-libterraform/actions/workflows/test.yml/badge.svg)](https://github.com/Prodesire/py-libterraform/actions/workflows/test.yml)
77
[![libterraform](https://img.shields.io/pypi/dm/libterraform)](https://pypi.python.org/pypi/libterraform)
88

99
Python binding for [Terraform](https://www.terraform.io/).
@@ -89,15 +89,16 @@ dict_keys(['time_sleep.wait1', 'time_sleep.wait2'])
8989

9090
| libterraform | Terraform |
9191
|-------------------------------------------------------|-------------------------------------------------------------|
92+
| [0.5.0](https://pypi.org/project/libterraform/0.5.0/) | [1.3.0](https://github.com/hashicorp/terraform/tree/v1.3.0) |
9293
| [0.4.0](https://pypi.org/project/libterraform/0.4.0/) | [1.2.2](https://github.com/hashicorp/terraform/tree/v1.2.2) |
9394
| [0.3.1](https://pypi.org/project/libterraform/0.3.1/) | [1.1.7](https://github.com/hashicorp/terraform/tree/v1.1.7) |
9495

9596
## Building & Testing
9697

9798
If you want to develop this library, should first prepare the following environments:
9899

99-
- [GoLang](https://go.dev/dl/) (Version 1.17.x or 1.16.x)
100-
- [Python](https://www.python.org/downloads/) (Version 3.6~3.10)
100+
- [GoLang](https://go.dev/dl/) (Version 1.18+)
101+
- [Python](https://www.python.org/downloads/) (Version 3.7~3.10)
101102
- GCC
102103

103104
Then, initialize git submodule:

libterraform/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from ctypes import cdll, c_void_p
33
from libterraform.common import WINDOWS
44

5-
__version__ = '0.4.0'
5+
__version__ = '0.5.0'
66

77
root = os.path.dirname(os.path.abspath(__file__))
88
_lib_filename = 'libterraform.dll' if WINDOWS else 'libterraform.so'

libterraform/cli.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def destroy(
584584

585585
def fmt(
586586
self,
587-
dir: str = None,
587+
dir: Union[str, List[str]] = None,
588588
check: bool = False,
589589
no_color: bool = True,
590590
list: bool = None,
@@ -626,7 +626,12 @@ def fmt(
626626
check=flag(check_input),
627627
recursive=flag(recursive),
628628
)
629-
args = [dir] if dir else None
629+
if dir:
630+
args = dir
631+
if not isinstance(dir, List):
632+
args = [dir]
633+
else:
634+
args = None
630635
retcode, stdout, stderr = self.run('fmt', args, options=options, chdir=self.cwd, check=check)
631636
return CommandResult(retcode, stdout, stderr, json=False)
632637

@@ -704,7 +709,6 @@ def import_resource(
704709
id: str,
705710
check: bool = False,
706711
config: str = None,
707-
allow_missing_config: bool = None,
708712
input: bool = False,
709713
lock: bool = None,
710714
lock_timeout: str = None,
@@ -745,7 +749,6 @@ def import_resource(
745749
to use to configure the provider. Defaults to pwd.
746750
If no config files are present, they must be provided
747751
via the input prompts or env vars.
748-
:param allow_missing_config: True to allow import when no resource configuration block exists.
749752
:param input: False to disable interactive prompts. Note that some actions may
750753
require interactive prompts and will error if input is disabled.
751754
:param lock: False to not hold a state lock during backend migration.
@@ -763,7 +766,6 @@ def import_resource(
763766
"""
764767
options.update(
765768
config=config,
766-
allow_missing_config=flag(allow_missing_config),
767769
input=input,
768770
lock=lock,
769771
lock_timeout=lock_timeout,
@@ -798,6 +800,7 @@ def output(
798800
:param json: Whether to load stdout as json.
799801
:param no_color: True to output not contain any color.
800802
:param state: Path to the state file to read. Defaults to "terraform.tfstate".
803+
Ignored when remote state is used.
801804
:param raw: For value types that can be automatically converted to a string,
802805
will print the raw string directly, rather than a human-oriented
803806
representation of the value.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "libterraform"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
description = "Python binding for Terraform."
55
authors = ["Prodesire <[email protected]>"]
66
license = "MIT"
@@ -30,7 +30,7 @@ packages = [
3030
include = ["libterraform/libterraform.so", "libterraform/libterraform.dll"]
3131

3232
[tool.poetry.dependencies]
33-
python = "^3.6"
33+
python = "^3.7"
3434

3535
[tool.poetry.dev-dependencies]
3636
pytest = "^7.0.1"

terraform

Submodule terraform updated 516 files

tests/cli/test_fmt.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import re
22

33
from libterraform import TerraformCommand
4-
from tests.consts import TF_SLEEP_DIR
4+
from tests.consts import TF_SLEEP_DIR, TF_SLEEP2_DIR
55

66

77
class TestTerraformCommandFmt:
@@ -15,3 +15,9 @@ def test_fmt_dir(self):
1515
r = cli.fmt(TF_SLEEP_DIR, list=False, write=False, diff=False, recursive=True)
1616
assert r.retcode == 0, r.error
1717
assert r.value
18+
19+
def test_fmt_dirs(self):
20+
cli = TerraformCommand()
21+
r = cli.fmt([TF_SLEEP_DIR, TF_SLEEP2_DIR], list=False, write=False, diff=False, recursive=True)
22+
assert r.retcode == 0, r.error
23+
assert r.value

tests/cli/test_import.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,3 @@ def test_import(self, cli: TerraformCommand):
1111
assert 'Import does not generate resource configuration' not in r.value
1212
finally:
1313
cli.destroy()
14-
15-
def test_import_missing(self, cli: TerraformCommand):
16-
cli.destroy()
17-
try:
18-
r = cli.import_resource('time_sleep.missing', '1s,')
19-
assert r.retcode == 1, r.value
20-
21-
r = cli.import_resource('time_sleep.missing', '1s,', allow_missing_config=True)
22-
assert r.retcode == 0, r.error
23-
assert 'Import successful!' in r.value
24-
assert 'Import does not generate resource configuration' in r.value
25-
finally:
26-
cli.destroy()

0 commit comments

Comments
 (0)