Skip to content

Commit e1ae747

Browse files
authored
Merge pull request #97 from aubustou/develop
Support for Terraform 0.14 and Python 3.6+
2 parents a33aebc + edfc33b commit e1ae747

File tree

19 files changed

+899
-890
lines changed

19 files changed

+899
-890
lines changed

.bumpversion.cfg

Lines changed: 0 additions & 7 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ Icon
1414

1515
# virtualenv
1616
.virtualenv/
17+
venv/
1718

1819

1920
# Intellij
2021
.idea/
2122

2223
# VSCode
2324
.vscode/
25+
pyrightconfig.json

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
default_language_version:
2+
python: python3.6
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.1.0 # v2.1.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-docstring-first
10+
- id: check-json
11+
- id: check-merge-conflict
12+
- id: check-toml
13+
- id: check-yaml
14+
- id: debug-statements
15+
- id: requirements-txt-fixer
16+
- repo: https://github.com/pycqa/isort
17+
rev: 5.5.2
18+
hooks:
19+
- id: isort
20+
- repo: https://github.com/lovesegfault/beautysh
21+
rev: 6.0.1
22+
hooks:
23+
- id: beautysh
24+
- repo: https://github.com/psf/black
25+
rev: 19.10b0
26+
hooks:
27+
- id: black

