Skip to content

for python3, ensure that packer inspect output is plain text #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ files:
git log --oneline --decorate --color > CHANGELOG

test:
@install -d var
@echo "Looking up latest Amazon Linux AMI"
aws ec2 describe-images --owners amazon --filters 'Name=virtualization-type,Values=hvm' 'Name=root-device-type,Values=ebs' 'Name=architecture,Values=x86_64' 'Name=is-public,Values=true' 'Name=name,Values=amzn-ami-hvm-*-gp2' --query 'Images[*].{aws_source_ami:ImageId,created:CreationDate,description:Description}' |jq 'sort_by(.created)[-1]' |tee var/amazon-linux.json
pip install tox==1.7.1
tox

Expand All @@ -37,4 +40,4 @@ prepare:
python scripts/make-release.py

publish:
python setup.py sdist upload
python setup.py sdist upload
3 changes: 2 additions & 1 deletion packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def inspect(self, mrf=True):

result = self.packer_cmd()
if mrf:
result.parsed_output = self._parse_inspection_output(result.stdout)
result.parsed_output = self._parse_inspection_output(
result.stdout.decode('utf-8'))
else:
result.parsed_output = None
return result
Expand Down
4 changes: 2 additions & 2 deletions tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
only = []
# vars = {"variable1": "y", "variable2": "value"}
vars = {}
vars_file = '/x'
var_file = 'packer/var/amazon-linux.json'

p = packer.Installer('packer_executables/', 'packer_0.7.5_linux_amd64.zip')
# If we installed packer using the provided installer, it will return
# packer's executable path. We can use it below:
# packer_exec = p.install()
packer_exec = 'packer'
p = packer.Packer(packerfile, exc=exc, only=only, vars=vars,
p = packer.Packer(packerfile, exc=exc, only=only, vars=vars, var_file=var_file,
exec_path=packer_exec)
# print(p.version())
# validation = p.validate(syntax_only=True)
Expand Down
4 changes: 2 additions & 2 deletions tests/resources/packerfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_source_ami": "",
"instance_type": "m3.large",
"instance_type": "t2.large",
"virtualbox_source_image": "",
"insecure_private_key": "./keys/insecure_private_key"
},
Expand Down Expand Up @@ -80,4 +80,4 @@
"format": "tar.gz"
}
]
}
}
9 changes: 5 additions & 4 deletions tests/test_packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@
TEST_RESOURCES_DIR = 'tests/resources'
TEST_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'packerfile.json')
TEST_BAD_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'badpackerfile.json')
TEST_VARFILE = 'var/amazon-linux.json')


class TestBase(testtools.TestCase):

def test_build(self):
p = packer.Packer(TEST_PACKERFILE)
p = packer.Packer(TEST_PACKERFILE, var_file=TEST_VARFILE)
p.build()

def test_fix(self):
p = packer.Packer(TEST_PACKERFILE)
p = packer.Packer(TEST_PACKERFILE, var_file=TEST_VARFILE)
p.fix()

def test_inspect(self):
p = packer.Packer(TEST_PACKERFILE)
p = packer.Packer(TEST_PACKERFILE, var_file=TEST_VARFILE)
p.inspect()

def test_validate(self):
p = packer.Packer(TEST_PACKERFILE)
p = packer.Packer(TEST_PACKERFILE, var_file=TEST_VARFILE)
p.validate()

def test_version(self):
Expand Down