Skip to content

Commit

Permalink
Added init command
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi1693 committed Jul 31, 2021
1 parent d06bce2 commit d50f5ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ def __init__(self, template, exc=None, only=None, vars=None,
self.packer = sh.Command(exec_path)
self.packer = self.packer.bake(**kwargs)

def init(self, upgrade=False):
"""Executes a `packer init`
:param bool upgrade: Updates plugins to the latest version
"""
self.packer_cmd = self.packer.init

self._add_opt('-upgrade' if upgrade else None)
self._add_opt(self.template)

return self.packer_cmd()

def build(self, parallel=True, debug=False, force=False, machine_readable=False):
"""Executes a `packer build`
Expand Down Expand Up @@ -243,11 +255,3 @@ def install(self):

def _verify_packer_installed(self, packer_path):
return os.path.isfile(packer_path)


class ValidationObject():
pass


class PackerException(Exception):
pass
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def read(*parts):

setup(
name='python-packer',
version='0.1.3',
version='1.0.1',
url='https://github.com/abhi1693/python-packer',
author='abhi1693',
author_email='desk.abhimanyu@gmail.com',
Expand Down

0 comments on commit d50f5ca

Please sign in to comment.