.travis.yml

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
language: python
22
python:
3-
- '2.7'
4-
- '3.5'
53
- '3.6'
4+
- '3.7'
5+
- '3.8'
6+
- '3.9'
67
before_install: sudo apt-get install unzip
78
before_script:
8-
- export TFVER=0.10.0
9+
- export TFVER=0.13.4
910
- export TFURL=https://releases.hashicorp.com/terraform/
1011
- TFURL+=$TFVER
1112
- TFURL+="/terraform_"
@@ -16,37 +17,12 @@ before_script:
1617
- unzip terraform_bin.zip -d tf_bin
1718
install:
1819
- curl https://bootstrap.pypa.io/ez_setup.py -o - | python
19-
- pip install tox-travis
2020
- pip install .
2121
script:
2222
- export PATH=$PATH:$PWD/tf_bin
23-
- tox
23+
- pytest -v
2424
branches:
2525
only:
2626
- master
2727
- develop
2828
- release/**
29-
deploy:
30-
- provider: pypi
31-
distributions: sdist
32-
server: https://testpypi.python.org/pypi
33-
user: beelit94
34-
password:
35-
secure: sWxc+p/gdq3k2WbUGNG2F4TukFNkTkvq6OPaiOvyfgWThYNk6/juRkMd8flmTbh0VGhcjFbpDLeSApb2kFhfiokYJSH1hOOcmXf8xzYH8/+R4DDEiGa5Y/pR9TBvYu4S8eJEfFUFfb1BBpapykj7o43hcaqMExBJIdVJU7aeoEAC1jQeTJh8wWwdJKHy2dNSM+6RVhk3e5+b0LfK7Bk5sU5P+YdEMj79MJU450J4OmZXWzJgvBN5/2QfVa5LrUD00nYuGuiBniz2lVevIHWjUYawUzpPsTa7F0s2WemG9YcV7U8u06xNjY9Ce3CTbxNhc7OIKq+TCkOgR3qZFXVJ8A87G+AT2iQ01VslQ4DJCxnJNTnpqojWnwf6MFL9O8ONioWYO32bhQFKOQ806ASHP4lNMRDKqx8hXtP5In7/r0SARKscv6Bas83rp+FESkKD5vWgkZJG+yx96LlwRLUhSVnVyb/nOJ++zt5RR3BvY2O4p9YAZY3Qt8TQihOdBQKnY3UXsMyNaE25+yvyNWpmyJiePRbTUd+cpLnycnqG9Ll8v6TpFXb6ahFMjlAFfJNQYlREfseClTHSRjZNxfsXGQCsJh6TZAq7jOB5hCk3q41eOUFWARxbyj8j59NBV8fSQrrGJJ9/VZKQeYiQlBB9KpK4PrnH84oeQ8i+VSbVr5w=
36-
on:
37-
branch: release/**
38-
tags: false
39-
condition: $TRAVIS_PYTHON_VERSION = "3.5"
40-
- provider: pypi
41-
distributions: sdist
42-
user: beelit94
43-
password:
44-
secure: QhCiTLrBvw/Uzt3eiLEmvMP3uHnayVCETqEDA+2+Q9vFavqj0CHA76zqYonBFqnh0a3HFCRIVVt+6ynpZ10kpQ3tAObIw+pY39ZPnpAhOjSpFzzMdpIF9Bhv9A93ng2iSESAZPAOwktHzUwjFx0Zvl0lSYD9rutHgttGgdU2CajiUtwTUhCTjOAVdR2Gm+15H808vzKWnMaKflXxZt+fkt279mQTYAtz6eBWtZwIKry/uAJCSrPSWtbi50O0HsWRMXLXWH5Jn/BVjWSDSM92DssUDq0D+tQyp4M5nQXJ9EyAvEdsKNLx3cvNruznh2ohI2jmcoIjwFiS6+wrEmUiXkP86iyzCSqL/EbcOG0xUh3vbfYtMBp7jENgD405+3SEhPY4PlqUmc+HDtB7FUcHz4y7wGWJRGyQzNnjJ6Tv0Ajdz5mfJubWVIvHjcRqkxTVtUKt50o00xZ62M0ZzQkDTIHQEsZly0XeHAgSvNzWkmjt9BiBrZ9OkoWVkRpSrCBy/EcpDNPCTSfSzOQ0Nq1ePFjkkW1n8QWDW9Pdb+/7/P2y9E2S8CT+nXBkRQeQiO86Qf1Ireg7k9TA5VYisVZ6bEXEc9UV0mAojpSsC7zWhVlbAoltN6ZbjKmqy/wqn2QIcJemcSie0JigzKpdw7l8FPT2lCRyTKlYLpRyKXzSkNI=
45-
on:
46-
branch: master
47-
tags: false
48-
condition: $TRAVIS_PYTHON_VERSION = "3.5"
49-
notifications:
50-
email:
51-
recipients:
52-

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
## [0.10.1]
1818
1. [#48] adding extension for temp file to adopt the change in terraform 0.12.0
19-
1. [#49] add workspace support
19+
1. [#49] add workspace support

DESCRIPTION.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Please see README at github_
22

3-
.. _github: https://github.com/beelit94/python-terraform/blob/master/README.md
3+
.. _github: https://github.com/beelit94/python-terraform/blob/master/README.md

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
44

55
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
66

7-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
## Introduction
22

3-
python-terraform is a python module provide a wrapper of `terraform` command line tool.
3+
python-terraform is a python module provide a wrapper of `terraform` command line tool.
44
`terraform` is a tool made by Hashicorp, please refer to https://terraform.io/
55

6+
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
7+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
8+
69
### Status
7-
[![Build Status](https://travis-ci.org/beelit94/python-terraform.svg?branch=develop)](https://travis-ci.org/beelit94/python-terraform)
10+
[![Build Status](https://travis-ci.org/aubustou/python-terraform.svg?branch=develop)](https://travis-ci.org/aubustou/python-terraform)
811

912
## Installation
1013
pip install python-terraform
11-
14+
1215
## Usage
1316
#### For any terraform command
1417

@@ -29,44 +32,44 @@ or just call cmd method directly
2932
from python_terraform import *
3033
t = Terraform()
3134
return_code, stdout, stderr = t.cmd(<cmd_name>, *arguments, **options)
32-
35+
3336
#### For any argument
3437
simply pass the string to arguments of the method, for example,
3538

36-
terraform apply target_dir
39+
terraform apply target_dir
3740
--> <instance>.apply('target_dir')
38-
terraform import aws_instance.foo i-abcd1234
41+
terraform import aws_instance.foo i-abcd1234
3942
--> <instance>.import('aws_instance.foo', 'i-abcd1234')
4043

4144
#### For any options
42-
45+
4346
* dash to underscore
4447

4548
remove first dash, and then use underscore to replace dash symbol as option name
46-
49+
4750
ex. -no-color --> no_color
4851

4952
* for a simple flag option
5053

51-
use ```IsFlagged/None``` as value for raising/not raising flag, for example,
52-
53-
terraform taint -allow-missing
54+
use ```IsFlagged/None``` as value for raising/not raising flag, for example,
55+
56+
terraform taint -allow-missing
5457
--> <instance>.taint(allow_missing=IsFlagged)
55-
terraform taint
58+
terraform taint
5659
--> <instance>.taint(allow_missing=None) or <instance>.taint()
5760
terraform apply -no-color
5861
--> <instance>.apply(no_color=IsFlagged)
59-
62+
6063
* for a boolean value option
61-
64+
6265
assign True or False, for example,
63-
66+
6467
terraform apply -refresh=true --> <instance>.apply(refresh=True)
65-
68+
6669
* if a flag could be used multiple times, assign a list to it's value
67-
70+
6871
terraform apply -target=aws_instance.foo[1] -target=aws_instance.foo[2]
69-
--->
72+
--->
7073
<instance>.apply(target=['aws_instance.foo[1]', 'aws_instance.foo[2]'])
7174
* for the "var" flag, assign dictionary to it
7275

@@ -84,19 +87,19 @@ By default, stdout and stderr are captured and returned. This causes the applica
8487
return_code, stdout, stderr = t.<cmd_name>(capture_output=False)
8588

8689
## Examples
87-
### Have a test.tf file under folder "/home/test"
90+
### Have a test.tf file under folder "/home/test"
8891
#### 1. apply with variables a=b, c=d, refresh=false, no color in the output
8992
In shell:
9093

9194
cd /home/test
9295
terraform apply -var='a=b' -var='c=d' -refresh=false -no-color
93-
96+
9497
In python-terraform:
9598

9699
from python_terraform import *
97100
tf = Terraform(working_dir='/home/test')
98101
tf.apply(no_color=IsFlagged, refresh=False, var={'a':'b', 'c':'d'})
99-
102+
100103
or
101104

102105
from python_terraform import *
@@ -108,40 +111,32 @@ or
108111
from python_terraform import *
109112
tf = Terraform(working_dir='/home/test', variables={'a':'b', 'c':'d'})
110113
tf.apply(no_color=IsFlagged, refresh=False)
111-
114+
112115
#### 2. fmt command, diff=true
113116
In shell:
114117

115118
cd /home/test
116-
terraform fmt -diff=true
117-
119+
terraform fmt -diff=true
120+
118121
In python-terraform:
119-
122+
120123
from python_terraform import *
121124
tf = terraform(working_dir='/home/test')
122125
tf.fmt(diff=True)
123126

124-
127+
125128
## default values
126-
for apply/plan/destroy command, assign with following default value to make
129+
for apply/plan/destroy command, assign with following default value to make
127130
caller easier in python
128131

129132
1. ```input=False```, in this case process won't hang because you missing a variable
130133
1. ```no_color=IsFlagged```, in this case, stdout of result is easier for parsing
131134

132135
## Implementation
133-
IMHO, how terraform design boolean options is confusing.
136+
IMHO, how terraform design boolean options is confusing.
134137
Take `input=True` and `-no-color` option of `apply` command for example,
135-
they're all boolean value but with different option type.
136-
This make api caller don't have a general rule to follow but to do
138+
they're all boolean value but with different option type.
139+
This make api caller don't have a general rule to follow but to do
137140
a exhaustive method implementation which I don't prefer to.
138-
Therefore I end-up with using `IsFlagged` or `IsNotFlagged` as value of option
141+
Therefore I end-up with using `IsFlagged` or `IsNotFlagged` as value of option
139142
like `-no-color` and `True/False` value reserved for option like `refresh=true`
140-
141-
142-
143-
144-
145-
146-
147-

0 commit comments

Comments
 (0)